mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-20 12:34:17 +02:00
* fix: forward custom_route endpoints from mounted servers When a child server with custom HTTP routes (registered via @server.custom_route()) is mounted onto a parent, the routes were silently dropped because _get_additional_http_routes() only returned self._additional_http_routes without recursing into mounted providers. This caused 404s for endpoints like /readyz health checks that worked in v2 but broke in v3 (regression). The fix updates _get_additional_http_routes() to traverse providers, unwrap _WrappedProvider layers (from namespace transforms), find FastMCPProvider instances, and recursively collect their server's custom routes. Fixes #3457 * fix: narrow type annotation from BaseRoute to Route All items in _additional_http_routes are Route objects (created via Route(...) in custom_route()). Using list[Route] instead of list[BaseRoute] fixes the ty type checker failure where .path is accessed on BaseRoute which doesn't have that attribute. Removes unused BaseRoute imports from both server.py and transport.py. * fix: revert route type to list[BaseRoute] to fix ty errors The previous commit narrowed _additional_http_routes from list[BaseRoute] to list[Route], which broke: - component_manager appending Mount objects (Mount is BaseRoute, not Route) - tests assigning list[BaseRoute] variables (generics are invariant) Revert to list[BaseRoute] and use isinstance(r, Route) guards in tests for type-safe .path access. * fix: remove unused import and fix import grouping - Remove unused `Route` import from server.py - Fix import grouping in test_advanced.py (ruff check) * Address review: move imports to module root, type Provider, add collision note * fix: sort imports in transport.py --------- Co-authored-by: voidborne-d <voidborne-d@users.noreply.github.com> Co-authored-by: d 🔹 <258577966+voidborne-d@users.noreply.github.com> Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_advanced.py | ||
| test_filtering.py | ||
| test_mount.py | ||
| test_prompts.py | ||
| test_proxy.py | ||
| test_resources.py | ||