-
Notifications
You must be signed in to change notification settings - Fork 1.4k
SEP-1613: use.catchall() on inputSchema/outputSchema to support JSON Schema 2020-12
#1135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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: |
|
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.
Done! |
.catchall() on inputSchema/outputSchema to support JSON Schema 2020-12
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