PrefectHQ/fastmcp · error · ImportError
FastMCP CLI support is not installed. Install `fastmcp` or `
Error message
FastMCP CLI support is not installed. Install `fastmcp` or `fastmcp-slim[server]`.
What it means
fastmcp/cli/__init__.py wraps the import of the CLI app in try/except ImportError and re-raises with an install hint: either install the full `fastmcp` package or fastmcp-slim with the `[server]` extra. The slim distribution ships without CLI dependencies to stay minimal.
Source
Thrown at fastmcp_slim/fastmcp/cli/__init__.py:8
"""FastMCP CLI package."""
try:
from .cli import app
except ImportError as exc:
from fastmcp import _install_hints
raise ImportError(_install_hints.CLI_SUPPORT) from exc
View on GitHub (pinned to 1f02114297)
Solutions
- pip install fastmcp (full package) to get CLI support
- Or pip install 'fastmcp-slim[server]' to add CLI deps to the slim build
- Confirm the CLI entrypoint resolves: fastmcp --help
Defensive patterns
Strategy: fallback
Validate before calling
import importlib.util
try:
importlib.util.find_spec('fastmcp.cli')
except Exception:
raise SystemExit('Install `fastmcp` or `fastmcp-slim[server]` for CLI support') Try / catch
try:
from fastmcp.cli import app
except ImportError as exc:
if 'CLI support' in str(exc):
print('Install `fastmcp` or `fastmcp-slim[server]`')
else:
raise Prevention
- Use the full fastmcp package wherever the CLI is needed
- Document that slim installs need fastmcp-slim[server] for CLI commands
- Verify `fastmcp --help` works in your container image build
When it happens
Trigger: `from fastmcp.cli import app` (or importing fastmcp.cli at all) in a fastmcp-slim install without the server extra; invoking the CLI entrypoint from a slim install.
Common situations: Using fastmcp-slim in production images and then attempting fastmcp run/dev/install CLI commands; CI scripts assuming full fastmcp; partially-installed package where CLI deps were skipped.
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
- FormInput requires prefab-ui. Install with: pip install 'fas
- GenerativeUI requires prefab-ui. Install with: pip install '
- The `anthropic` package is not installed. Install it with `p
- Expected integer, got {raw!r}
- Expected number, got {raw!r}
AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29).
Data as JSON: /api/errors/dfd4e319654fe644.
Report an issue: GitHub.