| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Enables tools to access the transport-level session ID (e.g., from streamable-http) via Context.session_id property. This supports session-level tracing and addresses user requests in modelcontextprotocol#485 and modelcontextprotocol#942. Changes: - Add session_id field to InitializationOptions - Store session_id in ServerSession and expose via property - Add session_id field to RequestContext dataclass - Pass session_id when creating RequestContext - Update StreamableHTTPSessionManager to pass session_id at init - Add session_id property to FastMCP Context class - Add comprehensive tests for session_id propagation The session_id is available for streamable-http transport and None for stdio/stateless modes. Tools can now correlate all requests within a session for observability and tracing purposes. Fixes modelcontextprotocol#485 Fixes modelcontextprotocol#942 Related to modelcontextprotocol#421 (OpenTelemetry tracing)
- Add ServerSession type arguments to Context in test tools - Switch to JSON response mode for easier testing (avoids SSE streaming complexity) - Update accept headers to match JSON response mode - All tests now pass locally Pyright errors in src/mcp/cli/*.py and src/mcp/client/websocket.py are pre-existing and not introduced by this change.
| Back | FazBrowse Home | New Git URL |
Summary
This PR enables tools to access the transport-level session ID via Context.session_id, supporting session-level tracing and observability use cases.
Changes
Usage
Tools can now access the session ID like this:
Behavior
Use Cases
Testing
Fixes
Related
Related to #421 (OpenTelemetry tracing integration)
Breaking Changes
None. This is a backward-compatible addition: