{"record":{"id":"b2171f00b0d3d644","repo":"PrefectHQ/fastmcp","slug":"choice-requires-prefab-ui-install-with-pip-insta","errorCode":null,"errorMessage":"Choice requires prefab-ui. Install with: pip install 'fastmcp[apps]'","messagePattern":"Choice requires prefab-ui\\. Install with: pip install 'fastmcp\\[apps\\]'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/apps/choice.py","lineNumber":39,"sourceCode":"try:\n    from prefab_ui.actions import SetState\n    from prefab_ui.actions.mcp import SendMessage\n    from prefab_ui.app import PrefabApp\n    from prefab_ui.components import (\n        H3,\n        Button,\n        Card,\n        CardContent,\n        CardFooter,\n        CardHeader,\n        Column,\n        Muted,\n        Text,\n    )\n    from prefab_ui.components.control_flow import If\n    from prefab_ui.rx import STATE\nexcept ImportError as _exc:\n    raise ImportError(\n        \"Choice requires prefab-ui. Install with: pip install 'fastmcp[apps]'\"\n    ) from _exc\n\nfrom fastmcp.apps.app import FastMCPApp\n\n\nclass Choice(FastMCPApp):\n    \"\"\"A Provider that lets the user choose from a set of options.\n\n    The LLM calls ``choose`` with a prompt and a list of options.\n    The user sees a card with one button per option. Clicking a button\n    sends the selection back into the conversation via ``SendMessage``,\n    triggering the LLM's next turn.\n\n    Example::\n\n        from fastmcp import FastMCP\n        from fastmcp.apps.choice import Choice","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/apps/choice.py#L21-L57","documentation":"fastmcp.apps.choice depends on the optional prefab-ui package for its UI components. When prefab_ui is missing, the module's import-time try/except re-raises an ImportError with this message (chained to the underlying error), stopping the import.","triggerScenarios":"`from fastmcp.apps.choice import Choice` (or importing the module) in an environment without prefab-ui installed.","commonSituations":"fastmcp installed without the [apps] extra; CI or server images built without optional deps; upgrading environments where extras were dropped.","solutions":["Run `pip install 'fastmcp[apps]'` to add prefab-ui.","Confirm `import prefab_ui` succeeds in the target environment.","Avoid importing fastmcp.apps.choice when the UI extra is not part of your deployment."],"exampleFix":"// before\nuv pip install fastmcp\n// after\nuv pip install 'fastmcp[apps]'","handlingStrategy":"fallback","validationCode":"import importlib.util\nif importlib.util.find_spec(\"prefab_ui\") is None:\n    raise SystemExit(\"Install fastmcp[apps] to use fastmcp.apps.choice\")","typeGuard":null,"tryCatchPattern":"try:\n    from fastmcp.apps.choice import Choice\nexcept ImportError as e:\n    Choice = None\n    print(f\"Choice UI unavailable: {e}; install 'fastmcp[apps]'\")","preventionTips":["Include the [apps] extra in all environments that use choice UIs","Add an import smoke test for fastmcp.apps.choice in CI","Keep extras synchronized between dev and prod dependency files"],"tags":["python","importerror","optional-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}