typescript-sdk/.changeset/support-standard-json-schema.md
Konstantin Konstantinov 0fb8406d83
v2: codemod iterations, canonical zod schema exports from sdk-shared (#2354)
Co-authored-by: Felix Weinberger <fweinberger@anthropic.com>
2026-06-25 19:42:44 +01:00

1.7 KiB

@modelcontextprotocol/core-internal @modelcontextprotocol/server @modelcontextprotocol/client
minor minor minor

Support Standard Schema for tool and prompt schemas

Tool and prompt registration now accepts any schema library that implements the Standard Schema spec: Zod v4, Valibot, ArkType, and others. RegisteredTool.inputSchema, RegisteredTool.outputSchema, and RegisteredPrompt.argsSchema now use StandardSchemaWithJSON (requires both ~standard.validate and ~standard.jsonSchema) instead of the Zod-specific AnySchema type.

Zod v4 schemas continue to work unchanged — Zod v4 implements the required interfaces natively.

import { type } from 'arktype';

server.registerTool('greet', {
  inputSchema: type({ name: 'string' })
}, async ({ name }) => ({ content: [{ type: 'text', text: `Hello, ${name}!` }] }));

For raw JSON Schema (e.g. TypeBox output), use the new fromJsonSchema adapter:

import { fromJsonSchema } from '@modelcontextprotocol/server';

server.registerTool('greet', {
  inputSchema: fromJsonSchema({ type: 'object', properties: { name: { type: 'string' } } })
}, handler);

Breaking changes:

  • experimental.tasks.getTaskResult() no longer accepts a resultSchema parameter. Returns GetTaskPayloadResult (a loose Result); cast to the expected type at the call site.
  • Removed unused exports from @modelcontextprotocol/core-internal: SchemaInput, schemaToJson, parseSchemaAsync, getSchemaShape, getSchemaDescription, isOptionalSchema, unwrapOptionalSchema. Use the new standardSchemaToJsonSchema and validateStandardSchema instead.
  • completable() remains Zod-specific (it relies on Zod's .shape introspection).