{"record":{"id":"0b77d2db63d1a536","repo":"PrefectHQ/fastmcp","slug":"forminput-requires-prefab-ui-install-with-pip-in","errorCode":null,"errorMessage":"FormInput requires prefab-ui. Install with: pip install 'fastmcp[apps]'","messagePattern":"FormInput requires prefab-ui\\. Install with: pip install 'fastmcp\\[apps\\]'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/apps/form.py","lineNumber":51,"sourceCode":"try:\n    import prefab_ui\n    from prefab_ui.actions import SetState\n    from prefab_ui.actions.mcp import CallTool, SendMessage\n    from prefab_ui.app import PrefabApp\n    from prefab_ui.components import (\n        H3,\n        Card,\n        CardContent,\n        CardFooter,\n        CardHeader,\n        Column,\n        Form,\n        Muted,\n    )\n    from prefab_ui.components.control_flow import If\n    from prefab_ui.rx import RESULT, STATE\nexcept ImportError as _exc:\n    raise ImportError(\n        \"FormInput requires prefab-ui. Install with: pip install 'fastmcp[apps]'\"\n    ) from _exc\n\n# `defaults` kwarg on Form.from_model was added in prefab-ui 0.19.1. Gate on\n# version so that older prefab-ui keeps working — `default` silently no-ops.\ntry:\n    _FORM_SUPPORTS_DEFAULTS = Version(prefab_ui.__version__) >= Version(\"0.19.1\")\nexcept InvalidVersion:\n    _FORM_SUPPORTS_DEFAULTS = False\n\nimport pydantic\n\nfrom fastmcp.apps.app import FastMCPApp\n\n\ndef _backfill_boolean_defaults(\n    model: type[pydantic.BaseModel],\n    data: dict[str, Any],","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/apps/form.py#L33-L69","documentation":"FastMCP's FormInput component in fastmcp/apps/form.py depends on the third-party prefab-ui package for UI primitives (Form, Muted, If, reactive STATE/RESULT). The module intentionally raises this ImportError at import time when prefab-ui is missing, telling you exactly which extra to install. FastMCP treats app/UI support as an optional dependency group so the core library stays lightweight.","triggerScenarios":"Importing fastmcp.apps.form (or anything importing it, e.g. FormInput / Form.from_model) in an environment where prefab_ui is not installed.","commonSituations":"Installed fastmcp or fastmcp-slim without the 'apps' extra; deployed to a fresh container/CI env from a requirements.txt that predates apps support; a dependency stripped prefab-ui.","solutions":["Run pip install 'fastmcp[apps]' (or add fastmcp[apps] to requirements/pyproject)","If using fastmcp-slim, install the equivalent extra that pulls in prefab-ui","Verify with python -c 'import prefab_ui' after installing"],"exampleFix":"# before\nfrom fastmcp.apps.form import FormInput  # ImportError\n\n# after\n# pip install 'fastmcp[apps]'\nfrom fastmcp.apps.form import FormInput","handlingStrategy":"fallback","validationCode":"import importlib.util\nif importlib.util.find_spec('prefab_ui') is None:\n    raise SystemExit(\"Install with: pip install 'fastmcp[apps]'\")","typeGuard":null,"tryCatchPattern":"try:\n    from fastmcp.apps.form import FormInput\nexcept ImportError as exc:\n    if 'prefab-ui' in str(exc):\n        print(\"Run: pip install 'fastmcp[apps]'\")\n    else:\n        raise","preventionTips":["Add fastmcp[apps] to your dependency manifest, not bare fastmcp","Smoke-test imports in CI with the same extras you use locally","Use uv sync so extras stay consistent across environments"],"tags":["dependency","optional-extra","import-error","prefab-ui"],"backgroundTag":"missing-optional-dependency","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}