{"record":{"id":"9e2be854a178d32c","repo":"Graphify-Labs/graphify","slug":"mcp-not-installed-run-pip-install-graphifyy-mcp","errorCode":null,"errorMessage":"mcp not installed. Run: pip install \"graphifyy[mcp]\"","messagePattern":"mcp not installed\\. Run: pip install \"graphifyy\\[mcp\\]\"","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"graphify/serve.py","lineNumber":1459,"sourceCode":"        clean = sanitize_label(str(community_name))\n        if clean and clean != base:\n            return f\"{base} — {clean}\"\n    return base\n\n\ndef _build_server(graph_path: str):\n    \"\"\"Build the configured low-level MCP Server (shared by every transport).\n\n    All graph query tools and resources are registered here over a single\n    ``mcp.server.Server`` instance; the caller picks the transport (stdio or\n    Streamable HTTP) and runs it. Hot-reload of graph.json works the same way\n    regardless of transport, since reloads happen inside the tool handlers.\n    \"\"\"\n    try:\n        from mcp.server import Server\n        from mcp import types\n    except ImportError as e:\n        raise ImportError('mcp not installed. Run: pip install \"graphifyy[mcp]\"') from e\n    try:\n        from mcp.types import AnyUrl\n    except ImportError:\n        # mcp >= 2.0 dropped the AnyUrl re-export; it was always pydantic's\n        # AnyUrl (pydantic is an mcp dependency, so this import cannot miss).\n        from pydantic import AnyUrl\n\n    from graphify import paths as _paths\n\n    # Graph contexts comprise one pinned configured default plus a bounded LRU\n    # of project_path graphs. This preserves the configured graph's warm index\n    # while preventing a shared server from retaining every project it serves.\n    _default_graph_path = str(Path(graph_path).resolve())\n    _ctx_cache = _GraphContextCache(_max_server_contexts())\n\n    def _load_ctx(path: str):\n        \"\"\"Return the current default or project graph context as a tool error.\n","sourceCodeStart":1441,"sourceCodeEnd":1477,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/serve.py#L1441-L1477","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\npip install graphifyy\ngraphify serve  # ImportError: mcp not installed\n\n# after\npip install \"graphifyy[mcp]\"\ngraphify serve","handlingStrategy":"validation","validationCode":"def mcp_extra_installed() -> bool:\n    try:\n        import mcp.server, mcp.types  # noqa: F401\n    except ImportError:\n        return False\n    return True\n\nassert mcp_extra_installed(), 'pip install \"graphifyy[mcp]\"'","typeGuard":"def can_build_mcp_server() -> bool:\n    return mcp_extra_installed()","tryCatchPattern":"try:\n    _build_server(graph_path)\nexcept ImportError as e:\n    if 'graphifyy[mcp]' in str(e):\n        sys.exit('Missing MCP dependencies. Run: pip install \"graphifyy[mcp]\"')\n    raise","preventionTips":["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."],"tags":["mcp","installation","dependencies"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}