fastmcp/tests/server/middleware
Jeremiah Lowin 635db7bde1
Resolve injected tools through the server's tool lookup (#5431)
`ToolInjectionMiddleware` contributes its tools to the server's own tool lookup. The server lists injected tools ahead of its provider tools and resolves them in `get_tool()`, so they take the same path as registered tools: a tool's `auth` check decides whether it is listed and callable, and every middleware in the chain, including `AuthMiddleware`, extension tool-call interceptors, and error masking, applies to injected tool calls. This holds wherever `ToolInjectionMiddleware` sits in the chain. Injected tools on a mounted server are also callable through the parent, consistent with how they are listed there.

An injected tool takes precedence over a registered tool with the same name, and the first injection middleware added takes precedence over later ones. The shadowed registered tool is not listed, so listing and calling agree. Injected tools are matched by name and follow their task configuration like registered tools. Server and session visibility settings still do not apply to injected tools.

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-04 10:39:47 -04:00
..
__init__.py Add single-component methods 2025-06-18 19:47:19 -04:00
test_caching.py Preserve binary resource contents in response cache (#5181) 2026-09-21 18:04:07 -05:00
test_caching_guards.py Split guard caching tests into their own module 2026-07-26 16:46:21 -04:00
test_dereference.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_discovery_middleware.py Forward proxy server metadata across protocol eras (#4776) 2026-08-06 19:09:05 -04:00
test_error_handling.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_initialization_middleware.py Audit mode="legacy" pins in server tests and top-level stragglers 2026-07-20 16:00:27 -04:00
test_logging.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_message_visibility.py Forward proxy server metadata across protocol eras (#4776) 2026-08-06 19:09:05 -04:00
test_middleware.py Update tests for the removed sampling and roots server API 2026-07-26 14:38:26 -04:00
test_middleware_nested.py Update tests for the removed sampling and roots server API 2026-07-26 14:38:26 -04:00
test_ping.py Audit mode="legacy" pins in server tests and top-level stragglers 2026-07-20 16:00:27 -04:00
test_rate_limiting.py rate_limiting: deprecate a burst_capacity below 1 (#5296) 2026-09-26 17:38:30 -05:00
test_response_limiting.py fix(middleware): align response limits with output schemas (#4931) 2026-08-27 18:00:48 -05:00
test_timing.py Consolidate test fixtures and refactor large test files (#2941) 2026-01-19 15:18:35 -05:00
test_tool_injection.py Resolve injected tools through the server's tool lookup (#5431) 2026-10-04 10:39:47 -04:00
test_versioned_caching.py Fix response cache partitioning for versioned components (#4948) 2026-08-31 01:23:41 -05:00