PrefectHQ/fastmcp · error · ImportError
FormInput requires prefab-ui. Install with: pip install 'fas
Error message
FormInput requires prefab-ui. Install with: pip install 'fastmcp[apps]'
What it means
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.
Source
Thrown at fastmcp_slim/fastmcp/apps/form.py:51
try:
import prefab_ui
from prefab_ui.actions import SetState
from prefab_ui.actions.mcp import CallTool, SendMessage
from prefab_ui.app import PrefabApp
from prefab_ui.components import (
H3,
Card,
CardContent,
CardFooter,
CardHeader,
Column,
Form,
Muted,
)
from prefab_ui.components.control_flow import If
from prefab_ui.rx import RESULT, STATE
except ImportError as _exc:
raise ImportError(
"FormInput requires prefab-ui. Install with: pip install 'fastmcp[apps]'"
) from _exc
# `defaults` kwarg on Form.from_model was added in prefab-ui 0.19.1. Gate on
# version so that older prefab-ui keeps working — `default` silently no-ops.
try:
_FORM_SUPPORTS_DEFAULTS = Version(prefab_ui.__version__) >= Version("0.19.1")
except InvalidVersion:
_FORM_SUPPORTS_DEFAULTS = False
import pydantic
from fastmcp.apps.app import FastMCPApp
def _backfill_boolean_defaults(
model: type[pydantic.BaseModel],
data: dict[str, Any],View on GitHub (pinned to 1f02114297)
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
Example fix
# before from fastmcp.apps.form import FormInput # ImportError # after # pip install 'fastmcp[apps]' from fastmcp.apps.form import FormInput
Defensive patterns
Strategy: fallback
Validate before calling
import importlib.util
if importlib.util.find_spec('prefab_ui') is None:
raise SystemExit("Install with: pip install 'fastmcp[apps]'") Try / catch
try:
from fastmcp.apps.form import FormInput
except ImportError as exc:
if 'prefab-ui' in str(exc):
print("Run: pip install 'fastmcp[apps]'")
else:
raise Prevention
- 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
When it happens
Trigger: Importing fastmcp.apps.form (or anything importing it, e.g. FormInput / Form.from_model) in an environment where prefab_ui is not installed.
Common situations: 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.
Understand the failure class
Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.
Related errors
- GenerativeUI requires prefab-ui. Install with: pip install '
- FastMCP CLI support is not installed. Install `fastmcp` or `
- The `anthropic` package is not installed. Install it with `p
- The `openai` package is not installed. Please install `fastm
- The `google-genai` package is not installed. Install it with
AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29).
Data as JSON: /api/errors/0b77d2db63d1a536.
Report an issue: GitHub.