Skip to content

fix: replace _tool_manager with local_provider for FastMCP 3.x tool-filter compat#396

Open
sdeonvacation wants to merge 2 commits intotirth8205:mainfrom
sdeonvacation:fix/fastmcp-3x-tool-filter-compat
Open

fix: replace _tool_manager with local_provider for FastMCP 3.x tool-filter compat#396
sdeonvacation wants to merge 2 commits intotirth8205:mainfrom
sdeonvacation:fix/fastmcp-3x-tool-filter-compat

Conversation

@sdeonvacation
Copy link
Copy Markdown
Contributor

Problem

FastMCP 3.x removed _tool_manager from the FastMCP instance. Code-review-graph used mcp._tool_manager to enumerate and filter tools via CRG_TOOLS, causing an AttributeError startup crash on FastMCP ≥ 3.0.

Fix

Switch the tool-filter implementation to use mcp.local_provider:

  • Enumerate registered tools via mcp.local_provider._components (keys prefixed tool:)
  • Remove unwanted tools via mcp.local_provider.remove_tool(name)

This is API-stable in FastMCP 3.x and fully backwards-compatible with the existing CRG_TOOLS env-var contract.

Testing

Updated tests/test_main.py to patch local_provider instead of _tool_manager.

Related

Split from PR #394 (fix/get-minimal-context-async) to keep concerns separate.

Keep only the semantic FastMCP 3.x compatibility edits:
- main.py: enumerate tools via mcp.local_provider._components instead of _tool_manager._tools
- main.py: remove via mcp.local_provider.remove_tool() instead of mcp.remove_tool()
- tests/test_main.py: fixture snapshot/restore via local_provider._components
- tests/test_main.py: sync _tool_names() helper replacing async get_tools() path
- tests/test_main.py: docstring update to local_provider.remove_tool()

Reverts: one-arg-per-line call reflows, blank line near asyncio import,
set-literal reformat, extra blank line before class, EOF whitespace churn.
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