{"record":{"id":"62a72bdf5aecfc0e","repo":"PrefectHQ/fastmcp","slug":"approval-requires-prefab-ui-install-with-pip-ins","errorCode":null,"errorMessage":"Approval requires prefab-ui. Install with: pip install 'fastmcp[apps]'","messagePattern":"Approval requires prefab-ui\\. Install with: pip install 'fastmcp\\[apps\\]'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/apps/approval.py","lineNumber":41,"sourceCode":"    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        Row,\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        \"Approval requires prefab-ui. Install with: pip install 'fastmcp[apps]'\"\n    ) from _exc\n\n\nfrom fastmcp.apps.app import FastMCPApp\n\n\nclass Approval(FastMCPApp):\n    \"\"\"A Provider that adds human-in-the-loop approval to a server.\n\n    The LLM calls the ``request_approval`` tool with a summary and\n    optional details. The user sees an approval card with Approve and\n    Reject buttons. Clicking either sends a message back into the\n    conversation (via ``SendMessage``), triggering the LLM's next turn.\n\n    The message appears as if the user sent it, so the LLM sees\n    something like ``'\"Deploy v3.2 to production\" is APPROVED'``.\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/apps/approval.py#L23-L59","documentation":"Importing fastmcp.apps.approval requires the optional prefab-ui dependency, which provides the UI component primitives (Row, Text, If, STATE, etc.). If prefab_ui cannot be imported, the module re-raises the ImportError with this install hint, chained to the original exception.","triggerScenarios":"`import fastmcp.apps.approval` or `from fastmcp.apps.approval import Approval` in an environment where the `prefab-ui` package is not installed.","commonSituations":"Installing fastmcp without the [apps] extra; deploying to a fresh container/venv that omitted the extra; a broken or incompatible prefab-ui install.","solutions":["Install the extra: `pip install 'fastmcp[apps]'` (or `uv add 'fastmcp[apps]'`).","Verify with `python -c \"import prefab_ui\"` that the package is importable.","If prefab-ui is intentionally omitted, remove imports of fastmcp.apps.approval from your code path."],"exampleFix":"// before\npip install fastmcp\n// after\npip install 'fastmcp[apps]'","handlingStrategy":"fallback","validationCode":"def prefab_available() -> bool:\n    import importlib.util\n    return importlib.util.find_spec(\"prefab_ui\") is not None","typeGuard":null,"tryCatchPattern":"try:\n    from fastmcp.apps.approval import Approval\nexcept ImportError:\n    Approval = None\n    logger.warning(\"prefab-ui missing; approval UI disabled. Install 'fastmcp[apps]'\")","preventionTips":["Add fastmcp[apps] to requirements/pyproject extras","Verify prefab_ui in the deployment image build","Guard approval imports behind feature flags"],"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"}