fastmcp/tests/server/middleware
claude[bot] a9b6e71966 Add trace context propagation to OpenTelemetry middleware
Enable distributed tracing across protocols that don't support HTTP headers (like SSE) by propagating W3C Trace Context through MCP _meta fields.

- Add propagate_context parameter (default: True) to OpenTelemetryMiddleware
- Implement _extract_trace_context() to read traceparent/tracestate from request metadata
- Implement _inject_trace_context() to write trace context to response metadata
- Update all operation handlers to extract parent context and inject into results
- Add comprehensive test coverage for context propagation
- Update documentation with examples and configuration details

This enables trace continuity across MCP calls, allowing clients to link server spans to their traces and propagate context downstream.

Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-12-03 23:58:17 +00:00
..
__init__.py Add single-component methods 2025-06-18 19:47:19 -04:00
test_caching.py Actually update lockfile, ignore caching diskstore cleanup 2025-11-17 12:03:24 -06:00
test_error_handling.py transform NotFoundError to standard MCP error (#2133) 2025-10-18 11:46:57 -04:00
test_initialization_middleware.py Expose InitializeResult to middleware (#2516) 2025-12-01 20:55:29 -05:00
test_logging.py Update FastMCP for MCP SDK 1.23.1 auth changes 2025-12-03 11:50:08 -05:00
test_middleware.py Support initialize requests in middleware (#1546) 2025-10-05 10:20:13 -04:00
test_opentelemetry_middleware.py Add trace context propagation to OpenTelemetry middleware 2025-12-03 23:58:17 +00:00
test_rate_limiting.py Support initialize requests in middleware (#1546) 2025-10-05 10:20:13 -04:00
test_timing.py Use lowercase namespace for fastmcp logger (#1791) 2025-09-26 12:13:02 -04:00
test_tool_injection.py Add ToolInjectionMiddleware + Tools for Read/List Resource/Prompt for Client Compat (#2142) 2025-10-24 18:06:58 -04:00