Both HTTP transports now record the principal that created each session
— the OAuth client together with the issuer and subject when the token
verifier supplies them — and serve subsequent requests for that session
only when they present the same principal. Requests presenting a
different principal receive the same 404 response as for an unknown
session ID, and SSE session entries are removed when the connection
ends.
Servers without authentication, and authentication backends other than
the built-in BearerAuthBackend, are unaffected: no principal is recorded
and the comparison always passes.
The new in-process SSE tests bring connect_sse, handle_post_message, and
TransportSecurityMiddleware under tracked coverage, so the corresponding
no-cover pragmas are removed.
Summary
The Streamable HTTP and SSE transports now record the principal that created each session — the OAuth client together with the issuer and subject when the token verifier supplies them — and serve subsequent requests for that session only when they present the same principal. Requests presenting a different principal receive the same 404 response as for an unknown session ID. SSE session entries are also removed when the connection ends rather than retained for the lifetime of the transport.
The new in-process SSE tests bring connect_sse, handle_post_message, and TransportSecurityMiddleware under tracked coverage, so the corresponding no cover pragmas are removed.
Motivation
Brings the Python transports in line with the Go SDK (TokenInfo.UserID-keyed) and C# SDK (UserIdClaim-keyed). Relevant for hosted MCP hosts and gateways where many end-users go through one OAuth client.
Behaviour
Test plan
Breaking changes
None for default deployments. A hand-rolled SSE setup that applies BearerAuthBackend only to the POST route and not the GET route would now reject every message; MCPServer applies auth at the app level and is unaffected.
AI Disclaimer