Skip to content

Conversation

@naji247
Copy link
Member

@naji247 naji247 commented Jan 28, 2026

Summary

  • Add support for Community FastMCP v3 (fastmcp>=3.0.0b1) using v3's official Middleware system instead of monkey-patching, while maintaining full backwards compatibility with v2
  • Implement MCPCatMiddleware with on_initialize, on_call_tool, and on_list_tools hooks that handle event tracking, context parameter injection, tool registry, client info extraction, and actor identification
  • Add version detection functions (is_community_fastmcp_v3, is_community_fastmcp_v2) and update track() routing logic to select the appropriate integration path

Test plan

  • Run full test suite: .venv/bin/python -m pytest tests/ -v (255 passed, 2 skipped)
  • Verify community tests pass: .venv/bin/python -m pytest tests/community/ -v (63 passed)
  • Confirm v3 middleware captures client name/version from initialize params
  • Confirm context parameter injection works on tool schemas
  • Confirm get_more_tools (report missing) feature works with v3
  • Confirm tool registry is populated when tools are listed or called

Use FastMCP v3's official Middleware system instead of monkey-patching
for cleaner, more maintainable integration. Maintains full backwards
compatibility with v2.

- Add MCPCatMiddleware for v3 with on_initialize, on_call_tool, on_list_tools
- Add version detection (is_community_fastmcp_v3, is_community_fastmcp_v2)
- Extract MCP client info and actor identity from middleware context
- Support context parameter injection, get_more_tools, tool registry
- Update tests to be version-agnostic with get_lowlevel_server helper
[project.optional-dependencies]
community = [
"fastmcp>=2.7.0,!=2.9.*",
"fastmcp==3.0.0b1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't pin version here, right?


_version = getattr(fastmcp, "__version__", "0.0.0")
# v3 starts at 3.0.0b1
IS_FASTMCP_V3 = _version.startswith("3.") or _version.startswith("3")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first check makes the second redundant? Also this would match 30 and above I guess but less of an issue.

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.

3 participants