Skip to content

fix(mcp): add compatibility for mcp SDK 2.x (MCPServer fallback) - #10

Merged
riponcm merged 1 commit into
riponcm:mainfrom
VIVAAN-DHAWAN:fix-mcp-v2-compatibility
Sep 1, 2026
Merged

fix(mcp): add compatibility for mcp SDK 2.x (MCPServer fallback)#10
riponcm merged 1 commit into
riponcm:mainfrom
VIVAAN-DHAWAN:fix-mcp-v2-compatibility

Conversation

@VIVAAN-DHAWAN

Copy link
Copy Markdown
Contributor

Summary

In mcp SDK v2.0+, mcp.server.fastmcp was deprecated/renamed to mcp.server.mcpserver.MCPServer. Because pyproject.toml specifies mcp>=0.1.0 without an upper pin, environments running mcp 2.x fail on from mcp.server.fastmcp import FastMCP with ModuleNotFoundError.

Changes

  • Wrapped from mcp.server.fastmcp import FastMCP in a try/except that falls back to from mcp.server.mcpserver import MCPServer as FastMCP for seamless forward/backward compatibility.
  • Added test coverage in tests/test_mcp_server.py verifying server instantiation across MCP SDK versions.
  • Verified all 136 tests pass cleanly via pytest.

@riponcm

riponcm commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Thank you — this was a real catch, and a well-diagnosed one.

I verified it from first principles before merging: installed mcp 2.1.1 in a clean venv, reproduced the ModuleNotFoundError, and confirmed mcp/server/fastmcp.py in 2.x is a deliberate tombstone that raises on import. Your reading of the rename was exactly right.

It is worse than the PR describes, too: with mcp>=0.1.0 unpinned, every fresh pip install projectmem since mcp 2.0.0 landed on 2026-07-28 got an MCP server that died at import — markdown mode kept working, all the tools did not. Five weeks of new users hit that silently. Your fix is the thing that unbreaks them.

Two additions on top of your change, both shipping in 0.3.0:

  • pyproject.toml now declares mcp>=1.0,<3. The open upper bound is what let a major release break us quietly; the alias handles 2.x, the bound stops the next major doing the same.
  • A test that actually exercises the fallback — it poisons mcp.server.fastmcp in sys.modules and loads a fresh copy of the module, so the 2.x path runs even on a machine with mcp 1.x installed.

Checked both directions after applying: 15 tools register on mcp 2.1.1, full suite green on 1.27.1.

Merging with thanks. 🙏

@riponcm
riponcm merged commit ddb0ea6 into riponcm:main Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants