fastmcp/tests
d 🔹 68e76fea2e
fix: forward custom_route endpoints from mounted servers (#3462)
* 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>
2026-03-13 20:37:22 -04:00
..
cli Sanitize untrusted output in fastmcp list and fastmcp call (#3409) 2026-03-07 12:31:46 -05:00
client fix: shield lifespan teardown from cancellation (#3480) 2026-03-13 19:47:42 -04:00
contrib Block recursive self-invocation in BulkToolCaller (#3433) 2026-03-07 11:41:15 -05:00
deprecated Deprecate PromptToolMiddleware and ResourceToolMiddleware (#3389) 2026-03-06 17:17:01 -05:00
experimental Remove stale catalog cache from CodeMode execute 2026-03-03 16:49:50 -05:00
fs fix: add version to components (#3458) 2026-03-13 17:33:50 -04:00
integration_tests Update repository references for transfer to prefecthq (#3207) 2026-02-18 10:33:56 -05:00
prompts Support ImageContent and AudioContent in Message class 2026-03-06 17:12:29 -05:00
resources Raise ValueError for invalid boolean query params in resource templates (#3424) (#3434) 2026-03-07 11:40:29 -05:00
server fix: forward custom_route endpoints from mounted servers (#3462) 2026-03-13 20:37:22 -04:00
telemetry Use standard traceparent/tracestate keys per OTel MCP semconv (#3221) 2026-02-18 15:51:24 -05:00
tools Fix transform arg collisions with passthrough params (#3431) 2026-03-07 11:41:07 -05:00
utilities Fix async partial callables rejected by iscoroutinefunction (#3438) 2026-03-07 12:10:09 -05:00
__init__.py Update type handling for resources 2024-11-29 19:42:46 -05:00
conftest.py Drop diskcache dependency (CVE-2025-69872) (#3185) 2026-02-16 16:43:15 -05:00
test_apps.py Rename ui= to app= and consolidate ToolUI/ResourceUI into AppConfig (#3117) 2026-02-08 20:26:47 -05:00
test_apps_prefab.py Add Prefab Apps integration for MCP tool UIs (#3316) 2026-02-27 14:37:57 -05:00
test_fastmcp_app.py Add FastMCPApp — a Provider for composable MCP applications (#3385) 2026-03-09 13:46:14 -04:00
test_json_schema_generation.py fix: use SkipJsonSchema to exclude callable fields from JSON schema generation (#3048) 2026-02-01 21:30:48 -05:00
test_mcp_config.py Fix flaky test_multi_client_lifespan and test_multi_client_force_close 2026-03-03 16:43:27 -05:00