{"record":{"id":"7c52005c364a2f58","repo":"PrefectHQ/fastmcp","slug":"fastmcp-server-support-is-not-installed-install-7c5200","errorCode":null,"errorMessage":"FastMCP server support is not installed. Install `fastmcp` or `fastmcp-slim[server]`.","messagePattern":"FastMCP server support is not installed\\. Install `fastmcp` or `fastmcp-slim\\[server\\]`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/__init__.py","lineNumber":19,"sourceCode":"import importlib\nfrom typing import TYPE_CHECKING\n\nfrom fastmcp import _install_hints\n\nif TYPE_CHECKING:\n    from .context import Context as Context\n    from .server import FastMCP as FastMCP\n    from .server import create_proxy as create_proxy\n\n\ndef __getattr__(name: str) -> object:\n    if name in {\"context\", \"dependencies\"}:\n        return importlib.import_module(f\"fastmcp.server.{name}\")\n    if name == \"Context\":\n        try:\n            from .context import Context\n        except ImportError as exc:\n            raise ImportError(_install_hints.SERVER_SUPPORT) from exc\n\n        return Context\n    if name in {\"FastMCP\", \"create_proxy\"}:\n        try:\n            from .server import FastMCP, create_proxy\n        except ImportError as exc:\n            raise ImportError(_install_hints.SERVER_SUPPORT) from exc\n\n        return FastMCP if name == \"FastMCP\" else create_proxy\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n\n\n__all__ = [\"Context\", \"FastMCP\", \"create_proxy\"]\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/__init__.py#L1-L33","documentation":"`fastmcp.server` is a lazy loader: accessing `Context` triggers a deferred import of fastmcp.server.context, which only exists when full server dependencies are installed. In a slim install (fastmcp-slim without the [server] extra) the import fails with ImportError, which is re-raised as ImportError with the message 'FastMCP server support is not installed. Install `fastmcp` or `fastmcp-slim[server]`.'","triggerScenarios":"In a slim installation, execute `from fastmcp.server import Context` or `import fastmcp.server; fastmcp.server.Context` — the __getattr__ path at fastmcp_slim/fastmcp/server/__init__.py:19 converts the inner ImportError into the install-hint error.","commonSituations":"A project installed fastmcp-slim for client usage but shared code (or a tutorial) imports Context/FastMCP from fastmcp.server; CI uses the slim package while local dev uses full fastmcp; a dependency was slimmed down to shrink installs and server imports broke.","solutions":["Install server support: `pip install fastmcp-slim[server]` (or plain `pip install fastmcp`).","Guard server-only imports so client-only code doesn't touch fastmcp.server attributes.","Pin the full `fastmcp` package in server-related environments (requirements/pyproject).","If you maintain the slim package, verify the optional extra name in install hints matches your install command."],"exampleFix":"// before\npip install fastmcp-slim\nfrom fastmcp.server import Context  # ImportError\n\n// after\npip install \"fastmcp-slim[server]\"\nfrom fastmcp.server import Context","handlingStrategy":"fallback","validationCode":"import importlib.util\nif importlib.util.find_spec('fastmcp.server.context') is None:\n    raise ImportError(\"Install server support: pip install 'fastmcp-slim[server]'\")","typeGuard":null,"tryCatchPattern":"try:\n    from fastmcp.server import Context\nexcept ImportError as e:\n    raise SystemExit(f'server deps missing: {e}')","preventionTips":["Install the [server] extra wherever server code runs.","Add an import smoke test to CI for both slim and full installs.","Document which environments need full fastmcp vs fastmcp-slim."],"tags":["imports","installation","lazy-loading","optional-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}