"""Delegate MCP transport/metadata with the original request path intact.""" class McpDispatchMiddleware: def __init__(self, app, runtime): self.app, self.runtime = app, runtime async def __call__(self, scope, receive, send): path = scope.get("path", "") if scope["type"] == "http" and ( path == "/mcp" or path.startswith("/.well-known/oauth-protected-resource") ): await self.runtime.asgi(scope, receive, send) else: await self.app(scope, receive, send)