zuplo 7.14.6 → 7.15.0

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.
@@ -0,0 +1,578 @@
1
+ ---
2
+ title: MCP Server Flat Tool Input
3
+ sidebar_label: Flat Tool Input
4
+ description:
5
+ Reference for flat MCP tool input in Zuplo. See how arguments map to path,
6
+ query, header, and body, and which OpenAPI schemas keep tool arguments nested.
7
+ applies_to:
8
+ product: gateway
9
+ hosting: all
10
+ ---
11
+
12
+ The MCP Server handler turns each OpenAPI operation into an MCP tool. The
13
+ `toolInputStyle` option decides the shape of that tool's `inputSchema`:
14
+
15
+ - `nested` (default) - Each input channel the operation declares is its own
16
+ object argument: `pathParams`, `queryParams`, `body`, and `headers`.
17
+ - `flat` - Path, query, and header parameters and the request body's properties
18
+ all become top-level arguments of one object.
19
+
20
+ This page is the full reference for `flat`: how arguments map back to the HTTP
21
+ request, which schemas flatten, and what happens when one can't. For a shorter
22
+ introduction, see [Tool input schemas](./tools.mdx#tool-input-schemas).
23
+
24
+ ## Why flat input exists
25
+
26
+ With `nested`, every argument sits one level deep. A search tool takes
27
+ `{"body": {"query": "hoodie"}}`, not `{"query": "hoodie"}`. Some models,
28
+ particularly less capable ones, send the body's fields at the top level anyway.
29
+ Against a nested schema that first call fails validation, and the model retries
30
+ with the wrapper. That costs:
31
+
32
+ - An extra round trip on every call.
33
+ - Validation errors such as `body.sortField` for a field the model never nested.
34
+ - A tool whose arguments are all optional still can't be called with `{}`,
35
+ because the `body` object itself is required.
36
+
37
+ Flat input removes the wrapper so the advertised schema matches what those
38
+ models send. MCP itself doesn't require either shape: it only requires
39
+ `inputSchema` to be a JSON Schema object, and capable models generally follow
40
+ whatever schema a tool advertises. Flat input is a Zuplo convenience, so it's
41
+ opt-in.
42
+
43
+ ## Turn on flat input
44
+
45
+ Set `toolInputStyle` in the MCP Server handler options to set the style for
46
+ every tool on the server:
47
+
48
+ ```json
49
+ "handler": {
50
+ "export": "mcpServerHandler",
51
+ "module": "$import(@zuplo/runtime)",
52
+ "options": {
53
+ "name": "example-mcp-server",
54
+ "version": "1.0.0",
55
+ "toolInputStyle": "flat",
56
+ "operations": [
57
+ { "file": "./config/routes.oas.json", "id": "searchProducts" }
58
+ ]
59
+ }
60
+ }
61
+ ```
62
+
63
+ To give one tool a different style, set `toolInputStyle` in its route's
64
+ `x-zuplo-route.mcp` block. The override works in either direction:
65
+
66
+ ```json
67
+ "x-zuplo-route": {
68
+ "mcp": { "type": "tool", "toolInputStyle": "flat" }
69
+ }
70
+ ```
71
+
72
+ If the MCP server uses the deprecated `files` option instead of `operations`,
73
+ set `toolInputStyle` in the operation's `x-zuplo-mcp-tool` extension.
74
+
75
+ Each tool uses the first value it finds:
76
+
77
+ 1. The tool's own `toolInputStyle`.
78
+ 2. The handler's `toolInputStyle` option.
79
+ 3. `nested`.
80
+
81
+ The default is `nested` on every compatibility date. A published `inputSchema`
82
+ is a contract with the clients built against it, so Zuplo doesn't change it
83
+ unless you ask.
84
+
85
+ | Where the value is set | Value other than `"flat"` or `"nested"` |
86
+ | -------------------------------------- | -------------------------------------------------------------------------- |
87
+ | Handler `toolInputStyle` option | Treated as `nested`, with no error. Check the spelling. |
88
+ | `x-zuplo-route.mcp.toolInputStyle` | The build fails route schema validation. |
89
+ | `x-zuplo-mcp-tool.toolInputStyle` | The MCP server throws an error that names the operation when it registers. |
90
+ | Any of the above, as `$env(...)` value | Depends on the compatibility date. See [below](#environment-variables). |
91
+
92
+ ### Environment variables
93
+
94
+ From compatibility date
95
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06), the
96
+ build generates each tool's schemas from `toolInputStyle`, so the value must be
97
+ a literal `"flat"` or `"nested"`. A value that contains `$env(...)`, on the
98
+ handler or on a tool, fails the build:
99
+
100
+ ```text
101
+ MCP handler option "toolInputStyle" on route "/mcp" can't use $env(...): the build uses it to generate tool schemas. Use "flat" or "nested".
102
+ ```
103
+
104
+ On earlier compatibility dates, the build doesn't read `toolInputStyle`, and the
105
+ MCP server resolves `$env(...)` when it starts.
106
+
107
+ ## How arguments map to the request
108
+
109
+ This page uses one example operation, `POST /stores/{storeId}/search`. It
110
+ declares a path parameter, a query parameter, a required header, and a JSON
111
+ body:
112
+
113
+ ```json
114
+ {
115
+ "/stores/{storeId}/search": {
116
+ "post": {
117
+ "operationId": "searchProducts",
118
+ "parameters": [
119
+ {
120
+ "name": "storeId",
121
+ "in": "path",
122
+ "required": true,
123
+ "schema": { "type": "string" }
124
+ },
125
+ { "name": "limit", "in": "query", "schema": { "type": "integer" } },
126
+ {
127
+ "name": "x-tenant",
128
+ "in": "header",
129
+ "required": true,
130
+ "schema": { "type": "string" }
131
+ }
132
+ ],
133
+ "requestBody": {
134
+ "content": {
135
+ "application/json": {
136
+ "schema": {
137
+ "type": "object",
138
+ "required": ["query"],
139
+ "properties": {
140
+ "query": { "type": "string" },
141
+ "sort": { "enum": ["price", "name"] }
142
+ },
143
+ "additionalProperties": false
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ The nested tool advertises one object per channel, and every channel is
154
+ required:
155
+
156
+ ```json title="Nested inputSchema"
157
+ {
158
+ "type": "object",
159
+ "properties": {
160
+ "pathParams": {
161
+ "type": "object",
162
+ "properties": { "storeId": { "type": "string" } },
163
+ "required": ["storeId"],
164
+ "additionalProperties": false
165
+ },
166
+ "queryParams": {
167
+ "type": "object",
168
+ "properties": { "limit": { "type": "integer" } },
169
+ "required": [],
170
+ "additionalProperties": false
171
+ },
172
+ "body": {
173
+ "type": "object",
174
+ "properties": {
175
+ "query": { "type": "string" },
176
+ "sort": { "enum": ["price", "name"] }
177
+ },
178
+ "required": ["query"],
179
+ "additionalProperties": false
180
+ },
181
+ "headers": {
182
+ "type": "object",
183
+ "properties": { "x-tenant": { "type": "string" } },
184
+ "required": ["x-tenant"],
185
+ "additionalProperties": false
186
+ }
187
+ },
188
+ "required": ["pathParams", "queryParams", "body", "headers"],
189
+ "additionalProperties": false
190
+ }
191
+ ```
192
+
193
+ The flat tool advertises the same properties in one object:
194
+
195
+ ```json title="Flat inputSchema"
196
+ {
197
+ "type": "object",
198
+ "properties": {
199
+ "storeId": { "type": "string" },
200
+ "limit": { "type": "integer" },
201
+ "query": { "type": "string" },
202
+ "sort": { "enum": ["price", "name"] },
203
+ "x-tenant": { "type": "string" }
204
+ },
205
+ "required": ["storeId", "query", "x-tenant"],
206
+ "additionalProperties": false
207
+ }
208
+ ```
209
+
210
+ Both calls below send the same request to the route,
211
+ `POST /stores/s1/search?limit=10` with the header `x-tenant: acme` and the body
212
+ `{"query":"hoodie"}`:
213
+
214
+ ```json title="Flat call"
215
+ {
216
+ "storeId": "s1",
217
+ "limit": 10,
218
+ "query": "hoodie",
219
+ "x-tenant": "acme"
220
+ }
221
+ ```
222
+
223
+ ```json title="Nested call"
224
+ {
225
+ "pathParams": { "storeId": "s1" },
226
+ "queryParams": { "limit": 10 },
227
+ "body": { "query": "hoodie" },
228
+ "headers": { "x-tenant": "acme" }
229
+ }
230
+ ```
231
+
232
+ The exact bytes of an advertised schema can differ slightly from these examples,
233
+ for example a root `$schema`, depending on the
234
+ [compatibility date](../programmable-api/compatibility-dates.mdx#2026-11-06).
235
+
236
+ ### Rules of the flat schema
237
+
238
+ - **Order.** Properties appear in this order: path parameters, query parameters,
239
+ body properties, then headers.
240
+ - **Required.** `required` lists every property its own channel requires: a
241
+ required parameter, or a name in the body's `required` list. A
242
+ [wrapped body](#when-the-body-stays-under-body), before compatibility date
243
+ `2026-11-06`, is the one exception: `body` is always required. Otherwise a
244
+ tool whose inputs are all optional accepts `{}`.
245
+ - **Schemas are copied unchanged.** Each property's schema, including its
246
+ `description`, `default`, and `enum`, is copied exactly from the parameter or
247
+ body property. Root `$defs` stay at the root, so a `$ref` inside a property
248
+ still resolves.
249
+ - **Routing.** Each argument goes back to the channel that declared it: a path
250
+ parameter fills the URL path, a query parameter the query string, a header
251
+ parameter a request header, and a body property the request body.
252
+ - **Header names.** A header argument uses the header parameter's name. From
253
+ compatibility date
254
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06), header
255
+ names are lowercase, so a header declared as `X-Tenant` is the argument
256
+ `x-tenant`.
257
+ - **Output.** Only the `inputSchema` is flattened. An `outputSchema` keeps the
258
+ response schema's shape.
259
+
260
+ ### Undeclared arguments
261
+
262
+ Your request body schema decides what happens to an argument that no parameter
263
+ or body property declares:
264
+
265
+ | Body schema | Flat `inputSchema` | Undeclared argument |
266
+ | --------------------------------------------- | -------------------------------------- | ----------------------------- |
267
+ | `additionalProperties: false` | `additionalProperties: false` | Rejected as an argument error |
268
+ | `additionalProperties` omitted | No `additionalProperties` | Forwarded in the request body |
269
+ | `additionalProperties` set to a schema | The same `additionalProperties` schema | Validated, then sent in body |
270
+ | No request body, or a body that stays wrapped | `additionalProperties: false` | Rejected as an argument error |
271
+
272
+ Before compatibility date
273
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06), an open
274
+ body publishes `"additionalProperties": {}`, which also permits any extra
275
+ argument.
276
+
277
+ Set `additionalProperties: false` on a request body schema to reject fields a
278
+ model invents rather than pass them upstream.
279
+
280
+ An argument becomes a request header only when a header parameter declares that
281
+ exact name. An undeclared argument never becomes a header, even one named
282
+ `headers` or `authorization`. With an open body, it lands in the body as a field
283
+ of that name.
284
+
285
+ A header argument overrides an inbound header of the same name that the MCP
286
+ client sent to the gateway. A required header parameter is a required tool
287
+ argument, so the model must send it even when the MCP client's own request
288
+ already carries that header.
289
+
290
+ ## Nested calls still work
291
+
292
+ A flat tool also accepts the nested form, so clients written against the nested
293
+ schema keep working after you switch to `flat`. The MCP server picks how to read
294
+ the arguments from their top-level keys:
295
+
296
+ - **Only channel names** (`pathParams`, `queryParams`, `body`, `headers`) that
297
+ aren't also flat properties: read as nested first, then as flat. If both fail,
298
+ the nested errors are reported.
299
+ - **Anything else:** read as flat first. If that fails and every key is a
300
+ channel name, read as nested. If both fail, the flat errors are reported.
301
+
302
+ A call is never read as half flat and half nested. For the example operation,
303
+ `{"storeId": "s1", "body": {"query": "hoodie"}}` is read as flat and fails,
304
+ because `body` isn't a flat property and `query` is missing.
305
+
306
+ When a channel name is also a flat property, the flat reading wins. For a body
307
+ that declares its own `body` property, `{"body": {"body": {}}}` is a flat call,
308
+ and the route receives the body `{"body": {}}`.
309
+
310
+ ## Validation errors
311
+
312
+ A flat call is validated against the advertised flat schema as a whole, and
313
+ errors use flat paths. A bad `sort` value reports `sort`, not `body.sort`:
314
+
315
+ ```text
316
+ Invalid arguments for tool 'searchProducts': sort: must be equal to one of the allowed values
317
+ ```
318
+
319
+ Clients on MCP protocol version `2025-11-25` or later receive this as a tool
320
+ result with `isError: true`. Earlier versions receive a JSON-RPC `-32602` error
321
+ with the same message. Either way, the route isn't called. The wording after the
322
+ colon comes from the validator and isn't a stable contract. Before compatibility
323
+ date [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06), it
324
+ uses a different format.
325
+
326
+ ## When a tool stays nested
327
+
328
+ When two channels declare the same property name, one flat argument can't carry
329
+ both values, so the tool's input can't be flattened. Zuplo doesn't rename or
330
+ prefix properties to resolve a collision.
331
+
332
+ | Collision | Example |
333
+ | ------------------------------------------- | -------------------------------------------------------------------- |
334
+ | Query parameter and body property | Query `id` (string) and body property `id` (integer) |
335
+ | Path parameter and query parameter | Path `id` and query `id` |
336
+ | Path parameter and body property | Path `storeId` and body property `storeId` |
337
+ | Header parameter and another channel | Header `x-tenant` and body property `x-tenant` |
338
+ | A parameter named `body` and a wrapped body | Query parameter `body` and an array request body |
339
+ | A merged `allOf` property and a parameter | Path `id` and an `allOf` branch that declares `id` (from 2026-11-06) |
340
+
341
+ From compatibility date
342
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06), a
343
+ collision on a tool whose `toolInputStyle` is `flat` fails the build. The error
344
+ names the tool, the operation, the property, the two channels, and the
345
+ operation's location:
346
+
347
+ ```text
348
+ MCP tool 'searchProducts' (operation searchProducts): toolInputStyle is "flat", but its input can't be flattened: `id` is declared by both `queryParams` and `body`, so the two cannot share one flat argument. Rename one of them to flatten it. Fix the schema, or set "toolInputStyle": "nested" on this tool (x-zuplo-route.mcp, or x-zuplo-mcp-tool in a files entry) to keep its input nested (config/routes.oas.json#/paths/~1stores~1{storeId}~1search/post)
349
+ ```
350
+
351
+ To fix it, rename one of the two properties, or set `"toolInputStyle": "nested"`
352
+ on that tool in its route's `x-zuplo-route.mcp` block (or in `x-zuplo-mcp-tool`
353
+ for the deprecated `files` option). The rest of the server's tools stay flat.
354
+
355
+ On earlier compatibility dates, the whole tool keeps the nested shape, and the
356
+ MCP server logs a warning each time it registers the tool, naming the property
357
+ and the two channels. The reason is never sent to MCP clients.
358
+
359
+ ## When the body stays under `body`
360
+
361
+ Some request bodies have no property names to hoist, or constrain the object as
362
+ a whole in a way that would also count the parameters. Those bodies can't be
363
+ flattened.
364
+
365
+ From compatibility date
366
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06), such a
367
+ body on a tool whose `toolInputStyle` is `flat` fails the build. For the example
368
+ operation with an array body (`{"type": "array", "items": {"type": "string"}}`),
369
+ the error is:
370
+
371
+ ```text
372
+ MCP tool 'searchProducts' (operation searchProducts): toolInputStyle is "flat", but its request body can't be flattened and would stay under `body`: the `body` schema is not an object schema (`type` is "array"), so it has no properties to hoist. Declare the request body as an object with `properties` to have its fields become top-level tool arguments. Fix the schema, or set "toolInputStyle": "nested" on this tool (x-zuplo-route.mcp, or x-zuplo-mcp-tool in a files entry) to keep its input nested (config/routes.oas.json#/paths/~1stores~1{storeId}~1search/post)
373
+ ```
374
+
375
+ To fix it, change the body schema so it flattens, or set
376
+ `"toolInputStyle": "nested"` on that tool.
377
+
378
+ On earlier compatibility dates, the body stays under a `body` argument (a
379
+ wrapped body), and `body` is required. The parameters still flatten. With the
380
+ example parameters and the array body, the flat schema is:
381
+
382
+ ```json
383
+ {
384
+ "type": "object",
385
+ "properties": {
386
+ "storeId": { "type": "string" },
387
+ "limit": { "type": "integer" },
388
+ "body": { "type": "array", "items": { "type": "string" } },
389
+ "x-tenant": { "type": "string" }
390
+ },
391
+ "required": ["storeId", "body", "x-tenant"],
392
+ "additionalProperties": false
393
+ }
394
+ ```
395
+
396
+ A call looks like
397
+ `{"storeId": "s1", "x-tenant": "acme", "body": ["hoodie", "scarf"]}`.
398
+
399
+ A body can't be flattened when its schema matches any row of this table. Rows
400
+ marked "from 2026-11-06" apply from compatibility date
401
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06).
402
+
403
+ | Body schema | Notes |
404
+ | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
405
+ | `type` isn't exactly `"object"`: an array, a string or other primitive, or `["object", "null"]` | From 2026-11-06, a body that omits `type` also can't be flattened. |
406
+ | `properties` isn't an object | |
407
+ | `oneOf`, `anyOf`, `not`, `if`, `then`, or `else` at the root | |
408
+ | `minProperties`, `maxProperties`, `patternProperties`, `propertyNames`, or `dependentSchemas` | Each would also count or constrain the parameters at the flat root. |
409
+ | `unevaluatedProperties` | From 2026-11-06, ignored in a draft-06 or draft-07 schema, which doesn't define it. |
410
+ | `allOf` at the root | From 2026-11-06, merged when it qualifies. See [Composed bodies](#composed-bodies). |
411
+ | `dependentRequired` | From 2026-11-06, flattened when it qualifies. See [Composed bodies](#composed-bodies). |
412
+ | `const`, `enum`, `dependencies`, `$id`, `$defs`, or `definitions` at the root (from 2026-11-06) | |
413
+ | `$dynamicRef`, `$recursiveRef`, or a `$ref` with other keywords beside it, at the root (from 2026-11-06) | |
414
+ | `required` names a property that `properties` doesn't declare (from 2026-11-06) | |
415
+ | A root `$dynamicAnchor` (or 2019-09 `$recursiveAnchor: true`) that a `$dynamicRef` (or `$recursiveRef: "#"`) in the body targets (from 2026-11-06) | The recursion would require the parameters again at every nested level. |
416
+ | A media type with no `schema` | From 2026-11-06, can't be flattened. Before 2026-11-06, the tool has no `body` argument. |
417
+
418
+ Before compatibility date `2026-11-06`, the MCP server decides from the schema
419
+ after converting it internally, and that conversion doesn't keep every keyword.
420
+ A root `allOf` body always stays wrapped, and `dependentRequired` is never
421
+ copied to the flat root.
422
+
423
+ A body that is only a `$ref` to a component, such as
424
+ `{"$ref": "#/components/schemas/Order"}`, isn't wrapped. The reference is
425
+ replaced by its target first, so it flattens like any other object body.
426
+
427
+ Before compatibility date `2026-11-06`, a wrapped body is expected for these
428
+ shapes, so the MCP server logs it only at debug level, and only when the
429
+ handler's [`debugMode`](../handlers/mcp-server.mdx#configuration) is on.
430
+
431
+ ## Composed bodies
432
+
433
+ From compatibility date
434
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06), two
435
+ composed body shapes flatten instead of staying wrapped. On earlier
436
+ compatibility dates, both stay wrapped.
437
+
438
+ For either shape, the MCP server validates the flat call against the flat schema
439
+ and then validates the routed body against your original body schema. A call
440
+ succeeds only when both accept it, so the flat tool never accepts a body your
441
+ OpenAPI document rejects. An error from the second check reports nested paths,
442
+ such as `body: must have required property 'card'`.
443
+
444
+ ### Root `allOf`
445
+
446
+ A body whose root is an `allOf` merges into one object when all of these are
447
+ true:
448
+
449
+ - Every branch, after following local `$ref`s, is `type: "object"` with only
450
+ `properties`, `required`, and annotations (`title`, `description`, `examples`,
451
+ `$comment`, `deprecated`).
452
+ - No property is declared by two branches with different schemas. The same
453
+ schema in two branches is fine.
454
+ - The root has nothing beside `allOf` except `type: "object"`,
455
+ `unevaluatedProperties: false`, and annotations.
456
+
457
+ The merged `required` is the union of the branches' `required` lists.
458
+ `unevaluatedProperties: false` closes the merged object with
459
+ `additionalProperties: false`. In a draft-06 or draft-07 schema,
460
+ `unevaluatedProperties` doesn't exist, so the merged object stays open.
461
+
462
+ ```json title="Body"
463
+ {
464
+ "allOf": [
465
+ { "$ref": "#/components/schemas/Base" },
466
+ {
467
+ "type": "object",
468
+ "properties": { "note": { "type": "string" } },
469
+ "required": ["note"]
470
+ }
471
+ ],
472
+ "unevaluatedProperties": false
473
+ }
474
+ ```
475
+
476
+ With `Base` declaring a required `id`, the body flattens to:
477
+
478
+ ```json title="Flat body properties"
479
+ {
480
+ "properties": { "id": { "type": "string" }, "note": { "type": "string" } },
481
+ "required": ["id", "note"],
482
+ "additionalProperties": false
483
+ }
484
+ ```
485
+
486
+ The body can't be flattened when:
487
+
488
+ - `additionalProperties` sits beside the `allOf`. It applies only to the root's
489
+ own `properties`, so it doesn't close the merged object. Use
490
+ `unevaluatedProperties: false` to close a composed body.
491
+ - A branch carries anything else, such as `additionalProperties`,
492
+ `minProperties`, `patternProperties`, or a nested `oneOf`.
493
+ - Two branches declare the same property with different schemas.
494
+ - `unevaluatedProperties` is anything other than `false`.
495
+
496
+ After merging, the body follows the same rules as any other body: a merged
497
+ property that collides with a parameter is a
498
+ [collision](#when-a-tool-stays-nested).
499
+
500
+ ### `dependentRequired`
501
+
502
+ A body's `dependentRequired` is copied to the flat root unchanged when every
503
+ name it mentions is one of the body's own `properties`:
504
+
505
+ ```json title="Body"
506
+ {
507
+ "type": "object",
508
+ "properties": {
509
+ "card": { "type": "string" },
510
+ "billingZip": { "type": "string" }
511
+ },
512
+ "dependentRequired": { "card": ["billingZip"] }
513
+ }
514
+ ```
515
+
516
+ The flat schema carries `"dependentRequired": { "card": ["billingZip"] }`, so
517
+ `{"storeId": "s1", "card": "4242", "billingZip": "94103"}` succeeds and
518
+ `{"storeId": "s1", "card": "4242"}` is an argument error.
519
+
520
+ When `dependentRequired` names something the body doesn't declare, such as a
521
+ parameter, the body can't be flattened: at the flat root, a parameter could
522
+ satisfy the rule.
523
+
524
+ ## Content types
525
+
526
+ Flattening reads only the request body's schema, not its media type. An
527
+ `application/x-www-form-urlencoded` body with an object schema flattens the same
528
+ way as a JSON body, and a `text/plain` body with `type: "string"` can't be
529
+ flattened.
530
+
531
+ An operation with several request content types gets one tool per content type,
532
+ named `<name>_<content type>`, such as `createOrder_application_json`. Each tool
533
+ is planned on its own, so one can flatten while another can't. Before
534
+ compatibility date `2026-11-06`, the other tool keeps a wrapped body. From
535
+ `2026-11-06`, it fails the build, and `"toolInputStyle": "nested"` in the
536
+ operation's `x-zuplo-route.mcp` block applies to every tool of that operation.
537
+
538
+ The MCP server serializes the request body as JSON for every content type, and
539
+ sets the request's `content-type` header to the tool's content type.
540
+
541
+ ## Behavior by compatibility date
542
+
543
+ Compatibility date `2026-11-06` changes how the MCP Server handler builds and
544
+ validates tool schemas, and that includes flat input. The new behavior applies
545
+ to projects with a `compatibilityDate` of `2026-11-06` or later. See
546
+ [Compatibility Dates](../programmable-api/compatibility-dates.mdx#2026-11-06).
547
+ The default `toolInputStyle` is `nested` either way.
548
+
549
+ | Behavior | Before 2026-11-06 | From 2026-11-06 |
550
+ | ------------------------------------------- | ---------------------------------------- | ---------------------------------------------- |
551
+ | When the flat schema is built | When the MCP server starts | At build time |
552
+ | `$env(...)` in `toolInputStyle` | Resolved when the MCP server starts | Fails the build |
553
+ | Root `allOf` and `dependentRequired` bodies | Body wrapped | Flattened when they qualify |
554
+ | Open body | `"additionalProperties": {}` | `additionalProperties` as written, or absent |
555
+ | Header argument names | As declared | Lowercase |
556
+ | Collision or body that can't be flattened | Tool nested or body wrapped; runtime log | Fails the build |
557
+ | Argument values | Validated per channel; defaults inserted | Validated as a whole; passed through unchanged |
558
+
559
+ ## Troubleshooting
560
+
561
+ | Symptom or message | Cause | Fix |
562
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
563
+ | Warning log `MCP tool input schema left nested` with a `reason` such as `` `id` is declared by both `queryParams` and `body`, so the two cannot share one flat argument. `` | Two channels declare the same name, before compatibility date `2026-11-06`. | Rename one of them. See [When a tool stays nested](#when-a-tool-stays-nested). |
564
+ | Warning log `MCP tool input schema left nested` with `` `body` is declared as a parameter by `queryParams` and is also where this operation's request body has to go `` | A parameter named `body` and a wrapped body, before compatibility date `2026-11-06`. | Rename the `body` parameter, or make the body a plain object. |
565
+ | Warning log `MCP tool input schema left nested` with `the build resolved this tool's toolInputStyle to "nested", so it has no flat schema.` | The tool is flat at runtime, but the build read `nested`. | Set `toolInputStyle` to the literal `"flat"` in the handler options or the route's `x-zuplo-route.mcp`. |
566
+ | Debug log `MCP tool request body left nested` | The body can't flatten, before compatibility date `2026-11-06`. | Expected for that body shape. See [When the body stays under `body`](#when-the-body-stays-under-body). |
567
+ | Build error `MCP tool '<name>' (operation <id>): toolInputStyle is "flat", but its input can't be flattened: ...` | A collision, from compatibility date `2026-11-06`. | Rename one of the two properties, or set `"toolInputStyle": "nested"` on that tool. |
568
+ | Build error ``MCP tool '<name>' (operation <id>): toolInputStyle is "flat", but its request body can't be flattened and would stay under `body`: ...`` | A body that can't flatten, from compatibility date `2026-11-06`. | Change the body schema so it flattens, or set `"toolInputStyle": "nested"` on that tool. |
569
+ | Build error `MCP handler option "toolInputStyle" on route "/mcp" can't use $env(...)` | `$env(...)`, from compatibility date `2026-11-06`. | Use the literal `"flat"` or `"nested"`. |
570
+ | `MCP tool configuration error: invalid toolInputStyle "Flat" on operation "searchProducts". Use "flat" or "nested".` | A value other than `"flat"` or `"nested"` in `x-zuplo-mcp-tool`. | Use lowercase `"flat"` or `"nested"`. |
571
+ | Tools stay nested with no log | The handler option has a typo, such as `"Flat"`, which is read as `nested`. | Use lowercase `"flat"`. |
572
+ | `must NOT have additional properties (color)` on a flat call | The body sets `additionalProperties: false` and the call sent an undeclared argument. | Expected. Remove `additionalProperties: false` from the body to forward extra fields. |
573
+
574
+ Each build message ends with the location of the operation in parentheses, for
575
+ example `(config/routes.oas.json#/paths/~1things/post)`.
576
+
577
+ For general argument errors and client debugging, see
578
+ [MCP Server Troubleshooting](./troubleshooting.mdx).
@@ -154,6 +154,16 @@ For more information on the format of messages to return to the LLM,
154
154
  For more information, review
155
155
  [the `PromptMessage` type and "Data Types" described in the MCP specification](https://modelcontextprotocol.io/specification/2025-06-18/server/prompts#promptmessage).
156
156
 
157
+ From compatibility date
158
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06), the
159
+ handler checks each message before it returns a prompt. When a message's `role`
160
+ isn't `user` or `assistant`, or its `content` isn't a content block that the
161
+ client's protocol version defines, `prompts/get` returns JSON-RPC error `-32603`
162
+ naming the prompt and the first invalid message. For example, an `audio` block
163
+ needs protocol version `2025-03-26` or later. A `resource_link` block reaches a
164
+ client before `2025-06-18` as a text block instead. On an earlier compatibility
165
+ date, the handler returns the messages as your route sends them.
166
+
157
167
  ### Multiple Messages
158
168
 
159
169
  You can return multiple messages to create complex and dynamic templates:
@@ -71,7 +71,9 @@ To provide MCP specific metadata for the resource, use the `mcp` property within
71
71
  `...`. This field has no length limit.
72
72
  - `uri` (optional) - The URI identifier for the resource (for example,
73
73
  `"file:///example.txt"`, `"ui://html"`). Defaults to
74
- `"mcp://resources/{name}"`.
74
+ `"mcp://resources/{name}"`. Must be an absolute
75
+ [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) URI. See
76
+ [Resource URIs](#resource-uris).
75
77
  - `mimeType` (optional) - The MIME type of the resource content (for example,
76
78
  `"text/html"`, `"text/css"`, `"application/json"`). Falls back to the
77
79
  response's Content-Type header or `"text/plain"`.
@@ -170,6 +172,61 @@ Resources must meet the following requirements:
170
172
 
171
173
  :::
172
174
 
175
+ ### Resource URIs
176
+
177
+ MCP requires each resource URI to be an absolute
178
+ [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) URI: a scheme, a colon, and
179
+ the rest of the URI, such as `docs://guide/getting-started` or
180
+ `file:///example.txt`. A value such as `audit doc with spaces` isn't a valid
181
+ URI, and clients that validate the `uri` field reject it.
182
+
183
+ The build checks every resource URI set in `x-zuplo-route.mcp.uri`. What happens
184
+ to an invalid one depends on your compatibility date:
185
+
186
+ - **Before
187
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06)** — the
188
+ build warns, names the operation and the URI, and the handler advertises the
189
+ URI as written.
190
+ - **From `2026-11-06`** — the build fails, names the operation, its file, and
191
+ the URI, and the project doesn't deploy.
192
+
193
+ The default URI, `mcp://resources/{name}`, is always valid. See
194
+ [Compatibility dates](../programmable-api/compatibility-dates.mdx#2026-11-06).
195
+
196
+ ## Errors When Reading a Resource
197
+
198
+ `resources/read` of a URI that no configured resource uses returns JSON-RPC
199
+ error `-32002` (`Resource not found`), with the requested URI in `data.uri`. On
200
+ MCP protocol [`2026-07-28`](../handlers/mcp-server.mdx#mcp-protocol-2026-07-28),
201
+ the error is `-32602` (`Resource not found: <uri>`), still with `data.uri`.
202
+
203
+ When the resource's route returns an error status, for example a `403` from an
204
+ API key policy on the route, the result depends on your compatibility date:
205
+
206
+ - **Before
207
+ [`2026-11-06`](../programmable-api/compatibility-dates.mdx#2026-11-06)** — the
208
+ route's response body becomes the resource's contents whatever the status, so
209
+ the client receives the `403` error body as a successful read.
210
+ - **From `2026-11-06`** — any status outside `200`-`299`, redirects included,
211
+ returns JSON-RPC error `-32603`. The message names the resource, its URI, and
212
+ the status, and `data` holds the URI and the status so a client can branch on
213
+ them. The route's body isn't read or sent.
214
+
215
+ ```json
216
+ {
217
+ "jsonrpc": "2.0",
218
+ "id": "0",
219
+ "error": {
220
+ "code": -32603,
221
+ "message": "Resource 'private-doc' (docs://private) could not be read: its route answered 403",
222
+ "data": { "uri": "docs://private", "status": 403 }
223
+ }
224
+ }
225
+ ```
226
+
227
+ From compatibility date `2026-11-06`, return a `2xx` status from a resource
228
+ route for every response that a client should receive as content.
229
+
173
230
  ## Testing MCP Resources
174
231
 
175
232
  ### List Available Resources