go-sdk icon indicating copy to clipboard operation
go-sdk copied to clipboard

Dual-era servers serve modern Tool schemas unchanged to legacy clients

Open SamMorrowDrums opened this issue 3 months ago • 6 comments

Summary

The Go SDK supports both legacy MCP (2025-11-25 and earlier) and modern MCP (2026-07-28), but a server registers one static Tool.InputSchema and appears to return that same schema from tools/list regardless of the negotiated/requested protocol version.

That can make a dual-era server emit a schema that is valid under 2026-07-28 but outside the 2025-11-25 Tool.inputSchema envelope.

Specification boundary

In 2025-11-25, Tool.inputSchema permits only:

{
  $schema?: string;
  type: "object";
  properties?: { [key: string]: object };
  required?: string[];
}

SEP-2106, shipped in 2026-07-28, changes this to:

{ $schema?: string; type: "object"; [key: string]: unknown }

This explicitly permits root composition keywords such as anyOf, oneOf, and allOf for modern clients.

Reproduction shape

  1. Create a Go SDK server using the normal dual-era/default protocol support.
  2. Register a tool whose root input schema contains type: "object" plus anyOf.
  3. Connect a client using protocol version 2025-11-25.
  4. Call tools/list.
  5. Observe that the modern schema is returned unchanged even though root anyOf was not representable by the legacy Tool.inputSchema definition.

A concrete downstream incident is documented in github/github-mcp-server#3126. That incident also involved a model-provider restriction, but this issue is specifically about MCP protocol-era conformance.

Expected SDK behavior / API

The SDK should provide a deliberate way for dual-era servers to remain schema-conformant. Possible approaches:

  1. Validate tool schemas against every enabled protocol version at registration/startup and reject modern-only schemas unless the server supplies a legacy representation.
  2. Provide a version-aware tool/schema callback or tools/list projection hook so applications can supply a legacy-compatible representation.
  3. Document that dual-era servers must keep canonical tool schemas within the legacy intersection unless they opt into version-specific representations.

I do not think the SDK should silently strip modern keywords, because removing constraints can change tool semantics.

Immutability and concurrency

Any version-specific representation should:

  • deep-clone or use copy-on-write per inventory/list response;
  • never mutate shared Tool, InputSchema, Properties, or nested schema maps in place;
  • remain safe when legacy and modern requests are served concurrently;
  • preserve the canonical modern schema for modern clients and caches.

Provider compatibility is separate

This issue should not attempt to solve Anthropic/OpenAI tool-schema subsets. A client using modern MCP may still need a provider-specific schema adapter before forwarding tools to an LLM API. That is independent of the MCP protocol version selected between client and server.

Existing issues checked

  • #990 implemented SEP-2106 for the modern protocol.
  • #455 addressed decoding incompatible schemas from older JSON Schema drafts.

I did not find an issue covering version-specific tools/list schema representations for a dual-era server.

SamMorrowDrums avatar Aug 20 '26 09:08 SamMorrowDrums

Related SDK and specification issues

These issues cover adjacent parts of the same compatibility problem; none appears to track version-specific tools/list schema representations for a dual-era Go server directly.

Go SDK

TypeScript SDK

Specification / practical consumption

The provider-adapter problem remains separate: a modern MCP schema can be valid under SEP-2106 and still require a copied/provider-specific representation before forwarding to Claude or OpenAI. #1188 is focused only on the Go SDK's MCP protocol-era behavior and immutable version-specific representations.

SamMorrowDrums avatar Aug 20 '26 09:08 SamMorrowDrums

I would like to help investigate this compatibility boundary if the maintainers agree with the direction. I can start with a focused, non-breaking implementation and regression coverage for concurrent legacy/modern tools/list responses, but the issue lists several possible API shapes (validation, projection, or documentation) and I do not want to choose one without maintainer guidance. Which contract would you prefer for the Go SDK: reject modern-only schemas at registration, provide a version-aware projection hook, or document the legacy-intersection requirement?

jstar0 avatar Aug 28 '26 15:08 jstar0

Hi maintainers, I would like to work on this issue and have a fix ready. I’ve reproduced the protocol-version mismatch and prepared a patch that keeps the canonical modern schema for 2026-07-28 sessions while projecting a legacy-safe schema for 2025-11-25 and earlier clients.

I would appreciate it if this issue could be assigned to me so I can continue with the review/PR process.

Thanks!

Adebayo120 avatar Oct 31 '26 19:10 Adebayo120

Hi @SamMorrowDrums,

The dual-era tools/list case here looks like a useful boundary for an independent compatibility fixture: the same tool can expose an input schema with root anyOf that is representable in the 2026-07-28 contract but not the older 2025-11-25 envelope.

I'm working on ChangeProof, which compares versioned MCP/OpenAPI snapshots and produces an integrity-checked, manually reviewed change report.

Would a free, read-only comparison of two public or synthetic tools/list snapshots (legacy-visible vs modern-visible) be useful as supplementary evidence for #1188? I could report exact schema/metadata deltas and conservative compatibility risks, including unsupported constructs marked for manual review.

This would not test the Go SDK's runtime negotiation, concurrent requests, in-place mutation, or provider-specific schema restrictions. No credentials, server access, installation, or payment required. If useful, which two representations would you want compared?

jajazpua avatar Nov 02 '26 00:11 jajazpua

For the dual-era schema concern, a good regression control is to register one modern tool with root anyOf, then serve tools/list concurrently to clients negotiating 2025-11-25 and 2026-07-28.

The test should assert both versions receive representations that satisfy their own protocol-era envelopes, that the modern response retains the intended constraints, and that serving the legacy response never mutates the canonical tool or causes nondeterministic results for the modern client.

If no faithful legacy representation exists, explicit registration or negotiation failure seems safer than silently stripping anyOf. A static before/after manifest comparison can help audit the projections but cannot prove concurrency safety. This is a proposed regression, not a run against the Go SDK.

jajazpua avatar Nov 04 '26 05:11 jajazpua

This dual-era schema mismatch also hits LLM provider validators (OpenAI, Anthropic, and Gemini strict function-calling validators reject root-level anyOf, oneOf, and allOf on inputSchema even when the MCP client itself negotiates 2026-07-28).

When a server serves a 2025-11-25 session (or normalizes Tool.InputSchema for legacy clients), root-level object composition branches (anyOf, oneOf, allOf where each branch has properties) can be deterministically flattened into the 2025-11-25 envelope { "$schema"?: string, "type": "object", "properties"?: ..., "required"?: ... }:

  1. Merge properties across all non-null object branches into the root properties map (inlining local $defs/$ref first if present).
  2. Compute root required:
    • For allOf: take the union of branch required lists.
    • For anyOf / oneOf: take the intersection of branch required lists (only properties required in every branch remain required at the root).
  3. Strip root anyOf / oneOf / allOf while keeping the full unflattened schema inside the server's internal 2026-07-28 validator so server-side argument validation still enforces the exact branch constraints on tools/call.

We just shipped this exact root anyOf/oneOf/allOf -> 2025-11-25 properties/required flattening pass (alongside $defs/$ref inlining and nullable ["T", "null"] collapse) in mcp-slim (SchemaSlimmer.slim_schema_node in src/mcp_slim/slimmer.py), which can also sit in front of any stdio MCP server (mcp-slim run -- <server-cmd>) to downgrade and compact schemas for legacy clients.

SalyyS1 avatar Nov 12 '26 01:11 SalyyS1