fastmcp/tests/server/middleware
Jeremiah Lowin 3213776b25
Run FastMCP middleware for every inbound message (#4553)
* Make the SDK seam the root of FastMCP middleware dispatch (D3)

Notifications, cancellations, and malformed/unroutable messages now reach
on_message/on_request/on_notification at the SDK seam. Component methods keep
their interior dispatch (typed hooks, tool-exception visibility) unchanged; the
seam covers only messages the interior never dispatches, so each hook fires once.

* Document the middleware seam coverage and suspend semantics (D3)

* Align seam docs and ask-visibility test with the result-cycle MRTR model

An InputRequiredResult is the full result of a complete request->response
cycle, not a suspension: component hooks observe an asking round's
InputRequiredToolResult as an ordinary return value.

* Replace 'seam' language with plain dispatch terminology

* Keep the raw middleware __call__ signature; forward middleware message edits

* Cover fires-once across an MRTR continuation round

* Align cherry-picked coverage test with renamed recorder

* Rewrite only the message, never the dispatch destination
2026-07-19 20:29:08 -04:00
..
__init__.py Add single-component methods 2025-06-18 19:47:19 -04:00
test_caching.py Fix typos (#4498) 2026-07-18 21:18:39 -04:00
test_dereference.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -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 Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_logging.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_message_visibility.py Run FastMCP middleware for every inbound message (#4553) 2026-07-19 20:29:08 -04:00
test_middleware.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_middleware_nested.py Repoint tests and examples off removed deprecations 2026-07-07 07:53:11 -04:00
test_ping.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_rate_limiting.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_response_limiting.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04: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 Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00