Skip to content

set_up_component_manager: ?version= param permanently breaks tools/list ('str' object has no attribute 'matches') #5572

Closed

Description

@BlueX888

What happened?

fastmcp.contrib.component_manager.set_up_component_manager documents POST /tools/{name}/disable[?version=v1] as one of the routes it installs. Using that documented ?version=v1 form returns HTTP 200 and reports success, but it permanently breaks the server: every subsequent tools/list fails with an internal error, for all clients (over a real HTTP transport, a client tools/list after the POST fails with MCPError: Internal server error).

Output of the MRE below:

HTTP response: {"message":"Disabled tool: mytool"}
tools/list raises: AttributeError: 'str' object has no attribute 'matches'

Expected: the documented ?version=v1 form should work, and tools/list should keep working afterwards. Provider.enable/disable take version: VersionSpec | None (fastmcp/server/providers/base.py:604), but the route handler passes the raw query string through at fastmcp/contrib/component_manager/component_manager.py:115; the stored str later reaches self.version.matches(...) in fastmcp/server/transforms/visibility.py:179. Without ?version=, the same route works fine — the string is the trigger.

Example Code

import asyncio

from starlette.requests import Request

from fastmcp import FastMCP
from fastmcp.contrib.component_manager import set_up_component_manager


def make_request(query: bytes, path_params: dict) -> Request:
    return Request(
        {
            "type": "http",
            "method": "POST",
            "path": "/tools/mytool/disable",
            "raw_path": b"/tools/mytool/disable",
            "query_string": query,
            "headers": [],
            "path_params": path_params,
        }
    )


async def main():
    mcp = FastMCP("test")

    @mcp.tool
    def mytool() -> str:
        return "hi"

    set_up_component_manager(mcp)

    route = next(
        r
        for r in mcp._additional_http_routes
        if getattr(r, "path", "") == "/tools/{name}/disable"
    )

    # documented route: POST /tools/mytool/disable?version=v1
    response = await route.endpoint(make_request(b"version=v1", {"name": "mytool"}))
    print("HTTP response:", response.body.decode())

    try:
        tools = await mcp.list_tools()
        print("tools/list ok:", [t.name for t in tools])
    except Exception as e:
        print(f"tools/list raises: {type(e).__name__}: {e}")


asyncio.run(main())

Version Information

fastmcp 4.0.11.dev1+0ebabc0c (main @ 0ebabc0ceafafa2885484bdbf316695148b22f42)
mcp 2.0.0 / starlette 1.3.1
Python 3.12.14
macOS 15 (Darwin 25.6.0, arm64)

Happy to open a PR — either wrap the query param as VersionSpec(eq=version) in the handler, or coerce a str in Provider.enable/disable.

Related: #4050 reported the same str-vs-VersionSpec gap via call_tool (closed after no MRE was added); this is the same pattern reached through the component_manager routes.

Report prepared with LLM assistance; the MRE and the output above are verbatim from my runs against the commit cited above.

Activity

  1. added
    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.
    contribRelated to community contributions in src/contrib/ directory.
    on Oct 7, 2026
  2. BlueX888 commented on Oct 7, 2026

    @BlueX888
    ContributorAuthor

    Reproduced this. Root cause: fastmcp/contrib/component_manager/component_manager.py:115 passes the raw ?version= query string into Provider.enable/disable (version: VersionSpec | None); the stored str later reaches self.version.matches(...) in fastmcp/server/transforms/visibility.py:179, so every tools/list raises.

    Minimal reproduction:

    mcp = FastMCP("test")
    
    @mcp.tool
    def mytool() -> str:
        return "hi"
    
    set_up_component_manager(mcp)
    route = next(r for r in mcp._additional_http_routes if getattr(r, "path", "") == "/tools/{name}/disable")
    await route.endpoint(make_request(b"version=v1", {"name": "mytool"}))  # POST /tools/mytool/disable?version=v1
    await mcp.list_tools()  # raises
    

    Observed output:

    HTTP response: {"message":"Disabled tool: mytool"}
    tools/list raises: AttributeError: 'str' object has no attribute 'matches'
    

    Fix is ready on BlueX888:fix/prep-component-manager-version-str-poisons-list (commit 1b128e0d). Converts the query param to VersionSpec(eq=version) in the component-manager route handler before calling enable/disable.
    Verified with: uv run pytest tests/contrib/test_component_manager.py

    Happy to open the PR once you confirm the approach or assign this to me.

  3. added a commit that references this issue on Oct 9, 2026
    9c4a0b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.contribRelated to community contributions in src/contrib/ directory.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions