Graphify-Labs/graphify · error · ImportError
mcp not installed. Run: pip install "graphifyy[mcp]"
Error message
mcp not installed. Run: pip install "graphifyy[mcp]"
What it means
Raised in _build_server (graphify/serve.py) when `from mcp.server import Server` (or `from mcp import types`) fails with ImportError. Every transport (stdio and HTTP) builds its tool/resource registrations through this function, so without the mcp package no server can start. The chained original ImportError identifies exactly which module was missing.
Source
Thrown at graphify/serve.py:1459
clean = sanitize_label(str(community_name))
if clean and clean != base:
return f"{base} — {clean}"
return base
def _build_server(graph_path: str):
"""Build the configured low-level MCP Server (shared by every transport).
All graph query tools and resources are registered here over a single
``mcp.server.Server`` instance; the caller picks the transport (stdio or
Streamable HTTP) and runs it. Hot-reload of graph.json works the same way
regardless of transport, since reloads happen inside the tool handlers.
"""
try:
from mcp.server import Server
from mcp import types
except ImportError as e:
raise ImportError('mcp not installed. Run: pip install "graphifyy[mcp]"') from e
try:
from mcp.types import AnyUrl
except ImportError:
# mcp >= 2.0 dropped the AnyUrl re-export; it was always pydantic's
# AnyUrl (pydantic is an mcp dependency, so this import cannot miss).
from pydantic import AnyUrl
from graphify import paths as _paths
# Graph contexts comprise one pinned configured default plus a bounded LRU
# of project_path graphs. This preserves the configured graph's warm index
# while preventing a shared server from retaining every project it serves.
_default_graph_path = str(Path(graph_path).resolve())
_ctx_cache = _GraphContextCache(_max_server_contexts())
def _load_ctx(path: str):
"""Return the current default or project graph context as a tool error.
View on GitHub (pinned to 7fe58b0b0f)
Solutions
- Install the extra: pip install "graphifyy[mcp]" (message is literal).
- Verify the interpreter matches: `python -m pip install "graphifyy[mcp]"` using the same python that runs the server.
- Confirm the import works: python -c "from mcp.server import Server; from mcp import types".
- If the import still fails after install, check for a conflicting local file/dir named mcp/ shadowing the package.
Example fix
# before pip install graphifyy graphify serve # ImportError: mcp not installed # after pip install "graphifyy[mcp]" graphify serve
Defensive patterns
Strategy: validation
Validate before calling
def mcp_extra_installed() -> bool:
try:
import mcp.server, mcp.types # noqa: F401
except ImportError:
return False
return True
assert mcp_extra_installed(), 'pip install "graphifyy[mcp]"' Type guard
def can_build_mcp_server() -> bool:
return mcp_extra_installed() Try / catch
try:
_build_server(graph_path)
except ImportError as e:
if 'graphifyy[mcp]' in str(e):
sys.exit('Missing MCP dependencies. Run: pip install "graphifyy[mcp]"')
raise Prevention
- Install with extras at setup time: pip install "graphifyy[mcp]".
- Pin the same interpreter in launcher configs as the one with the extras installed.
- Add a smoke import (from mcp.server import Server) to container health checks.
When it happens
Trigger: Calling serve()/serve_http or otherwise triggering _build_server in an environment where the `mcp` package (the pip extra graphifyy[mcp]) is not installed. Also fires when mcp is installed but broken — wrong version, missing dependency, partially uninstalled.
Common situations: Installing graphifyy without extras (pip install graphifyy) and then running graphify serve; a venv mismatch where the server runs under a different interpreter than the one with mcp; dependency resolver downgrading/removing mcp.
Related errors
- HTTP transport needs the mcp extra (mcp + starlette + uvicor
- graphify install is incomplete: missing always-on block '{ba
- the '{pkg}' package is required for this backend but is not
- the 'anthropic' package is required for this backend but is
- Claude Code CLI not found on $PATH. Install from https://cla
AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14).
Data as JSON: /api/errors/9e2be854a178d32c.
Report an issue: GitHub.