Skip to content

Keep $defs in MCP 2024-11-05 and 2025-03-26 tool input schemas - #11010

Open
Marve10s wants to merge 1 commit into
Effect-TS:mainfrom
Marve10s:fix/mcp-legacy-tool-defs
Open

Marve10s wants to merge 1 commit into
Effect-TS:mainfrom
Marve10s:fix/mcp-legacy-tool-defs

Conversation

@Marve10s

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

On the 2024-11-05 and 2025-03-26 protocol revisions, McpServer lists tool input schemas whose properties reference #/$defs/... without the $defs they point to. Any tool parameter that nests a Schema.Class or another schema with an identifier is affected, so clients that negotiate these revisions get an input schema they cannot resolve, and strict model providers may reject the tool. 2025-06-18 and later already keep $defs.

The legacy wire schema ToolInputSchema (shared by both revisions) is a closed struct of type, properties and required, so encoding strips every other root keyword, including $defs, while the nested $refs are copied through unchanged. Both revisions' spec schema.json describe inputSchema as an open JSON Schema object. This adds an optional $defs field to ToolInputSchema (object or boolean definitions, as toolJsonSchema emits only $defs), which keeps the referenced definitions and leaves the existing behavior of dropping additionalProperties on these revisions unchanged.

Verification

The same probe on both versions lists a tool whose parameters are Schema.Struct({ to: Address }), with Address a Schema.Class, over McpServer.layerHttp:

effect@4.1.7 and main:
2024-11-05 {"type":"object","properties":{"to":{"$ref":"#/$defs/AddressEncoded"}},"required":["to"]}
2025-03-26 {"type":"object","properties":{"to":{"$ref":"#/$defs/AddressEncoded"}},"required":["to"]}

this branch:
2024-11-05 {"type":"object","$defs":{"AddressEncoded":{"type":"object","properties":{"street":{"type":"string"},"city":{"type":"string"}},"required":["street","city"],"additionalProperties":true}},"properties":{"to":{"$ref":"#/$defs/AddressEncoded"}},"required":["to"]}
2025-03-26 (same as 2024-11-05)

The new protocol adapter test for both revisions fails without the fix (no $defs.AddressEncoded) and passes with it, alongside the existing 2025-03-26 test that drops additionalProperties. Root pnpm check and pnpm lint passed, and the effect test files passed (15,017 tests, 58 skipped).

@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f7ea936

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-cloudflare Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.28 KB 40.28 KB 0.00 KB (0.00%)
basic.ts 6.60 KB 6.60 KB 0.00 KB (0.00%)
batching.ts 11.65 KB 11.65 KB 0.00 KB (0.00%)
brand.ts 7.17 KB 7.17 KB 0.00 KB (0.00%)
cache.ts 11.83 KB 11.83 KB 0.00 KB (0.00%)
config.ts 23.75 KB 23.75 KB 0.00 KB (0.00%)
differ.ts 22.55 KB 22.55 KB 0.00 KB (0.00%)
http-client.ts 28.40 KB 28.40 KB 0.00 KB (0.00%)
http-router.ts 39.10 KB 39.10 KB 0.00 KB (0.00%)
logger.ts 12.26 KB 12.26 KB 0.00 KB (0.00%)
metric.ts 9.91 KB 9.91 KB 0.00 KB (0.00%)
optic.ts 7.43 KB 7.43 KB 0.00 KB (0.00%)
pubsub.ts 16.55 KB 16.55 KB 0.00 KB (0.00%)
queue.ts 13.44 KB 13.44 KB 0.00 KB (0.00%)
schedule.ts 12.27 KB 12.27 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.32 KB 14.32 KB 0.00 KB (0.00%)
schema-binary.ts 43.17 KB 43.17 KB 0.00 KB (0.00%)
schema-class.ts 22.31 KB 22.31 KB 0.00 KB (0.00%)
schema-codegen.ts 33.66 KB 33.66 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.76 KB 30.76 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.49 KB 28.49 KB 0.00 KB (0.00%)
schema-string-transformation.ts 16.06 KB 16.06 KB 0.00 KB (0.00%)
schema-string.ts 12.60 KB 12.60 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.62 KB 16.62 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 39.82 KB 39.82 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.44 KB 21.44 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.62 KB 21.62 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.71 KB 21.71 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.75 KB 26.75 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.77 KB 21.77 KB 0.00 KB (0.00%)
schema.ts 21.41 KB 21.41 KB 0.00 KB (0.00%)
stm.ts 14.77 KB 14.77 KB 0.00 KB (0.00%)
stream.ts 10.56 KB 10.56 KB 0.00 KB (0.00%)
supervisor.ts 11.85 KB 11.85 KB 0.00 KB (0.00%)

This branch is waiting to be deployed

1 waiting deployment
fork — f7ea9362 Waiting Nov 27, 2026 by Marve10s via approval-gate #27806
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant