8000 fix: support MCP Python SDK 2.x (FastMCP renamed to MCPServer) by eLyiN · Pull Request #10 · eLyiN/gemini-bridge · GitHub
[go: up one dir, main page]

Skip to content

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

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

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

Conversation

@eLyiN
@eLyiN eLyiN commented Sep 30, 2026
Copy link
Copy Markdown
Owner

Root cause

pyproject.toml declared mcp>=1.0.0 with no upper bound. The current MCP Python SDK 2.x renamed FastMCP to MCPServer (from mcp.server.mcpserver import MCPServer), so every fresh install (uvx gemini-bridge) resolved to mcp 2.x and crashed at startup with:

ModuleNotFoundError: No module named 'mcp.server.fastmcp'

PyPI latest published (1.3.1) has requires_dist ['mcp>=1.0.0'], so the published package is broken for every new install right now.

Fix

Mirrors the codex-bridge fix (eLyiN/codex-bridge#6, released as 1.2.4):

  • src/mcp_server.py: from mcp.server.mcpserver import MCPServer and mcp = MCPServer("gemini-assistant") — nothing else touched in that file.
  • Dependency bound to mcp>=2,<3 in pyproject.toml and the README dependency mention. CI installs the built wheel, so the bound flows through transitive resolution; no workflow pins the old range.
  • New offline, in-process regression test tests/test_mcp_handshake.py: completes a real MCP initialize handshake against the server object and asserts the tool list is exactly consult_gemini, consult_gemini_with_files, web_search. No network, ~0.01s. Also runs as a CI step before pytest.
  • Version bumped to 1.3.2 (pyproject.toml, src/__init__.py) with a CHANGELOG entry dated 2026-09-30.

Verification (clean venv, real run)

Created a clean venv with /opt/homebrew/bin/python3.11 -m venv, pip install'd the repo into it (resolved mcp 2.2.0), then drove the installed gemini-bridge console script over stdio with JSON-RPC initialize + tools/list. Literal output:

initialize response:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "capabilities": {
      "experimental": {},
      "prompts": { "listChanged": false },
      "resources": { "listChanged": false, "subscribe": false },
      "tools": { "listChanged": false }
    },
    "protocolVersion": "2025-06-18",
    "serverInfo": { "name": "gemini-assistant", "version": "" }
  }
}
tools/list response: tools = [consult_gemini, consult_gemini_with_files, web_search]
STDIO HANDSHAKE OK in 0.63s; serverInfo={'name': 'gemini-assistant', 'version': ''}; tools=['consult_gemini', 'consult_gemini_with_files', 'web_search']

In-process regression test in the same venv:

🧪 serverInfo: name='gemini-assistant' version=''
🧪 protocol version: 2025-11-25
✅ handshake succeeded with serverInfo.name == 'gemini-assistant'
🧪 Listed tools: ['consult_gemini', 'consult_gemini_with_files', 'web_search']
✅ tool list is exactly the expected three Gemini tools
🧪 Elapsed: 0.01s
🎉 MCP handshake regression test passed!

Existing suite: 38 passed in 0.35s.

Release gating

The PyPI release (tag + v1.3.2 publish via the release workflow) is intentionally left to a human. This PR only fixes the code.

- Migrate src/mcp_server.py to mcp>=2: from mcp.server.mcpserver import MCPServer
- Bound dependency to mcp>=2,<3 in pyproject.toml and README.md
- Add offline in-process initialize-handshake regression test (tests/test_mcp_handshake.py)
- Run the handshake regression test in CI before the pytest suite
- Bump version to 1.3.2 and add CHANGELOG entry

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 75f6f2d into master Sep 30, 2026
3 checks passed
@eLyiN
eLyiN deleted the fix/mcp-sdk-2-compat branch September 30, 2026 15:35
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

0