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.
The basic MCP pattern is JSON-RPC's: the client sends a request with an id and the server replies with result or error carrying the same id. What MCP adds is how this maps onto each transport and what may travel between the request and the response.
sequenceDiagram
participant C as Client
participant S as Server
C->>S: request (id: 1, _meta)
S-->>C: notifications/progress (optional, if there was a progressToken)
S-->>C: notifications/message (optional, if there was a logLevel)
S-->>C: response (id: 1)
Intermediate notifications MUST relate to the request in progress. In 2026-07-28 the server never interleaves requests of its own.
| Aspect | stdio | Streamable HTTP |
|---|---|---|
| Request | One JSON line on stdin. | One POST with the JSON as the body and Mcp-* headers. |
| Response | One JSON line on stdout, correlated by id. |
application/json (a single object) or text/event-stream (notifications + final response). The client MUST support both. |
| Related notifications | Lines interleaved on stdout. | SSE events on the same response stream. |
| End | Implicit on receiving the response. | The final response SHOULD close the stream. |
| Cancellation | notifications/cancelled. |
Close the response stream. |
Every request sent SHOULD have a timeout configurable per request. On expiry, the sender SHOULD cancel and stop waiting. The clock MAY be reset when progress is received, but always with an absolute maximum.
The "response" may be a complete, an input_required (MRTR, lesson 5.2) or, with the Tasks extension, a task. The client decides by resultType before interpreting anything else.
A client MAY have several requests in flight with distinct ids. Over HTTP each one has its own POST and its own stream; over stdio they share the channel and the client demultiplexes by id (responses), progressToken (progress) and subscriptionId (subscriptions).
1. Which content types can an HTTP server return for a request?
The server chooses per request; the client must handle both.
2. Can the intermediate notifications in a response stream refer to a different request?
In 2026-07-28 the response stream carries only notifications for that request.