Skip to content

[Client][Schema] Preserve JSON types in tool results and output schemas - #771

Open
ineersa wants to merge 1 commit into
modelcontextprotocol:mainfrom
ineersa:fix/preserve-client-structured-json
Open

ineersa wants to merge 1 commit into
modelcontextprotocol:mainfrom
ineersa:fix/preserve-client-structured-json

Conversation

@ineersa

@ineersa ineersa commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve JSON object/list distinctions in structuredContent and discovered outputSchema using the already-decoded response.
  • Keep response envelopes and content blocks in their existing array representation; structured JSON objects remain stdClass.
  • Reject shape-sensitive responses through a correlated error when NUL-prefixed member names force lossy associative decoding.
  • Document the representation change and cover parsing, hydration, serialization and pending-request error delivery.

Motivation

Converting an empty structured object to an empty PHP array makes a valid result fail object-schema validation. Schema literals such as const: {} also become indistinguishable from const: []. Preserve the original JSON types before those distinctions are lost.

Validation

  • SDK unit suite: 4,005 tests / 11,778 assertions passed.
  • SDK integration suite: 241 tests / 1,147 assertions passed.
  • PHPStan, formatting and git diff --check passed.
  • Deptrac passed on the initial structured-result patch; not rerun after the final discovery/error additions.
  • Full interop is unverified: the earlier full make tests run lacked Node fixtures, including mcp-server-everything and mcp-inspector.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant