Files
fastmcp-feedback/tests/_compat.py
T
rsp2k ddf23d10e4
Tests / test (==2.12.2) (push) Canceled after 0s
Tests / test (==2.14.3) (push) Canceled after 0s
Tests / test (>=4,<5) (push) Canceled after 0s
Tests / canary (push) Canceled after 0s
Support FastMCP 4 and fix silent composition failure
compose_feedback_services() called import_server() without awaiting it.
That method became async in FastMCP 2.14, so on the version this package
was built against it composed nothing while logging success. FastMCP 4
removed it outright. Use mount(), which is sync on 2.12 through 4.x.

The test suite could not start (pytest-html hook, plugin not installed),
so nothing caught this. Add pytest-html, bring examples/ over from the docs
repo since the integration tests import them, and fix the tests that had
drifted from the code. 407 tests pass on FastMCP 2.12.2, 2.14.3 and 4.0.10.

- Declare fastmcp>=2.12.2,<5; CI matrix covers each family plus a
  non-blocking canary on the newest FastMCP
- Add a composition test with real servers; the mocked ones could not
  see a missing await
- Rewrite the README against the actual API and execute its examples
- Ignore ruff UP042: StrEnum would change stored enum formatting
- Version 2026.09.27
2026-09-27 06:09:30 -06:00

11 lines
385 B
Python

"""Helpers that paper over FastMCP API differences between 2.x and 4.x."""
from fastmcp import FastMCP
async def tool_map(server: FastMCP) -> dict:
"""Return {name: Tool}. 2.x has get_tools() -> dict, 4.x has list_tools() -> list."""
if hasattr(server, "get_tools"):
return await server.get_tools()
return {tool.name: tool for tool in await server.list_tools()}