Skip to content

fix: support MCP Python SDK 2.x (FastMCP renamed to MCPServer) - #6

Merged
eLyiN merged 1 commit into
mainfrom
fix/mcp-sdk-2-compat
Sep 30, 2026
Merged

eLyiN merged 1 commit into
mainfrom
fix/mcp-sdk-2-compat

Conversation

@eLyiN

@eLyiN eLyiN commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Root cause

Third-party directories and the README tell users to run uvx codex-bridge. That install
resolved the unbounded mcp>=1.0.0 dependency to the 2.x SDK, where FastMCP no longer
exists, so the published package died at startup:

ModuleNotFoundError: No module named 'mcp.server.fastmcp'. This is mcp 2.x, where FastMCP
was renamed to MCPServer (from mcp.server.mcpserver import MCPServer) ... or pin 'mcp<2' to
keep running v1 code.

Fix

  • Migrated src/mcp_server.py to the 2.x SDK: from mcp.server.mcpserver import MCPServer,
    mcp = MCPServer("codex-assistant").
  • Bounded the dependency to mcp>=2,<3 in pyproject.toml, .github/workflows/ci.yml
    (which installed mcp>=1.0.0 literally) and .github/workflows/release.yml.
  • Added tests/test_mcp_handshake.py: an offline, in-process MCP initialize handshake that
    lists the tools, so this class of breakage fails CI instead of shipping.
  • Version bumped to 1.2.4 in pyproject.toml and src/__init__.py, with a CHANGELOG entry.

Verification (real output, not claims)

  • Clean venv, pip install . on the branch, resolving mcp 2.2.0: console script completes the
    handshake and returns serverInfo.name = codex-assistant with the three tools
    (consult_codex, consult_codex_with_stdin, consult_codex_batch).
  • python tests/test_mcp_handshake.py passes in 0.01s.
  • Before the fix, the same console script on the published 1.2.3 exited 1 with the import error
    above.

Not in this PR

The PyPI release (tag v1.2.4) is deliberately not pushed. That step needs explicit human
approval; after merge, git tag v1.2.4 && git push origin v1.2.4 triggers the release workflow.

- Migrate src/mcp_server.py to mcp>=2: from mcp.server.mcpserver import MCPServer
- Bound dependency to mcp>=2,<3 in pyproject.toml, ci.yml and release.yml
- Add offline in-process initialize-handshake regression test

Root cause: the unbounded mcp>=1.0.0 dependency resolved to SDK 2.x, where
FastMCP was removed/renamed to MCPServer, so published installs crashed at
startup with ModuleNotFoundError: No module named 'mcp.server.fastmcp'.
@eLyiN
eLyiN merged commit 5bf260a into main Sep 30, 2026
7 checks passed
@eLyiN
eLyiN deleted the fix/mcp-sdk-2-compat branch September 30, 2026 15:19
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.

1 participant