# mcp 2.x Python SDK stack # # nixpkgs pins the MCP Python SDK at 1.x, whose server class is # `mcp.server.fastmcp.FastMCP`. SDK 2.x renamed it to # `mcp.server.mcpserver.MCPServer` and dropped the old module, so packages that # upstream has ported to the 2.x API need their own copy of the SDK rather than # the nixpkgs attribute. Derivations are isolated, so this stack coexists with # the 1.x packages in the same repository without affecting them. # # The three pure-Python wheels below (`mcp-types`, `httpx2`, `httpcore2`) are # not in nixpkgs; everything else resolves from the pinned nixpkgs. { lib, pythonPackages, fetchurl, }: let ps = pythonPackages; mk = { pname, version, url, hash, deps ? [ ] }: ps.buildPythonPackage { inherit pname version; format = "wheel"; src = fetchurl { inherit url hash; }; propagatedBuildInputs = deps; doCheck = false; # Upstream floors track the latest releases, which routinely sit ahead of # nixpkgs. The build is pure-Python and import-checked below, so the # strict floor check is not useful here. dontCheckRuntimeDeps = true; pythonImportsCheck = [ (builtins.replaceStrings [ "-" ] [ "_" ] pname) ]; meta = with lib; { description = "MCP Python SDK ${version} dependency: ${pname}"; homepage = "https://github.com/modelcontextprotocol/python-sdk"; license = licenses.mit; }; }; mcp-types = mk { pname = "mcp-types"; version = "2.1.1"; url = "https://files.pythonhosted.org/packages/71/d0/242e63c510f4a17381f55b1549a3f94f5687a0595984febd2b6f87a687a0/mcp_types-2.1.1-py3-none-any.whl"; hash = "sha256-Jvn38D8qVzBxeluY4qt+tkCsNS0FoAzcclwxGGR3gpU="; deps = with ps; [ pydantic typing-extensions ]; }; httpcore2 = mk { pname = "httpcore2"; version = "2.5.0"; url = "https://files.pythonhosted.org/packages/c9/a1/7564199d1a8728fe737b0a72e5b3f8d92dfe085a74ddf7cdd83bce5f206d/httpcore2-2.5.0-py3-none-any.whl"; hash = "sha256-XONRiN5GHTHo0AC/uO+L8ixsFlh6IR5Vcd6qXpvfhCo="; deps = with ps; [ h11 truststore ]; }; httpx2 = mk { pname = "httpx2"; version = "2.5.0"; url = "https://files.pythonhosted.org/packages/31/22/859d8252dad9bc9adee34b52e62cde621ece07b042ccb2ab4da1be46695f/httpx2-2.5.0-py3-none-any.whl"; hash = "sha256-PS1NnPS2HxofRqlZR8/bR+gMtWovkcYlasj1jkiR30E="; deps = with ps; [ anyio httpcore2 idna truststore ]; }; in { inherit mcp-types httpcore2 httpx2; mcp = mk { pname = "mcp"; version = "2.1.1"; url = "https://files.pythonhosted.org/packages/50/af/8644cc5fa26a59afd2df2e98eeb19e72926887fa4b7441aba4ff661140db/mcp-2.1.1-py3-none-any.whl"; hash = "sha256-HGwxxdZHHFjbdq86+K9n9G0R0B8KWQd9CjCMvbPT6RU="; deps = with ps; [ anyio httpx2 jsonschema mcp-types opentelemetry-api pydantic pyjwt python-multipart sse-starlette starlette typing-extensions typing-inspection uvicorn ] ++ (with ps; [ # mcp[cli] console entry point python-dotenv rich typer ]); }; }