Repository navigation
feat: support Standard Schema for tool/prompt schemas - #1689
Merged
Merged
Conversation
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.
Supersedes #1473 — rebased, with follow-up fixes from review.
Replace the Zod-specific
AnySchematype withStandardSchemaWithJSONfrom the Standard Schema spec for tool and prompt schemas. Any library implementing both~standard.validateand~standard.jsonSchemaworks — Zod v4, ArkType, Valibot.Motivation and Context
The SDK was tightly coupled to Zod for user-provided schemas. This makes it library-agnostic:
registerTool/registerPromptnow accept any schema that can both validate incoming arguments and emit JSON Schema fortools/list.Zod v4 schemas work unchanged — Zod v4 implements the spec natively.
How Has This Been Tested?
Breaking Changes
inputSchema/outputSchema/argsSchemanow typedStandardSchemaWithJSONinstead of ZodAnySchema. Zod v4 schemas satisfy this without changes.experimental.tasks.getTaskResult()no longer accepts aresultSchemaparameter (returnsGetTaskPayloadResult; cast at call site).@modelcontextprotocol/core:SchemaInput,schemaToJson,parseSchemaAsync,getSchemaShape,getSchemaDescription,isOptionalSchema,unwrapOptionalSchema.completable()remains Zod-specific (relies on.shapeintrospection).Types of changes
Checklist
Additional context
Changes on top of #1473:
StandardJSONSchemaV1(JSON Schema only) toStandardSchemaWithJSON(both validate + JSON Schema) — the SDK needs both, so the type should say so. This letvalidateStandardSchemadrop its fallback branches.resultSchemafromexperimental.tasks.getTaskResult()— consistent withv2refactor!: remove Zod schema parameter from public-facing APIs #1606 removing user-supplied Zod schemas for response parsing.Co-authored with @mattzcarey.