| Classes |
| BearerAuthenticationMiddleware |
Makes the MCP endpoint an OAuth 2.1 resource server: it requires a bearer token, binds that token's audience
to this server, and enforces the scopes the endpoint calls for. A request presenting no bearer credential is answered 401 with a WWW-Authenticate challenge naming the
Protected Resource Metadata document, one presenting a bearer credential that cannot be read is answered
400 invalid_request, and a token that is valid but too narrow is answered 403 insufficient_scope. The
validated token reaches request handlers on ServerContext::$receiveContext->authInfo.
|
| CorsMiddleware |
Grants browser clients cross-origin access to the MCP endpoint. The middleware is additive. An allowed Origin is reflected into Access-Control-Allow-Origin, a preflight
OPTIONS is answered with 204 plus the negotiated Access-Control-* headers, and every other request is
forwarded and its response decorated. A disallowed or absent Origin receives no grant, so rejection stays
with the DNS-rebinding gate. Every response carries the Vary keys it turns on, grant or not, so a shared
cache cannot serve one origin's answer to another.
|
| DnsRebindingProtectionMiddleware |
Guards the MCP endpoint against DNS rebinding by rejecting requests from an unrecognised Origin or Host. A present-but-unlisted Origin is answered with an id-less JSON-RPC error on HTTP 403. A request without an
Origin header (non-browser clients) passes through, since only browsers send it. Host validation is a
beyond-spec, opt-in dimension: an empty allow-list disables it, otherwise the Host header must be present
and listed. Matching is case-insensitive, since RFC 9110 makes the scheme and host of a URI so.
|
| ParameterHeaderValidationMiddleware |
Rejects a tools/call whose Mcp-Param-{Name} headers disagree with the arguments in its body. The spec requires any server that processes the body to validate the mirrored headers against it, so an
intermediary routing on a header value cannot disagree with what the server executes. Bindings are read
from the tool inputSchema declarations once and cached, and the cache is dropped whenever a
ListChangeSourceInterface store reports that its listing changed.
|
| RequestBodySizeLimitMiddleware |
Rejects a request whose body exceeds a configured byte cap before it reaches the transport. An oversized body is answered with an id-less JSON-RPC error on HTTP 413, sparing the transport the cost of
stringifying and parsing it. The cap is measured against the buffered body size. A body whose size cannot be
determined passes through, leaving a streaming cap to the HTTP server.
|
|