diff --git a/pkgs/mcpx/docs/schema-validation.md b/pkgs/mcpx/docs/schema-validation.md index 2e246fbdb3..20563ccf3b 100644 --- a/pkgs/mcpx/docs/schema-validation.md +++ b/pkgs/mcpx/docs/schema-validation.md @@ -44,3 +44,24 @@ is the validator the binary carries. - **Errors are flat and path-carrying.** A failed validation returns one line per problem in the form `$.count: got string, want integer`, so a caller can show a tool user exactly what to fix. + +## Output policy: `structuredContent` is warn-only + +Tool **inputs** are enforced: `internal/mcpclient` validates CallTool +arguments against the tool's `inputSchema` and rejects invalid arguments +before the transport (error -32602; design #1481, Phase 2 #1483). + +Tool **outputs** are deliberately **warn-only**. `checkToolOutput` +(`internal/mcpclient/schemacheck.go`) validates a result's +`structuredContent` against the tool's `outputSchema`, but a violation +does not change the result: it is delivered unchanged and a `Warning` +("structuredContent violates outputSchema (delivered unchanged)") is +recorded instead. + +Rationale: mcpx is a gateway for servers it does not control. Rejecting +an otherwise usable result because a third-party server's output drifts +from its declared `outputSchema` would break working integrations for a +documentation defect in someone else's schema; a warning keeps the +drift visible without making mcpx the enforcement point. Flipping +outputs to enforcing is a separate decision, not a default that may be +turned on by accident (see the design in #1481 and Phase 2 in #1483). diff --git a/pkgs/mcpx/docs/spec/conformance-matrix.md b/pkgs/mcpx/docs/spec/conformance-matrix.md index fb678193f2..c8ea59b030 100644 --- a/pkgs/mcpx/docs/spec/conformance-matrix.md +++ b/pkgs/mcpx/docs/spec/conformance-matrix.md @@ -2,7 +2,7 @@ Generated by `internal/conformance` (`MCPX_UPDATE_MATRIX=1 go test ./internal/conformance -run TestMatrix`); do not edit. -Generated from inputs `d87c25241c253b00` (sha256 of docs/spec/requirements.md, internal/conformance/overrides/*.json, internal/conformance/coverage*.go). `TestMatrix` regenerates this file and fails when it differs, so it describes the tree it is committed in. +Generated from inputs `62e6a03725241937` (sha256 of docs/spec/requirements.md, internal/conformance/overrides/*.json, internal/conformance/coverage*.go). `TestMatrix` regenerates this file and fails when it differs, so it describes the tree it is committed in. Every normative requirement of every revision (catalogue: `docs/spec/requirements.md`), for mcpx as a server and as a client. A requirement is *tested* when a named test verifies it in that revision, *n/a* when it does not bind mcpx in that role, and a *gap* when it binds mcpx and mcpx does not meet it yet, with the issue that tracks it. Run exactly the covering tests with `go run ./internal/conformance/cmd/covering`. @@ -48,25 +48,25 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | 2025-06-18 | client | other | 10 | 8 | 2 | 0 | 8 | | 2025-11-25 | server | MUST | 115 | 97 | 18 | 0 | 65 | | 2025-11-25 | server | MUST NOT | 22 | 19 | 3 | 0 | 13 | -| 2025-11-25 | server | SHOULD | 78 | 63 | 15 | 0 | 81 | +| 2025-11-25 | server | SHOULD | 78 | 64 | 14 | 0 | 81 | | 2025-11-25 | server | SHOULD NOT | 11 | 10 | 1 | 0 | 3 | | 2025-11-25 | server | MAY | 27 | 25 | 2 | 0 | 28 | | 2025-11-25 | server | other | 19 | 19 | 0 | 0 | 2 | | 2025-11-25 | client | MUST | 76 | 56 | 20 | 0 | 104 | | 2025-11-25 | client | MUST NOT | 16 | 14 | 2 | 0 | 19 | -| 2025-11-25 | client | SHOULD | 67 | 47 | 20 | 0 | 92 | +| 2025-11-25 | client | SHOULD | 67 | 48 | 19 | 0 | 92 | | 2025-11-25 | client | SHOULD NOT | 5 | 4 | 1 | 0 | 9 | | 2025-11-25 | client | MAY | 20 | 17 | 3 | 0 | 35 | | 2025-11-25 | client | other | 13 | 11 | 2 | 0 | 8 | | 2026-07-28 | server | MUST | 128 | 108 | 20 | 0 | 96 | | 2026-07-28 | server | MUST NOT | 44 | 42 | 2 | 0 | 20 | -| 2026-07-28 | server | SHOULD | 74 | 62 | 12 | 0 | 86 | +| 2026-07-28 | server | SHOULD | 75 | 64 | 11 | 0 | 85 | | 2026-07-28 | server | SHOULD NOT | 11 | 10 | 1 | 0 | 9 | | 2026-07-28 | server | MAY | 31 | 29 | 2 | 0 | 30 | | 2026-07-28 | server | other | 23 | 22 | 1 | 0 | 4 | | 2026-07-28 | client | MUST | 91 | 64 | 27 | 0 | 133 | | 2026-07-28 | client | MUST NOT | 25 | 23 | 2 | 0 | 39 | -| 2026-07-28 | client | SHOULD | 74 | 55 | 19 | 0 | 86 | +| 2026-07-28 | client | SHOULD | 75 | 57 | 18 | 0 | 85 | | 2026-07-28 | client | SHOULD NOT | 13 | 11 | 2 | 0 | 7 | | 2026-07-28 | client | MAY | 14 | 11 | 3 | 0 | 47 | | 2026-07-28 | client | other | 13 | 11 | 2 | 0 | 14 | @@ -1379,7 +1379,7 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [json-schema-may-declare-dialect](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#schema-dialect) | MAY | both | tested: `conformance.TestMessagesServer/2025-11-25/json-schema/json-schema-may-declare-dialect` | tested: `conformance.TestMessagesClient/2025-11-25/json-schema/json-schema-may-declare-dialect` | | [json-schema-support-2020-12](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements) | MUST | both | tested: `mcpclient.TestCallToolRejectsInvalidArgumentsBeforeTheTransport@all` | n/a: passes through | | [json-schema-validate-per-dialect-and-error-on-unsupported](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements) | MUST | both | tested: `mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all`
`schemaval.TestDeclaredDialectsCompile@all`
`schemaval.TestUnsupportedDialect@all` | tested: `mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all`
`schemaval.TestDeclaredDialectsCompile@all`
`schemaval.TestUnsupportedDialect@all` | -| [json-schema-document-dialects](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements) | SHOULD | both | **gap** #254: no document states which dialects mcpx supports | **gap** #254: no document states which dialects mcpx supports | +| [json-schema-document-dialects](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements) | SHOULD | both | tested: `schemaval.TestDeclaredDialectsCompile@all`
`schemaval.TestUnsupportedDialect@all` | tested: `schemaval.TestDeclaredDialectsCompile@all`
`schemaval.TestUnsupportedDialect@all` | | [json-schema-recommend-2020-12](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#schema-dialect) | RECOMMENDED | both | tested: `conformance.TestMessagesServer/2025-11-25/json-schema/json-schema-recommend-2020-12` | n/a: catalogue marks it n/a | | [json-schema-schemas-valid](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#schema-validation) | MUST | both | tested: `conformance.TestMessagesServer/2025-11-25/json-schema/json-schema-schemas-valid` | n/a: catalogue marks it n/a | | [tools-schema-default-2020-12](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | (definition) | both | tested: `conformance.TestMessagesServer/2025-11-25/json-schema/tools-schema-default-2020-12` | tested: `conformance.TestMessagesClient/2025-11-25/json-schema/tools-schema-default-2020-12` | @@ -2067,13 +2067,13 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [json-schema-may-declare-dialect](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#schema-dialect) | MAY | both | tested: `conformance.TestMessagesServer/2026-07-28/json-schema/json-schema-may-declare-dialect` | tested: `conformance.TestMessagesClient/2026-07-28/json-schema/json-schema-may-declare-dialect` | | [json-schema-support-2020-12](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements) | MUST | both | tested: `mcpclient.TestCallToolRejectsInvalidArgumentsBeforeTheTransport@all` | n/a: passes through | | [json-schema-validate-per-dialect-and-error-on-unsupported](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements) | MUST | both | tested: `mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all`
`schemaval.TestDeclaredDialectsCompile@all`
`schemaval.TestUnsupportedDialect@all` | tested: `mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all`
`schemaval.TestDeclaredDialectsCompile@all`
`schemaval.TestUnsupportedDialect@all` | -| [json-schema-document-dialects](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements) | SHOULD | both | **gap** #254: no document states which dialects mcpx supports | **gap** #254: no document states which dialects mcpx supports | +| [json-schema-document-dialects](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements) | SHOULD | both | tested: `schemaval.TestDeclaredDialectsCompile@all`
`schemaval.TestUnsupportedDialect@all` | tested: `schemaval.TestDeclaredDialectsCompile@all`
`schemaval.TestUnsupportedDialect@all` | | [json-schema-recommend-2020-12](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#schema-dialect) | RECOMMENDED | both | tested: `conformance.TestMessagesServer/2026-07-28/json-schema/json-schema-recommend-2020-12` | n/a: catalogue marks it n/a | | [json-schema-schemas-valid](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#schema-validation) | MUST | both | tested: `conformance.TestMessagesServer/2026-07-28/json-schema/json-schema-schemas-valid` | n/a: catalogue marks it n/a | | [json-schema-no-network-ref](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#ref-resolution) | MUST NOT | both | tested: `conformance.TestMessagesServer/2026-07-28/json-schema/json-schema-no-network-ref` | tested: `conformance.TestMessagesClient/2026-07-28/json-schema/json-schema-no-network-ref` | | [json-schema-remote-ref-opt-in-off-by-default](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#ref-resolution) | MAY / MUST / SHOULD | both | n/a: catalogue marks it n/a | n/a: catalogue marks it n/a | | [json-schema-reject-unresolved-ref](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#ref-resolution) | SHOULD | both | tested: `mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all`
`schemaval.TestRemoteRefMakesNoRequests@all`
`schemaval.TestUnresolvedInternalRef@all` | tested: `mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all`
`schemaval.TestRemoteRefMakesNoRequests@all`
`schemaval.TestUnresolvedInternalRef@all` | -| [json-schema-bound-composition-cost](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#composition-keyword-resource-use) | SHOULD | both | n/a: no validator | n/a: catalogue marks it n/a | +| [json-schema-bound-composition-cost](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#composition-keyword-resource-use) | SHOULD | both | tested: `schemaval.TestSchemaTooLarge@all` | tested: `schemaval.TestSchemaTooLarge@all` | | [tools-schema-default-2020-12](https://modelcontextprotocol.io/specification/2026-07-28/server/tools#tool) | (definition) | both | tested: `conformance.TestMessagesServer/2026-07-28/json-schema/tools-schema-default-2020-12` | tested: `conformance.TestMessagesClient/2026-07-28/json-schema/tools-schema-default-2020-12` | ### lifecycle diff --git a/pkgs/mcpx/docs/spec/requirements.md b/pkgs/mcpx/docs/spec/requirements.md index 1f6a15ed2b..f4f2395de0 100644 --- a/pkgs/mcpx/docs/spec/requirements.md +++ b/pkgs/mcpx/docs/spec/requirements.md @@ -131,13 +131,13 @@ Most 2025-11-25 growth is the tasks page (57 rows) and the elicitation rewrite; | json-schema-may-declare-dialect | 2025-11-25..2026-07-28 | both | MAY | json-schema | "Schemas MAY include a `$schema` field to specify a different dialect" | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#schema-dialect | yes (passes upstream `$schema` through) | yes | | | json-schema-support-2020-12 | 2025-11-25..2026-07-28 | both | MUST | json-schema | "Clients and servers **MUST** support JSON Schema 2020-12 for schemas without an explicit `$schema` field" | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements | not verified: mcpx does not appear to validate tool arguments against schemas (no validator in mcpserver) | n/a (passes through) | | | json-schema-validate-per-dialect-and-error-on-unsupported | 2025-11-25..2026-07-28 | both | MUST | json-schema | "Clients and servers **MUST** validate schemas according to their declared or default dialect. They **MUST** handle unsupported dialects gracefully by returning an appropriate error" | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements | no (no validation; a proxy forwarding opaque schemas arguably does not "handle" them) | no | Uncertain what "validate schemas" binds a pass-through proxy to | -| json-schema-document-dialects | 2025-11-25..2026-07-28 | both | SHOULD | json-schema | "Clients and servers **SHOULD** document which schema dialects they support" | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements | no | no | | +| json-schema-document-dialects | 2025-11-25..2026-07-28 | both | SHOULD | json-schema | "Clients and servers **SHOULD** document which schema dialects they support" | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#implementation-requirements | yes: documented in docs/schema-validation.md (Dialect policy table) | yes: documented in docs/schema-validation.md (Dialect policy table) | | | json-schema-recommend-2020-12 | 2025-11-25..2026-07-28 | both | RECOMMENDED | json-schema | "Implementors are RECOMMENDED to use JSON Schema 2020-12." | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#schema-dialect | yes | n/a | | | json-schema-schemas-valid | 2025-11-25..2026-07-28 | both | MUST | json-schema | "Schemas **MUST** be valid according to their declared or default dialect" | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#schema-validation | yes for own tools (compacted literal schemas, test-checked); upstream schemas passed through unchecked | n/a | | | json-schema-no-network-ref | 2026-07-28 | both | MUST NOT | json-schema | "Implementations **MUST NOT** automatically dereference `$ref` values that resolve to a network URI." | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#ref-resolution | yes (never dereferences) | yes | New in 2026 (SEP-2106) | | json-schema-remote-ref-opt-in-off-by-default | 2026-07-28 | both | MAY / MUST / SHOULD | json-schema | "Implementations **MAY** offer an opt-in mode that fetches non-local `$ref`s but it **MUST** be disabled by default and **SHOULD** enforce an allowlist of hosts" | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#ref-resolution | n/a | n/a | | | json-schema-reject-unresolved-ref | 2026-07-28 | both | SHOULD | json-schema | "Schemas that fail to validate due to an unresolved external `$ref` **SHOULD** be rejected rather than silently treated as permissive." | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#ref-resolution | no (no validation) | no | | -| json-schema-bound-composition-cost | 2026-07-28 | both | SHOULD | json-schema | "Implementations **SHOULD** apply reasonable bounds, such as a maximum schema depth, a cap on the total number of subschemas, or a per-validation time budget" | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#composition-keyword-resource-use | n/a (no validator) | n/a | | +| json-schema-bound-composition-cost | 2026-07-28 | both | SHOULD | json-schema | "Implementations **SHOULD** apply reasonable bounds, such as a maximum schema depth, a cap on the total number of subschemas, or a per-validation time budget" | https://modelcontextprotocol.io/specification/2026-07-28/basic/index#composition-keyword-resource-use | yes: schemaval bounds schema documents at 1 MiB (MaxSchemaBytes) | yes: schemaval bounds schema documents at 1 MiB (MaxSchemaBytes) | | | versioning-server-unsupported-version-error | 2026-07-28 | server | MUST | versioning | "it **MUST** respond with an `UnsupportedProtocolVersionError` listing the versions it does support" | https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning#protocol-version-negotiation | yes (-32022, `data.supported`, `data.requested`) | n/a | | | versioning-unsupported-version-http-400 | 2026-07-28 | server | MUST | errors | "For HTTP, the response status code MUST be `400 Bad Request`." (schema, UnsupportedProtocolVersionError) | https://modelcontextprotocol.io/specification/2026-07-28/schema#unsupportedprotocolversionerror | **no**: ServeHTTP writes every JSON-RPC response with 200 | n/a | Same MUST on HeaderMismatchError and MissingRequiredClientCapabilityError | | errors-header-mismatch-http-400 | 2026-07-28 | server | MUST | errors | "For HTTP, the response status code MUST be `400 Bad Request`." (schema, HeaderMismatchError) | https://modelcontextprotocol.io/specification/2026-07-28/schema#headermismatcherror | partly: 400, but body is `{"error": "..."}` not a JSON-RPC error with -32020 | n/a | A dual-era client then cannot recognise it as a modern error and falls back to legacy — see I7 | diff --git a/pkgs/mcpx/internal/conformance/coverage_messages.go b/pkgs/mcpx/internal/conformance/coverage_messages.go index ba8ebf759c..f80f084f13 100644 --- a/pkgs/mcpx/internal/conformance/coverage_messages.go +++ b/pkgs/mcpx/internal/conformance/coverage_messages.go @@ -113,6 +113,16 @@ func init() { S("json-schema-validate-per-dialect-and-error-on-unsupported", "mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all", "schemaval.TestUnsupportedDialect@all", "schemaval.TestDeclaredDialectsCompile@all"), C("json-schema-validate-per-dialect-and-error-on-unsupported", "mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all", "schemaval.TestUnsupportedDialect@all", "schemaval.TestDeclaredDialectsCompile@all"), S("json-schema-reject-unresolved-ref", "mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all", "schemaval.TestUnresolvedInternalRef@all", "schemaval.TestRemoteRefMakesNoRequests@all"), + // json-schema-document-dialects is met by docs/schema-validation.md + // ("Dialect policy" table); the tests below pin the documented set. + S("json-schema-document-dialects", "schemaval.TestDeclaredDialectsCompile@all", "schemaval.TestUnsupportedDialect@all"), + C("json-schema-document-dialects", "schemaval.TestDeclaredDialectsCompile@all", "schemaval.TestUnsupportedDialect@all"), + // json-schema-bound-composition-cost is met by schemaval's 1 MiB + // schema-document cap (MaxSchemaBytes), which bounds the total + // subschema count a document can carry; no separate depth or + // per-validation time bound exists yet. + S("json-schema-bound-composition-cost", "schemaval.TestSchemaTooLarge@all"), + C("json-schema-bound-composition-cost", "schemaval.TestSchemaTooLarge@all"), C("json-schema-reject-unresolved-ref", "mcpclient.TestListToolsExcludesUncompilableSchemasWithWarning@all", "schemaval.TestUnresolvedInternalRef@all", "schemaval.TestRemoteRefMakesNoRequests@all"), ) registerGaps( @@ -122,9 +132,5 @@ func init() { Why: "mcpx answers methods whatever was negotiated (accept liberally, revisions.go); the schema guidance asks for -32601"}, Gap{ID: "mrtr-missing-capability-error-32021", Side: Server, Issue: "#257", Why: "through the gateway (mcpx_call) a call that needs input from a client that declared none goes to the broker instead of failing with -32021; the specification contradicts itself here (docs/spec/revision-conflicts.md). In pass-through mode the client's declaration is relayed and the upstream's -32021 returned (mcpserver.TestAPassThroughUpstreamsMissingCapabilityIsRelayed)"}, - Gap{ID: "json-schema-document-dialects", Side: Server, Issue: "#254", - Why: "no document states which dialects mcpx supports"}, - Gap{ID: "json-schema-document-dialects", Side: Client, Issue: "#254", - Why: "no document states which dialects mcpx supports"}, ) } diff --git a/pkgs/mcpx/internal/conformance/requirements.json b/pkgs/mcpx/internal/conformance/requirements.json index 080f02e345..8b4ec6b727 100644 --- a/pkgs/mcpx/internal/conformance/requirements.json +++ b/pkgs/mcpx/internal/conformance/requirements.json @@ -2200,8 +2200,8 @@ "server": "applies" }, "notes": { - "client": "no", - "server": "no" + "client": "yes: documented in docs/schema-validation.md (Dialect policy table)", + "server": "yes: documented in docs/schema-validation.md (Dialect policy table)" } }, { @@ -2312,12 +2312,12 @@ "url": "https://modelcontextprotocol.io/specification/2026-07-28/basic/index#composition-keyword-resource-use", "quote": "\"Implementations **SHOULD** apply reasonable bounds, such as a maximum schema depth, a cap on the total number of subschemas, or a per-validation time budget\"", "applicability": { - "client": "n/a:catalogue marks it n/a", - "server": "n/a:no validator" + "client": "applies", + "server": "applies" }, "notes": { - "client": "n/a", - "server": "n/a (no validator)" + "client": "yes: schemaval bounds schema documents at 1 MiB (MaxSchemaBytes)", + "server": "yes: schemaval bounds schema documents at 1 MiB (MaxSchemaBytes)" } }, {