feat: support Standard Schema for tool/prompt schemas by felixweinberger · Pull Request #1689 · modelcontextprotocol/typescript-sdk
…ompt schemas Replace the Zod-specific AnySchema type with StandardJSONSchemaV1 from the Standard Schema spec for user-provided tool and prompt schemas. Enables any schema library implementing the spec (Zod v4, Valibot, ArkType) to be used. - New packages/core/src/util/standardSchema.ts with spec interfaces and utils - RegisteredTool/RegisteredPrompt accept StandardJSONSchemaV1 - Tool callbacks use StandardJSONSchemaV1.InferOutput<T> for inference - New ArkType and Valibot examples - New integration tests for mixed schema libraries completable() remains Zod-specific (relies on .shape introspection). Co-authored-by: Matt Carey <mcarey@cloudflare.com>
7 tasks
…w fixes Follow-up to the Standard Schema feature. Completes the schema-agnostic surface and addresses review findings. Scope completion: - Narrow registration types (inputSchema/outputSchema/argsSchema) from StandardJSONSchemaV1 to StandardSchemaWithJSON — the SDK needs both ~standard.validate and ~standard.jsonSchema, so the type should say so. validateStandardSchema drops to 11 lines, no branches. - Drop resultSchema from experimental.tasks.getTaskResult() — same pattern #1606 used for callTool. Returns GetTaskPayloadResult. - Delete 7 dead exports from schema.ts orphaned by the feature. - Add fromJsonSchema(schema, validator) adapter for raw JSON Schema input (TypeBox, hand-written schemas). Wraps as StandardSchemaWithJSON using the SDK's existing AJV/cfWorker validators. Bug fixes: - Include issue.path in validation error messages (was dropping the field path, e.g. "must be a number" instead of "config.retryCount: must be a number"). - Unwrap optional schema in handlePromptCompletion — registration checked isCompletable after unwrapping, request handler didn't. completable(z.string(), cb).optional() registered but silently returned empty. Pre-existing on main. - Null-safe isOptionalSchema so unwrapOptionalSchema(undefined) doesn't crash when the arg name doesn't exist in the schema shape. Docs and tests: - Migration guides document the removed exports and use z.object() consistently. - standardSchema.test.ts cleaned to v2 request() API (no schema arg; auto-resolved from method name). - Changeset + tests for fromJsonSchema.
This was referenced
Mar 23, 2026This was referenced
Mar 15, 2026This was referenced
Mar 25, 2026This was referenced
Mar 27, 2026This was referenced
Mar 28, 2026This was referenced
Mar 30, 2026This 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