SEP-1613: use.catchall() on inputSchema/outputSchema to support JSON Schema 2020-12#1135
Merged
SEP-1613: use.catchall() on inputSchema/outputSchema to support JSON Schema 2020-12#1135
.catchall() on inputSchema/outputSchema to support JSON Schema 2020-12#1135Conversation
Add .passthrough() to inputSchema and outputSchema to accept all JSON Schema 2020-12 keywords. This is the correct approach because: - inputSchema/outputSchema are embedded external specs (JSON Schema), not MCP protocol fields that should be strictly validated - The SDK's role is to transport schemas, not validate JSON Schema structure - Enumeration approach would silently drop unrecognized keywords (data loss) Changes: - Add .passthrough() to inputSchema and outputSchema in ToolSchema - Update JSDoc to document SEP-1613/2020-12 as default dialect - Add comprehensive tests for JSON Schema 2020-12 keyword support Backwards compatible: existing typed properties (type, properties, required) remain explicitly typed for TypeScript autocomplete.
8fe3ce9 to
2d3b1a5
Compare
commit: |
Contributor
|
Hello, There should be a way to achieve it without using
inputSchema: z
.object({
type: z.literal('object'),
properties: z.record(z.string(), AssertObjectSchema).optional(),
required: z.array(z.string()).optional()
})
.catchall(z.unknown()),or alternatively an intersection with a inputSchema: z.intersection(z
.object({
type: z.literal('object'),
properties: z.record(z.string(), AssertObjectSchema).optional(),
required: z.array(z.string()).optional()
}), z.record(z.string(), z.unknown())) |
More semantically correct for JSON Schema objects where additional properties are expected but not validated by Zod.
Contributor
Author
Done! |
.catchall() on inputSchema/outputSchema to support JSON Schema 2020-12
pcarleton
approved these changes
Nov 21, 2025
pcarleton
added a commit
that referenced
this pull request
Jan 12, 2026
- Remove unused Tool type import - Remove unused JSON_SCHEMA_2020_12_INPUT_SCHEMA constant (SEP-1613 test is pending - SDK validation supports the fields via PR #1135, but tool registration doesn't yet support generating raw JSON Schema) - Remove emoji from console.log - Alphabetize devDependencies in package.json
This was referenced Jan 13, 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.
Summary
Restores
.catchall()oninputSchemaandoutputSchemain ToolSchema to properly support JSON Schema 2020-12 keywords as required by SEP-1613.Motivation and Context
SEP-1613 establishes JSON Schema 2020-12 as the default dialect for MCP embedded schemas. This requires the SDK to preserve all JSON Schema properties (like
$schema,additionalProperties,$defs,allOf, etc.) rather than stripping them.The Problem: PR #1086 removed
.passthrough()from ToolSchema, causing the SDK to strip valid JSON Schema properties. This was reported in #1057 where$schemawas being stripped, breaking SEP-1613's backwards compatibility mechanism (servers need$schemato specify alternative dialects).Why passthrough is correct here:
inputSchemadoes NOT haveadditionalProperties: false, meaning additional properties are allowed by defaultinputSchema/outputSchemaare JSON Schema objects - the SDK should transport them, not validate their internal structure$schemato use dialects other than 2020-12Changes:
.catchall()toinputSchemaandoutputSchemain ToolSchematype,properties,required) for TypeScript backwards compatibilityHow Has This Been Tested?
Breaking Changes
None. This restores the ability to use JSON Schema properties that were being silently stripped since PR #1125.
Types of changes
Checklist