Allow $ref in Tool::Schema for protocol version 2025-11-25#242
Merged
koic merged 1 commit intomodelcontextprotocol:mainfrom Mar 1, 2026
Merged
Allow $ref in Tool::Schema for protocol version 2025-11-25#242koic merged 1 commit intomodelcontextprotocol:mainfrom
$ref in Tool::Schema for protocol version 2025-11-25#242koic merged 1 commit intomodelcontextprotocol:mainfrom
Conversation
`Tool::Schema` rejected `$ref` with an `ArgumentError`. Earlier MCP spec versions (2024-11-05 through 2025-06-18) did not define a JSON Schema dialect or reference the `$ref` keyword. `inputSchema` was described only as "JSON Schema defining expected parameters" with no further constraints: - https://modelcontextprotocol.io/specification/2024-11-05/server/tools - https://modelcontextprotocol.io/specification/2025-06-18/server/tools The MCP spec 2025-11-25 introduced a "JSON Schema Usage" section that adopts JSON Schema 2020-12 as the default dialect. Since `$ref` is a core keyword in 2020-12, it is now allowed for protocol version 2025-11-25 and later. - https://modelcontextprotocol.io/specification/2025-11-25/basic#json-schema-usage - https://modelcontextprotocol.io/specification/2025-11-25/server/tools - https://json-schema.org/draft/2020-12/release-notes For backward compatibility with older protocol versions (2025-06-18 and earlier), `Server#validate!` continues to raise `ArgumentError` when a tool input schema contains `$ref`. This preserves the existing behavior for servers targeting those spec versions.
5f3728b to
99cbefc
Compare
9 tasks
atesgoral
approved these changes
Mar 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Tool::Schemarejected$refwith anArgumentError. Earlier MCP spec versions (2024-11-05 through 2025-06-18) did not define a JSON Schema dialect or reference the$refkeyword.inputSchemawas described only as "JSON Schema defining expected parameters" with no further constraints:The MCP spec 2025-11-25 introduced a "JSON Schema Usage" section that adopts JSON Schema 2020-12 as the default dialect. Since
$refis a core keyword in 2020-12, it is now allowed for protocol version 2025-11-25 and later.How Has This Been Tested?
Added a repro test to verify the fix and prevent regression.
Breaking Changes
None. For backward compatibility with older protocol versions (2025-06-18 and earlier),
Server#validate!continues to raiseArgumentErrorwhen a tool input schema contains$ref. This preserves the existing behavior for servers targeting those spec versions.Types of changes
Checklist