MCP TypeScript SDK (V2)
    Preparing search index...
    • Express middleware that requires a valid Bearer token in the Authorization header.

      The token is validated via the supplied OAuthTokenVerifier and the resulting AuthInfo (from @modelcontextprotocol/server) is attached to req.auth. The MCP Streamable HTTP transport reads req.auth and surfaces it to handlers as ctx.http.authInfo.

      On failure the middleware sends a JSON OAuth error body and a WWW-Authenticate: Bearer … challenge that includes the configured resource_metadata URL so clients can discover the Authorization Server.

      Parameters

      Returns RequestHandler