From 50008cdf361ecd813aacde2bf479f93ea6b53d9a Mon Sep 17 00:00:00 2001 From: Nicola Avancini Date: Wed, 29 Jul 2026 19:10:33 +0200 Subject: [PATCH] fix(serve): cap the mcp extra below 2.0; AnyUrl fallback for the 2.x SDK mcp 2.0 removed the low-level decorator API (Server.list_tools/call_tool/ list_resources/read_resource) that serve.py is built on, so an install that resolved the unpinned extra to 2.0.0 crashed at server startup (first at `from mcp.types import AnyUrl`, then at @server.list_tools()). Pin mcp>=1,<2 in the `mcp` and `all` extras; import AnyUrl with a pydantic fallback so that piece is already 2.x-ready. Verified with a full stdio handshake (initialize / tools/list / tools/call) against the installed graphify-mcp with mcp 1.29.0. Porting to the 2.x API is a separate work item. Co-Authored-By: Claude Fable 5 --- graphify/serve.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/graphify/serve.py b/graphify/serve.py index 025fda41..cc64bd92 100644 --- a/graphify/serve.py +++ b/graphify/serve.py @@ -1190,9 +1190,14 @@ def _build_server(graph_path: str): try: from mcp.server import Server from mcp import types - from mcp.types import AnyUrl 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