mcptest docs GitHub

Structured output conformance

An MCP tool can declare an outputSchema and return a structuredContent object alongside its text content. mcptest checks that the structured result actually validates against the schema the tool declared. The check is deterministic and reuses the same JSON Schema matcher the schema: assertion uses. No model is involved.

Run this example. examples/output-schema-conformance.yml asserts a tool's result.structuredContent against its declared outputSchema with the schema: matcher.

mcptest run --config examples/output-schema-conformance.yml

Why it matters

Programmatic tool calling (Anthropic) and Code Mode (Cloudflare) both project MCP tools into a typed code API, and the model writes code that consumes the typed output. When a tool's real structuredContent drifts from its declared outputSchema, the generated binding breaks without an obvious error: a field the calling code expects is absent or the wrong type. The conformance check catches that drift before it reaches the code path.

Rule SCHEMA-006

The check carries rule ID SCHEMA-006, in the SCHEMA family of the standardized rule-ID scheme. It runs in code rather than as a compliance corpus rule, because it reads the tool's own declared outputSchema at runtime and validates a live structuredContent result against it. The single request/response corpus assertions cannot express that. The SEC and DESC families carry catalogue IDs the same way.

What it reports

The check applies only when a tool declares an outputSchema. Given that tool definition and the matching tools/call result:

A tool that declares no outputSchema produces no finding. There is nothing to conform to, so the check stays silent rather than warning on every untyped tool.