Skip to content

fix: migrate to mcp 2.x SDK (FastMCP -> MCPServer) - #27

Merged
shenxianpeng merged 1 commit into
mainfrom
fix/mcp-2-migration
Aug 2, 2026
Merged

fix: migrate to mcp 2.x SDK (FastMCP -> MCPServer)#27
shenxianpeng merged 1 commit into
mainfrom
fix/mcp-2-migration

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Aug 2, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the CI failure on #25 (ModuleNotFoundError: No module named 'mcp.server.fastmcp').

Root cause: dependabot PR #25 relaxes the mcp constraint to allow 2.x, and mcp 2.0.0 removes mcp.server.fastmcp — the module this server imports. All four test jobs (3.10–3.13) fail at collection.

Fix: migrate to the v2 API. mcp 2.0.0 replaced FastMCP with mcp.server.mcpserver.MCPServer, whose API is identical for this project's usage:

# before
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("commit-check-mcp", instructions=...)

# after
from mcp.server.mcpserver import MCPServer
mcp = MCPServer("commit-check-mcp", instructions=...)

Verified MCPServer.tool(), MCPServer.run(transport="stdio") and the instructions kwarg have the same signatures in 1.x/2.x.

Changes

  • src/commit_check_mcp/server.py — import + instantiate MCPServer (2 lines)
  • pyproject.toml — require mcp>=2,<3 (the code now uses a v2-only module; keeping >=1.27 would let pip resolve 1.x and break imports)
  • uv.lock — regenerated

Validation

  • Clean install from the new constraint resolves mcp 2.0.0; all 67 tests pass
  • All 8 MCP tools register on the v2 server (server_health, validate_commit_message, validate_branch_name, validate_author_info, validate_push_safety, validate_commit_context, validate_repository_state, describe_validation_rules)
  • CI failure reproduced locally before the fix (same traceback as GitHub Actions)

Supersedes #25 (close #25 after merging this).

Summary by CodeRabbit

  • New Features

    • Updated compatibility with MCP version 2.
    • Continued support for existing server configuration and registered tools.
  • Bug Fixes

    • Improved server startup compatibility following the MCP framework update.

mcp 2.0.0 removes mcp.server.fastmcp; the replacement mcp.server.mcpserver.MCPServer has an identical API for this project's usage (tool decorator, instructions, run(transport='stdio')). All 8 tools register and all 67 tests pass against mcp 2.0.0.

Require mcp>=2,<3 since the code now uses the v2-only module; keep uv.lock in sync.
@github-actions github-actions Bot added the bug Something isn't working label Aug 2, 2026
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bfc73e28-c69c-4873-81af-fdf6981c5427

📥 Commits

Reviewing files that changed from the base of the PR and between c4be16d and e150df6.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • pyproject.toml
  • src/commit_check_mcp/server.py

📝 Walkthrough

Walkthrough

The project now requires MCP v2. The server imports and instantiates MCPServer instead of FastMCP.

Changes

MCP v2 migration

Layer / File(s) Summary
Update MCP dependency and server initialization
pyproject.toml, src/commit_check_mcp/server.py
The mcp requirement now targets version 2. The server uses MCPServer while retaining its existing configuration and tool registrations.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The source migration and dependency constraint satisfy the visible issue requirements, but uv.lock regeneration cannot be verified because uv.lock was excluded by !**/*.lock. Include uv.lock in the review or provide evidence that it resolves mcp to version 2.0.0 or later.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the MCP 2.x migration and the FastMCP to MCPServer API change.
Out of Scope Changes check ✅ Passed The reviewed changes are limited to the MCP dependency update and required server API migration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mcp-2-migration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c4be16d) to head (e150df6).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #27   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          203       203           
=========================================
  Hits           203       203           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shenxianpeng
shenxianpeng merged commit b1c61e4 into main Aug 2, 2026
7 checks passed
@shenxianpeng
shenxianpeng deleted the fix/mcp-2-migration branch August 2, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants