zuplo 7.14.8 → 7.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,3 +34,99 @@ to existing projects being upgraded to use the MCP Gateway.
34
34
 
35
35
  For background on Zuplo's compatibility-date system in general, see
36
36
  [Compatibility dates](../../programmable-api/compatibility-dates.mdx).
37
+
38
+ ## MCP protocol `2026-07-28`
39
+
40
+ Set `compatibilityDate` to `2026-11-06` or later to turn on support for MCP
41
+ protocol revision `2026-07-28`:
42
+
43
+ ```jsonc
44
+ // zuplo.jsonc
45
+ {
46
+ "version": 1,
47
+ "compatibilityDate": "2026-11-06",
48
+ }
49
+ ```
50
+
51
+ With this date, the MCP Gateway handles requests that name `2026-07-28` in the
52
+ `MCP-Protocol-Version` header as that revision requires:
53
+
54
+ - Upstream readiness checks fall back to `server/discover` when an upstream
55
+ refuses `initialize`.
56
+ - The gateway answers `server/discover` itself for a caller that hasn't
57
+ connected the upstream yet, and adds the configured server icons to its reply.
58
+ The reply lists the protocol versions the upstream serves once the gateway has
59
+ seen them, and `2026-07-28` plus `2025-11-25` and earlier until then.
60
+ - A caller that hasn't connected the upstream gets an `input_required` result
61
+ with a connect link for `tools/call`, `prompts/get`, and `resources/read` (or
62
+ a `-32021` error when the client doesn't support URL elicitation), instead of
63
+ the `-32042` error that `2026-07-28` clients can't act on. The list methods
64
+ return an empty list, the methods `2026-07-28` removed return HTTP `404` with
65
+ `-32601`, and other requests return `-32603` with the connect link in
66
+ `data.connectRequired`.
67
+ - Before the gateway answers a request itself, it refuses one that a
68
+ `2026-07-28` server refuses, such as a request without a required
69
+ `MCP-Protocol-Version`, `Mcp-Method`, or `Mcp-Name` header (`-32020`).
70
+ - On `subscriptions/listen`, the request timeout limits only the wait for
71
+ response headers, so the stream can stay open. A client disconnect cancels the
72
+ upstream request.
73
+
74
+ Requests on `2025-11-25` and earlier also get the changes in
75
+ [Gateway answers follow the MCP specification](#gateway-answers-follow-the-mcp-specification),
76
+ and these project-wide changes:
77
+
78
+ - The gateway's OAuth authorization responses include the RFC 9207 `iss`
79
+ parameter, and its authorization server metadata advertises
80
+ `authorization_response_iss_parameter_supported`.
81
+ - The configured server icons are also added to an `initialize` reply that the
82
+ upstream sends as an event stream.
83
+ - On Managed Edge and in local development, `request.signal` aborts when the
84
+ client disconnects. This applies to all code in the project, not only the MCP
85
+ Gateway.
86
+
87
+ On an earlier compatibility date, the MCP Gateway relays `2026-07-28` traffic
88
+ without handling it as that revision.
89
+
90
+ The same date also turns on `2026-07-28` support in the
91
+ [MCP Server handler](../../handlers/mcp-server.mdx#mcp-protocol-2026-07-28),
92
+ along with other handler changes. See
93
+ [2026-11-06](../../programmable-api/compatibility-dates.mdx#2026-11-06) for
94
+ every change it includes.
95
+
96
+ ## Gateway answers follow the MCP specification
97
+
98
+ From compatibility date `2026-11-06`, the answers the MCP Gateway builds itself
99
+ follow the MCP specification in several error and edge cases. Most of them
100
+ affect a caller that hasn't connected the upstream yet, on MCP protocol
101
+ `2025-11-25` and earlier:
102
+
103
+ | Request from a caller that hasn't connected the upstream | Before `2026-11-06` | From `2026-11-06` |
104
+ | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -------------------------------------------------------- |
105
+ | `initialize` on `2025-11-25` that declares `capabilities.elicitation.url` | `-32042` URL-elicitation error | `-32042` URL-elicitation error |
106
+ | Any other request, such as `tools/call` | `-32042`, or `-32600` when only an administrator can connect the upstream | `-32603` with the connect link in `data.connectRequired` |
107
+ | `ping` | `-32042` | An empty result |
108
+ | Notification or JSON-RPC response | `-32042` error without an `id` | HTTP `202` with no body |
109
+ | Empty body, or a body that isn't JSON | `-32042` | HTTP `400` with `-32700` |
110
+ | Message that isn't valid JSON-RPC | `-32042` | HTTP `400` with `-32600` |
111
+ | `MCP-Protocol-Version` that the route doesn't serve | `-32042` | HTTP `400` with `-32000` |
112
+ | JSON-RPC batch on `2025-06-18` or later | `-32042` | HTTP `400` with `-32600` |
113
+ | JSON-RPC batch on `2025-03-26` or without a version header | One `-32042` error | One answer for each message |
114
+ | `GET` or `DELETE` | HTTP `200` with a `-32042` error | HTTP `405` with `Allow: POST` |
115
+
116
+ A client that relied on `-32042` for a `tools/call` reads the connect link from
117
+ `data.connectRequired.authUrl` instead.
118
+
119
+ On a route with the `mcp-token-exchange-inbound` policy, the date also changes
120
+ what the client gets when the upstream rejects the credential the gateway sent.
121
+ When the upstream still answers `401` after the gateway refreshed its
122
+ credential, or answers `403` with a `WWW-Authenticate` challenge, the gateway
123
+ answers each request with JSON-RPC error `-32603` and the message
124
+ `The upstream MCP server rejected the gateway's credential.`, with the
125
+ upstream's status in `data.upstreamStatus`. Before `2026-11-06`, the client gets
126
+ the upstream's response, including its `WWW-Authenticate` challenge, and reads
127
+ the `401` as its own gateway token failing. A route without the policy relays
128
+ the upstream's response on every date.
129
+
130
+ On a `2026-07-28` request, the methods that `2026-07-28` removed, such as `ping`
131
+ and `logging/setLevel`, get HTTP `404` with `-32601` from the gateway instead of
132
+ a connect-required answer.
@@ -112,6 +112,28 @@ When set, the upstream fetch uses mutual TLS with the specified client
112
112
  certificate. Most MCP upstreams don't require mTLS; leave this unset unless you
113
113
  specifically need it.
114
114
 
115
+ ### `telemetry.captureToolCallContent` (optional)
116
+
117
+ Type: `boolean`. Default: `false`.
118
+
119
+ When `true`, the OpenTelemetry spans of each forwarded `tools/call` record the
120
+ arguments the client sent as `gen_ai.tool.call.arguments` and, when the upstream
121
+ returns a result without `isError: true`, that result as
122
+ `gen_ai.tool.call.result`. Both the gateway's `SERVER` and `CLIENT` spans carry
123
+ them, as JSON strings capped at 8,192 characters. Only the boolean `true` turns
124
+ capture on.
125
+
126
+ ```jsonc
127
+ {
128
+ "rewritePattern": "https://mcp.linear.app/mcp",
129
+ "telemetry": { "captureToolCallContent": true },
130
+ }
131
+ ```
132
+
133
+ Tool arguments and results often contain personal or otherwise sensitive data,
134
+ so turn this on only when your trace destination is allowed to store it. See
135
+ [Capture tool call content](../../articles/opentelemetry.mdx#capture-tool-call-content).
136
+
115
137
  ## Behavior
116
138
 
117
139
  ### GET returns 405
@@ -162,6 +162,24 @@ session affinity — any node can serve any request. Stateful MCP features
162
162
  (long-running subscriptions, server-initiated sampling) aren't supported through
163
163
  the gateway today.
164
164
 
165
+ ### Streamed responses
166
+
167
+ An upstream can answer a POST with a single JSON body or with an event stream
168
+ (`text/event-stream`). The gateway relays an event stream to the client as the
169
+ upstream sends it, without buffering it to the end, so progress notifications
170
+ and partial results reach the client right away.
171
+
172
+ If the upstream's event stream ends or fails before it answers a request, the
173
+ gateway sends a JSON-RPC `-32603` error for each unanswered request, so the
174
+ client isn't left waiting. The error message says whether the gateway's request
175
+ timeout ended the stream or the upstream did.
176
+
177
+ For a request on MCP protocol `2026-07-28`, with
178
+ [`2026-07-28` support](./reference.mdx#mcp-protocol-2026-07-28) turned on, a
179
+ client that disconnects or closes the response stream cancels the upstream
180
+ request. On `2025-11-25` and earlier, MCP doesn't treat a disconnect as a
181
+ cancellation, so a request the gateway has already sent upstream keeps running.
182
+
165
183
  ## Configuration model
166
184
 
167
185
  The MCP Gateway is configured the same way as the rest of a Zuplo project: an
@@ -245,8 +263,9 @@ to the upstream URL, and emits capability analytics events.
245
263
 
246
264
  A few capabilities are intentionally out of scope, at least today:
247
265
 
248
- - **No stateful sessions.** The gateway doesn't open SSE streams, doesn't track
249
- `MCP-Session-Id`, and doesn't proxy server-initiated requests.
266
+ - **No stateful sessions.** The gateway doesn't open server-initiated SSE
267
+ streams, doesn't track `MCP-Session-Id`, and doesn't proxy server-initiated
268
+ requests.
250
269
  - **No `tools/list` caching.** Every request goes upstream. If an upstream is
251
270
  slow to list capabilities, callers feel it.
252
271
  - **No prompt-injection or PII scanning at the policy level.** These belong in a
@@ -66,7 +66,7 @@ request:
66
66
  - `upstreamServerId` — the upstream id from the token exchange policy, populated
67
67
  once the upstream is resolved.
68
68
  - `subjectId` — the authenticated user's stable subject id, populated once the
69
- bearer token is validated.
69
+ token exchange policy resolves the user.
70
70
 
71
71
  These fields make it trivial to filter a log provider by route, upstream, or
72
72
  user without scanning message bodies. The same three identifiers also appear on
@@ -141,6 +141,30 @@ logs in OTLP format. Traces include spans for the request, every inbound policy
141
141
  (`mcp-*-inbound`), the handler, and the upstream fetch; logs export the same
142
142
  structured entries described above with their `event` field preserved.
143
143
 
144
+ For every MCP message it proxies, the gateway also records two spans that follow
145
+ the OpenTelemetry semantic conventions for MCP:
146
+
147
+ - A `SERVER` span for the message as the gateway received it from the MCP
148
+ client, for example `tools/call`, with attributes such as `mcp.method.name`,
149
+ `gen_ai.tool.name`, `mcp.session.id`, `mcp.protocol.version`, and the client's
150
+ IP address as `client.address`.
151
+ - A `CLIENT` span, its child, for the message as the gateway forwarded it to the
152
+ upstream MCP server, with the upstream's `server.address` and `server.port`.
153
+ The upstream fetch nests under it.
154
+
155
+ Failed operations carry an `error.type`, such as `tool_error`, a JSON-RPC error
156
+ code, an HTTP status code, or `cancelled`. The gateway also adds the `CLIENT`
157
+ span's trace context to the forwarded message's `params._meta`, so an upstream
158
+ server that reads it continues the same trace. See
159
+ [MCP tracing](../../articles/opentelemetry.mdx#mcp-tracing) for the full span
160
+ and attribute reference and an example trace.
161
+
162
+ To also record tool call arguments and results on both spans, set
163
+ `telemetry.captureToolCallContent` to `true` in the route's
164
+ [`McpProxyHandler` options](../code-config/mcp-proxy-handler.mdx). It's off by
165
+ default. See
166
+ [Capture tool call content](../../articles/opentelemetry.mdx#capture-tool-call-content).
167
+
144
168
  Registering both plugins is a small addition to `modules/zuplo.runtime.ts`:
145
169
 
146
170
  ```ts title="modules/zuplo.runtime.ts"
@@ -116,11 +116,11 @@ DCR requests that include any other scope value are rejected with
116
116
 
117
117
  ### Required on requests to MCP routes
118
118
 
119
- | Header | Required | Notes |
120
- | --------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------- |
121
- | `Authorization: Bearer <token>` | Yes (after initial 401) | Opaque access token issued by `/__zuplo/oauth/token`. Tokens in query strings are rejected. |
122
- | `Accept: application/json, text/event-stream` | Yes | Per the Streamable HTTP transport spec. The gateway forwards the body as-is. |
123
- | `MCP-Protocol-Version: 2025-11-25` | Yes after `initialize` | Per the MCP spec. The gateway tracks the current MCP protocol revision. |
119
+ | Header | Required | Notes |
120
+ | --------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
121
+ | `Authorization: Bearer <token>` | Yes (after initial 401) | Opaque access token issued by `/__zuplo/oauth/token`. Tokens in query strings are rejected. |
122
+ | `Accept: application/json, text/event-stream` | Yes | Per the Streamable HTTP transport spec. The gateway forwards the body as-is. |
123
+ | `MCP-Protocol-Version` | Yes after `initialize` | The version the client negotiated, for example `2025-11-25`. See [Supported MCP protocol versions](#supported-mcp-protocol-versions). |
124
124
 
125
125
  ### Honored when present
126
126
 
@@ -138,6 +138,87 @@ or CDN propagates one of those headers correctly.
138
138
  Inbound auth headers don't leak to the upstream — the gateway sets its own
139
139
  upstream `Authorization` header.
140
140
 
141
+ ## Supported MCP protocol versions
142
+
143
+ The gateway implements MCP protocol revision `2025-11-25`. It advertises that
144
+ version as `mcp_protocol_version` in Protected Resource Metadata and uses it for
145
+ the readiness check it sends to each upstream.
146
+
147
+ The gateway doesn't pick the protocol version for a session. The client and the
148
+ upstream MCP server negotiate it in `initialize`, and the gateway relays
149
+ requests on any earlier revision the two agree on, such as `2025-06-18` or
150
+ `2025-03-26`. Send the negotiated version in the `MCP-Protocol-Version` header
151
+ on every request after `initialize`.
152
+
153
+ ### MCP protocol `2026-07-28`
154
+
155
+ Support for revision `2026-07-28` starts with compatibility date
156
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06). A
157
+ request counts as a `2026-07-28` request when its `MCP-Protocol-Version` header
158
+ or its `params._meta` envelope names `2026-07-28` or a later revision.
159
+ `2026-07-28` has no JSON-RPC batches.
160
+
161
+ From compatibility date `2026-11-06`, the gateway handles `2026-07-28` requests
162
+ as that revision requires:
163
+
164
+ - `2026-07-28` removes the `initialize` handshake, and clients call
165
+ `server/discover` instead. The gateway answers `server/discover` itself for a
166
+ caller that hasn't connected the upstream yet, and forwards it once the caller
167
+ has. Its own reply lists the protocol versions the upstream serves, once the
168
+ gateway has seen the upstream's list, and `2026-07-28` plus `2025-11-25` and
169
+ earlier until then.
170
+ - The gateway already adds the configured server icons (`serverInfo.icons`) to a
171
+ JSON `initialize` reply that has none. From compatibility date `2026-11-06`,
172
+ it also adds them to `server/discover` replies and to replies the upstream
173
+ sends as an event stream.
174
+ - Upstream readiness checks fall back to `server/discover` when an upstream
175
+ refuses `initialize`.
176
+ - For a caller that hasn't connected the upstream, the gateway answers these
177
+ requests itself:
178
+ - `tools/call`, `prompts/get`, and `resources/read` get an `input_required`
179
+ result with a connect link, or a `-32021` error when the client doesn't
180
+ support URL elicitation.
181
+ - `tools/list`, `prompts/list`, `resources/list`, and
182
+ `resources/templates/list` get an empty list with `ttlMs: 0` and
183
+ `cacheScope: "private"`, so the client lists again after it connects.
184
+ - The methods `2026-07-28` removed, such as `ping` and `logging/setLevel`, get
185
+ HTTP `404` with `-32601`.
186
+ - A notification gets HTTP `202` with no body. Any other request gets JSON-RPC
187
+ error `-32603` with the connect link in `data.connectRequired`.
188
+ - Before it answers, the gateway checks the request as a `2026-07-28` server
189
+ does. A missing or malformed `_meta` envelope gets HTTP `400` with `-32602`,
190
+ a missing `MCP-Protocol-Version`, `Mcp-Method`, or `Mcp-Name` header, or one
191
+ that disagrees with the body, gets `-32020`, and an unsupported revision
192
+ gets `-32022`. A JSON-RPC batch gets `-32600`.
193
+ - A client that closes the response stream of a `2026-07-28` request cancels the
194
+ upstream request. On `subscriptions/listen`, the request timeout limits only
195
+ the wait for response headers, so the stream can stay open.
196
+ - The gateway's OAuth authorization responses include the RFC 9207 `iss`
197
+ parameter.
198
+
199
+ On earlier compatibility dates, the gateway relays `2026-07-28` traffic without
200
+ handling it as that revision. An upstream that answers only `server/discover` is
201
+ reported as unavailable, and a caller that hasn't connected the upstream gets
202
+ the `-32042` URL-elicitation error, which `2026-07-28` clients can't act on.
203
+
204
+ From compatibility date `2026-11-06`, requests on `2025-11-25` and earlier also
205
+ see the project-wide changes above (the readiness fallback, the `iss` parameter,
206
+ and icons on event-stream `initialize` replies) and the changes in
207
+ [Gateway answers follow the MCP specification](./code-config/compatibility-dates.mdx#gateway-answers-follow-the-mcp-specification).
208
+ See [MCP Gateway compatibility dates](./code-config/compatibility-dates.mdx) for
209
+ the full list of changes and
210
+ [Compatibility dates](../programmable-api/compatibility-dates.mdx#2026-11-06)
211
+ for the other changes the same date makes.
212
+
213
+ :::note
214
+
215
+ The [MCP Server handler](../handlers/mcp-server.mdx#mcp-protocol-2026-07-28)
216
+ also serves `2026-07-28` from compatibility date `2026-11-06`. On an earlier
217
+ compatibility date, it serves `2024-10-07` through `2025-11-25` and answers any
218
+ other `MCP-Protocol-Version` with HTTP `400`.
219
+
220
+ :::
221
+
141
222
  ## Compatibility date
142
223
 
143
224
  MCP Gateway features require `compatibilityDate >= 2026-03-01` in `zuplo.jsonc`:
@@ -70,7 +70,11 @@ client to re-request.
70
70
  **Symptom.** The first tool call after authentication returns a JSON-RPC error
71
71
  with `code: -32042` and a payload containing `"state": "authenticating"` and an
72
72
  `authUrl`. The MCP client either opens a browser tab (modern clients) or
73
- surfaces the URL for the user to copy (older clients).
73
+ surfaces the URL for the user to copy (older clients). From compatibility date
74
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06), the
75
+ error code is `-32603`, with the same `data.connectRequired` payload, unless the
76
+ request is an `initialize` that declares URL elicitation. See
77
+ [Connect-required states](./auth/upstream-oauth.mdx#connect-required-states).
74
78
 
75
79
  **Likely cause.** This is expected behavior. The gateway requires each user to
76
80
  complete the upstream OAuth flow once per upstream. After the first connection,