part…
Building governance for MCP?
The gateway applies what the guide teaches: policies on discovery, invocation and authorisation.
The gateway applies what the guide teaches: policies on discovery, invocation and authorisation.
MCP's Streamable HTTP transport is built from standard HTTP and SSE pieces. An HTTP gateway has to know them precisely, because the spec imposes rules on header names, permitted values, status codes and stream behaviour.
field-name): tokens (tchar), case-insensitive. Mcp-Method and mcp-method are the same header; MCP requires case-insensitive comparison of names and case-sensitive comparison of values.=?base64?…?= encoding that MCP uses when a value does not fit that alphabet comes from.Accept, Content-Type, Origin, Authorization, WWW-Authenticate, plus its own MCP-Protocol-Version, Mcp-Method, Mcp-Name, Mcp-Param-*, and in legacy Mcp-Session-Id, Last-Event-ID.200 (JSON or SSE response), 202 Accepted with no body (notification accepted), 400 (malformed request, unsupported version, mismatched headers, missing capability), 401 (no token or invalid token), 403 (invalid Origin; insufficient scope), 404 (unknown method in modern; expired session in legacy), 405 (GET/DELETE not supported).Mcp-Param-* included).WWW-Authenticate (RFC 6750 and 9728)HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource", scope="files:read"
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope", scope="files:write", resource_metadata="…", error_description="…"
The client MUST know how to parse this header (comma-separated key="value" parameters).
A text/event-stream stream is UTF-8 text in blocks separated by a blank line:
: comment (keep-alive), ignored
event: message
id: 42
retry: 3000
data: {"jsonrpc":"2.0","method":"notifications/progress","params":{...}}
data: {"jsonrpc":"2.0","id":1,"result":{...}}
data: may be repeated over several lines (they are concatenated with \n).id: sets the Last-Event-ID that the browser would resend on reconnect. MCP 2026-07-28 does not support resumability: modern servers do not offer it and clients must not send Last-Event-ID. In legacy (2025-03-26 to 2025-11-25) it did exist.retry: suggests milliseconds before reconnecting. In legacy, servers could close the connection and request polling this way (SEP-1699).: are comments: the modern spec encourages sending them as keep-alives on long streams (subscriptions/listen); the client must ignore them.X-Accel-Buffering: no disables buffering in nginx and similar; without it, events may arrive bunched together and late.Differences between a response stream and a subscription stream in MCP: the former ends when the JSON-RPC response arrives (SHOULD close); the latter stays open until one party closes it.
OriginA malicious website can make evil.example resolve first to its own IP and then to 127.0.0.1, so that the user's browser sends requests to a local MCP server believing they are same-origin. Defences the spec requires: validate Origin (403 if invalid), bind only to 127.0.0.1 locally, and authenticate.
tchar and values containing CR/LF (header injection).X-Accel-Buffering: no and disable compression on SSE streams that pass through your proxies.1. Are HTTP header names case-sensitive?
RFC 9110: names are case-insensitive; MCP requires comparing values (e.g. method names) case-sensitively.
2. Which HTTP status does an MCP server return when accepting a notification?
The spec requires 202 Accepted with no body.
3. What does an SSE client do with a line that begins with a colon?
Per the SSE specification, comment lines carry no data.