MCP: mcp 2.3 (MCPServer, transport arguments on streamable_http_app, bearer read in middleware); tests for the 2026-07-28 revision and the resource check

This commit is contained in:
2026-10-28 09:21:01 +01:00
parent c04d6b83c6
commit c04e4883c2
8 changed files with 224 additions and 55 deletions
+7 -4
View File
@@ -167,18 +167,21 @@ class _ThroughThePortal:
def build_http_app(app: object) -> ASGIApp:
"""The MCP sub-app, wired to this app's API and its OAuth server."""
server.mcp.settings.stateless_http = True
server.mcp.settings.json_response = True
server.mcp.settings.auth = AuthSettings(
issuer_url=AnyHttpUrl(settings.oauth_issuer),
resource_server_url=AnyHttpUrl(settings.mcp_resource),
required_scopes=None,
validate_token_resource=True,
)
server.mcp.settings.transport_security = _transport_security()
# The SDK only takes a verifier through its constructor, and the instance is
# module-level so the tools can be declared at import time.
server.mcp._token_verifier = _JWTVerifier() # noqa: SLF001
server.connect(app)
return _ThroughThePortal(server.mcp.streamable_http_app())
return _ThroughThePortal(
server.mcp.streamable_http_app(
stateless_http=True,
json_response=True,
transport_security=_transport_security(),
)
)