Four Contracts, One Tool Call: Shipping MCP Schemas Across Model Providers
Make MCP tool calls reliable across model providers with explicit schema profiles, validated adapters, release gates, and separate input, output, and authorization checks.
On this page
A tool definition can be valid under the Model Context Protocol and unusable by a particular model's strict-output mode. That is neither proof of a model failure nor necessarily a defect in the MCP server. It is a compatibility error between independently versioned interfaces.
I would operate that boundary as four contracts: the MCP schema advertised by the server, the schema shown to a particular model, the executor's validation of actual arguments and results, and the authorization policy deciding whether the requested action is allowed. A schema-constrained response is not the last line of defense; it is only the first part of an application-owned tool call.
The July 28, 2026 MCP revision expanded the schema vocabulary for tools to JSON Schema 2020-12. The official changelog confirms this. But an MCP schema and a provider's constrained-generation schema are distinct contracts. This article develops an original compatibility release gate for a hypothetical industrial asset-monitoring assistant. Its architecture, code, and failure cases are design proposals, not reports of a real deployment.
A maintenance tool with two query modes
Imagine an assistant that retrieves measurements from factory equipment. A user may ask for the latest reading or a historical interval. The server's read_asset_samples tool must enforce these conditions:
- The caller can access the requested asset within the authenticated tenant.
- A latest query must not contain a date interval.
- A range query requires two valid UTC timestamps, start before end, within an approved maximum window.
- Returned readings must be scoped to the same tenant and asset.
- Unsupported modes or malformed arguments must be rejected rather than guessed.
A sophisticated JSON Schema can describe much of that shape, but some invariants—authorization, asset existence, maximum business-allowed interval—still require application code. The model should not be trusted to certify these facts.
I would split the tool path explicitly:
~~~text MCP tools/list --> trusted schema registry | compatibility record for route / | \ MCP definition model view adapter version \ | / [model proposes JSON] | validate model view | translate with reviewed adapter | validate canonical input | authorize and execute | validate structured result | scoped model output
Release admission and policy live outside the model. ~~~
This is an original *execution contract diagram*, not a description of a specific MCP SDK.
An important terminology distinction: structuredContent is a server-produced tool result, not the model's structured-output response. The 2026 MCP tool specification allows it to be any JSON value (including arrays and primitives) and defines outputSchema for validating those results. Decoder constraints for model-generated tool arguments are a separate issue.
The contract manifest is a release artifact
For each admitted tool/model combination, I would store a record with the MCP server identity, protocol version, canonical input and output schema hashes, model-facing schema hash, provider/model identifier, strict-mode profile, translation-adapter revision, validator revision, and required test evidence.
A digest identifies bytes, not semantic equivalence. Two different schemas may permit the same operations—or a tiny text change may alter their accepted inputs. The compatibility record therefore needs tests, not just matching names.
| Change | Required review |
|---|---|
| MCP input schema adds a required field | Re-evaluate model view and adapter |
| MCP output schema changes its root type | Re-test clients and result parsing |
| Provider switches strict-mode behavior | Re-test schema admission and tool invocation |
| Model is upgraded | Require an explicit tested profile |
| Tool description or permissions change | Re-evaluate trust and authorization separately |
| Adapter changes null/omitted-field semantics | Test both query modes and failure cases |
This builds on my tool-definition drift gate, which addresses whether a live tool still matches its approved identity. Here the question is whether a *trusted* tool is representable and executable through a particular model interface.
What the primary documentation actually guarantees
OpenAI's Structured Outputs documentation lists constraints on strict object schemas, including required properties and additionalProperties: false, and excludes certain composition keywords such as allOf, not, and if/then/else. It documents an error when an unsupported schema is supplied with strict mode; I would not claim the API silently removes keywords. Some capabilities differ for fine-tuned models.
Anthropic's structured outputs and strict tool-use documentation has a different supported subset, including qualified support for allOf, and restrictions on numeric, length, and recursive schemas. It likewise documents errors for unsupported features.
These are provider product contracts, not interchangeable definitions of JSON Schema. A gateway should pin and test a profile for its actual endpoint, model, mode, and SDK version. Do not hard-code one “LLM schema subset” and assume it applies forever.
A compatibility gate has three valid outcomes: the authoritative schema is directly supported; a deliberately reviewed simpler model-facing representation maps safely to the authoritative tool contract; or the tool is unavailable for that route. The dangerous fourth outcome is silently weakening constraints while reporting them as enforced.
TypeScript: keep the model view simpler than the server contract
The model-facing representation below requires a mode and two nullable date fields. The trusted adapter then converts it to a canonical request. For latest it removes date fields only after confirming both are null; for range it requires dates and validates a business time window.
This example uses Ajv 8 with the JSON Schema 2020-12 class and ajv-formats. It assumes those dependencies are installed. It illustrates a gateway boundary rather than implementing the MCP transport.
~~~typescript import Ajv2020 from "ajv/dist/2020"; import addFormats from "ajv-formats";
const ajv = new Ajv2020({ strict: true }); addFormats(ajv);
const modelSchema = { type: "object", properties: { asset_id: { type: "string" }, mode: { type: "string", enum: ["latest", "range"] }, start_utc: { type: ["string", "null"] }, end_utc: { type: ["string", "null"] }, }, required: ["asset_id", "mode", "start_utc", "end_utc"], additionalProperties: false, } as const;
const canonicalSchema = { type: "object", properties: { assetId: { type: "string", minLength: 1, maxLength: 128 }, mode: { type: "string", enum: ["latest", "range"] }, startAt: { type: "string", format: "date-time" }, endAt: { type: "string", format: "date-time" }, }, required: ["assetId", "mode"], additionalProperties: false, allOf: [ { if: { type: "object", properties: { mode: { const: "range" } } }, then: { type: "object", required: ["startAt", "endAt"] }, }, { if: { type: "object", properties: { mode: { const: "latest" } } }, then: { not: { anyOf: [ { type: "object", required: ["startAt"] }, { type: "object", required: ["endAt"] }, ], }, }, }, ], } as const;
const checkView = ajv.compile(modelSchema); const checkCanonical = ajv.compile(canonicalSchema);
type View = { asset_id: string; mode: "latest" | "range"; start_utc: string | null; end_utc: string | null; };
export function parseToolArguments(raw: unknown): unknown { if (!checkView(raw)) throw new Error("model-schema-failure"); const v = raw as View; let canonical: unknown;
if (v.mode === "latest") { if (v.start_utc !== null || v.end_utc !== null) { throw new Error("unexpected-date-range"); } canonical = { assetId: v.asset_id, mode: "latest" }; } else { if (v.start_utc === null || v.end_utc === null) { throw new Error("missing-range"); } canonical = { assetId: v.asset_id, mode: "range", startAt: v.start_utc, endAt: v.end_utc, }; }
if (!checkCanonical(canonical)) { throw new Error("canonical-schema-failure"); }
if (v.mode === "range") { const start = Date.parse(v.start_utc!); const end = Date.parse(v.end_utc!); const sevenDaysMs = 7 * 24 * 60 * 60 * 1000; if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start || end - start > sevenDaysMs) { throw new Error("business-range-rejected"); } }
return canonical; } ~~~
The code intentionally makes no external API call. The executor must also check that the current authenticated tenant may read assetId, apply rate and cost limits, and send the canonical request through a trusted MCP adapter. Neither the model-facing schema nor the returned object gives the model authority to access another tenant.
The canonical schema uses composition keywords that are available to a full JSON Schema validator but not necessarily supported by a strict model decoder. That is why the model sees a separate view. The application does not silently strip server rules; it restores their effect through trusted translation and validation.
A more complex system might generate the simpler view at build time, but only after proving the transformation preserves intended semantics. Do not build a general-purpose schema flattener that claims arbitrary oneOf or conditions are equivalent to a broader object schema.
Validate the server output independently
The tool server—not the model—produces structuredContent. Its output may now be an array, primitive, or object, depending on the declared schema. Validate the entire value against the pinned outputSchema and the application invariants before passing it to the model or the UI.
These cases must remain distinct:
| Server response | Meaning |
|---|---|
| Valid empty array | Successful query with no results |
Completed result violating outputSchema | Server contract failure |
| A result from the wrong tenant or asset | Security and isolation failure |
| Tool error or input-required state | Not a successful empty response |
| Output shape from a newer untested server | Compatibility failure; use an approved version |
The MCP specification requires a server that declares an output schema to return conforming structured data and recommends that clients validate it. It also recommends compatible text content when returning structured data. Treat that text as a compatibility aid, not an authority that overrides authenticated structured results.
For model-generated arguments, runtime validation is needed even after schema-constrained generation. For tool results, runtime validation is needed even if transport and JSON parsing succeeded. Those are different checks that should have different failure metrics.
Python: block deployments without complete compatibility evidence
A release controller should require an exact tested configuration instead of a generic “supports tools” flag. This pure function models the policy decision; authenticated CI evidence and provider tests must be supplied by infrastructure outside it.
~~~python from dataclasses import dataclass from typing import Literal
Status = Literal["pass", "fail", "unknown"] REQUIRED = frozenset({ "provider_schema_admitted", "model_view_validated", "canonical_mapping_tested", "tenant_access_denied", "structured_result_checked", "unsupported_schema_rejected", })
@dataclass(frozen=True) class Release: tool_revision: str model_profile: str adapter_revision: str validator_revision: str
@dataclass(frozen=True) class Check: release: Release name: str status: Status verified_origin: bool
def allow_release(expected: Release, checks: list[Check]) -> bool: if not all(vars(expected).values()): return False observed: dict[str, Status] = {} for check in checks: if (check.release != expected or not check.verified_origin or check.name not in REQUIRED or check.name in observed): return False observed[check.name] = check.status return set(observed) == REQUIRED and all( value == "pass" for value in observed.values() )
example = Release("asset-read-v3", "model-profile-v2", "adapter-v3", "validator-v2") checks = [Check(example, name, "pass", True) for name in REQUIRED] assert allow_release(example, checks) assert not allow_release(example, checks[:-1]) ~~~
verified_origin is an assumption about the trusted caller, not an authenticator: passing True from an untrusted process would defeat the gate. In production, a protected release service must fetch check status from the authorized CI provider and bind it to the actual repository commit, schema digests, model configuration, and deployed artifact. The release identity should include the MCP protocol revision and both schema hashes in that protected record.
This mechanism prevents a missing check from being misreported as success. It does not prove that one passing test suite establishes universal model correctness.
The security boundary must outlive the model-facing format
A correctly constrained tool call can still target an unauthorized resource. The server must independently validate caller identity, tenant membership, asset permission, request budgets, and any approval required for side effects.
Schema references can also become an attack surface. The 2026 MCP changes include reference-resolution requirements and composition-resource bounds. For tool definitions from less trusted servers, do not automatically fetch arbitrary external $ref URIs; bound schema size, depth, reference expansion, validation time, and compiled variants. Review the implementation of these controls in the chosen JSON Schema engine. The Ajv strict-mode guide explains how ambiguous or ignored keywords can be surfaced rather than quietly accepted.
The boundaries are cumulative. A valid schema cannot grant access, and an authorized user cannot make invalid data safe. For operations that modify state, an independent approval and idempotency layer is required, as described in my agent tool authorization article.
Failure tests before the canary
I would test compatibility against each supported provider/model/adapter combination using controlled synthetic fixtures:
- Model schema admission rejects an unsupported keyword instead of claiming successful enforcement.
- Null versus missing date fields produces the expected canonical decision.
- Unexpected
latestdates, reversed intervals, and excessive ranges fail without a tool call. - A tool upgrade adds a required field and invalidates its old adapter evidence.
- A changed output root type is handled by a compatible client or blocked explicitly.
- A mismatched schema fingerprint or model revision blocks dispatch.
- Unknown asset ownership is denied even when the argument shape passes.
- External reference resolution and oversized schemas fail within resource budgets.
- Model failure is classified separately from server error and provider-schema rejection.
- Tool discovery changes trigger compatibility re-evaluation before the next protected call.
Observe failures at each boundary: provider admission failure, model-view validation failure, canonical mapping failure, authorization denial, server output violation, and unavailable tool routes. Track counts against their correct denominators, plus final workflow success, p95 latency, and per-outcome cost. Do not invent measured improvement percentages; compare canary results against a retained baseline.
For logs, keep model profile, schema version, and error class as low-cardinality dimensions. Avoid exporting raw prompts or sensitive tool arguments by default. My telemetry export boundary covers that concern.
During a rolling deployment, only route traffic to combinations that have complete evidence. Roll back the server, adapter, and model-profile combination, not just a model identifier. Discovery caches and approval records must be invalidated consistently. The broader MCP protocol compatibility gate addresses host/server version negotiation; this article addresses the separate schema-to-decoder boundary.
Prefer explicit compatibility to magical repair
For a small read-only tool with a simple schema, a direct interface plus server-side validation may be enough. A fleet of MCP servers and multiple model providers needs something more deliberate: a tested compatibility registry, reviewed adapters where necessary, independent result validation, and a hard refusal when the route is unsupported.
The architectural principle is straightforward: the model-facing shape is an interface, not the source of truth. Rich server schemas, real-world authorization, and result validation retain their authority regardless of what the decoder can generate.
Primary technical sources
- MCP 2026-07-28 changelog
- MCP 2026-07-28 tool specification
- JSON Schema 2020-12
- OpenAI Structured Outputs guide
- Anthropic structured outputs and strict tool use
- Ajv JSON Schema support
- Ajv strict-mode guidance
Topic provenance: The subject was discovered through Viral Ruparel's October 29, 2026 MCP schema article. The four-contract model, industrial-asset example, release evidence matrix, code, diagram, and testing analysis above are original, developed using first-party technical documentation.
KEEP READING
Related engineering notes
A Failover Route Is Not a Recovery Path: Proving Independence in AI Infrastructure
Two LLM providers can share the same failure domain. Build an evidence-backed recovery graph that checks cloud, networking, identity, control-plane and capacity dependencies before admitting fallback routes, then test correlated outages without weakening safety.
Read articleAn Eval Platform Sunset Can Erase Your Release Evidence: Build an Evidence-Escrow Migration Gate
When a hosted LLM evaluation platform retires, switching runners is not enough. Preserve the historical evidence, reconstruct grader semantics, validate scoring parity, and enforce a fail-closed release gate that survives the service shutdown.
Read articleWhen the Package Runs Before Your App: Quarantining AI Framework Releases
The 2026 agent-framework PyPI compromise exposed a blind spot in AI build pipelines: Python startup hooks execute before application imports. Design an artifact-quarantine gate, inspect wheels without installing them, separate credentials, and recover from suspected exposure.
Read article