Co-authored-by: Matt <77928207+mattzcarey@users.noreply.github.com> Co-authored-by: Konstantin Konstantinov <KKonstantinov@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
24 KiB
@modelcontextprotocol/server
2.0.0-alpha.3
Major Changes
- #2128
c8d7401Thanks @felixweinberger! - SEP-2663: remove 2025-11 experimental tasks (TaskManager, experimental.tasks.* accessors). Tasks are now Extensions Track.
Minor Changes
-
#1974
db83829Thanks @felixweinberger! - Add custom (non-spec) method support: a 3-argsetRequestHandler(method, schemas, handler)/setNotificationHandler(method, schemas, handler)form for vendor-prefixed methods, and arequest(req, resultSchema)overload (also onctx.mcpReq.send) for typed custom-method results. Spec-method calls are unchanged.Response result-schema validation failure now rejects with
SdkError(InvalidResult)instead of a rawZodError. AddsSdkErrorCode.InvalidResult. -
#2353
c59dc3aThanks @KKonstantinov! - Supporticonson the high-levelMcpServer.registerTool()andregisterPrompt()config objects (and on theirupdate()methods). Tool and prompt icons now surface intools/listandprompts/list. Resource, resource-template, and server-info (Implementation) icons already passed through. This closes the gap with the MCP spec, which allowsiconson tools, resources, resource templates, and prompts. -
#2354
0fb8406Thanks @KKonstantinov! - Add the v2IdJagTokenExchangeResponsetype to the public API and register its schema as an MCP spec type.IdJagTokenExchangeResponseis now exported from@modelcontextprotocol/clientand@modelcontextprotocol/server,'IdJagTokenExchangeResponse'joins theSpecTypeNameunion, andisSpecType.IdJagTokenExchangeResponse(value)/specTypeSchemas.IdJagTokenExchangeResponsevalidate it by name — matching how the OAuth/OpenID auth schemas are already exposed. The Zod schema itself,IdJagTokenExchangeResponseSchema, is available from@modelcontextprotocol/core. -
#2248
db28156Thanks @felixweinberger! - Restore the 2025-11-25 task wire types that were removed together with the task feature: the task schemas and inferred types, task members of the request/result/notification unions, thetaskrequest-params augmentation, thetaskscapability key, theisTaskAugmentedRequestParamsguard, andRELATED_TASK_META_KEY. The task feature itself remains removed — servers do not advertise thetaskscapability and inboundtasks/*requests receive-32601— but the wire surface stays so SDKs interoperate cleanly with peers on the 2025-11-25 revision. -
#1887
96db044Thanks @felixweinberger! - ExportisSpecTypeandspecTypeSchemasrecords for runtime validation of any MCP spec type by name.isSpecType.ContentBlock(value)is a type predicate;specTypeSchemas.ContentBlockis aStandardSchemaV1Sync<ContentBlock>validator —validate()returns the result synchronously. Guards are standalone functions, soarr.filter(isSpecType.ContentBlock)works. Also export theSpecTypeName,SpecTypes, andStandardSchemaV1Synctypes. -
#1871
9fc9070Thanks @felixweinberger! - Move stdio transports to a./stdiosubpath export. ImportStdioClientTransport,getDefaultEnvironment,DEFAULT_INHERITED_ENV_VARS, andStdioServerParametersfrom@modelcontextprotocol/client/stdio, andStdioServerTransportfrom@modelcontextprotocol/server/stdio. The@modelcontextprotocol/clientroot entry no longer pulls innode:child_process,node:stream, orcross-spawn, fixing bundling for browser and Cloudflare Workers targets; the@modelcontextprotocol/serverroot entry drops itsnode:streamreference. Node.js, Bun, and Deno consumers update the import path; runtime behavior is unchanged.
Patch Changes
-
#2280
e8c7180Thanks @felixweinberger! - Bound the protocol-version checks gating SSE resumability behavior (priming events andcloseSSEStreamcallbacks) in the Streamable HTTP server transport. Previously an open-ended>= '2025-11-25'comparison let unknown future protocol version strings from aninitializerequest body enable this behavior; the version must now also be one of the transport's supported protocol versions. Behavior for all currently supported protocol versions is unchanged. -
#1897
434b2f1Thanks @felixweinberger! - Stop bundling@cfworker/json-schemainto the main package barrel. PreviouslyCfWorkerJsonSchemaValidatorwas re-exported from the core internal barrel, so tsdown inlined the@cfworker/json-schemadependency into every consumer's bundle even when it was never used. The named validator classes are now reachable only via the explicit@modelcontextprotocol/{client,server}/validators/{ajv,cf-worker}subpaths and the runtime_shimsconditional, so consumers that import only from the root entry point no longer ship the validator dep. -
#2269
e84c3e9Thanks @mattzcarey! - Non-SEP draft spec conformance fixesMcpServernow eagerly installs list/read/call handlers for every primitive capability (tools,resources,prompts) declared inServerOptions.capabilities. Per the draft spec, a server that declares a capability MUST respond to its list method (potentially with an empty result) instead of returning "Method not found". Previously, handlers were only installed lazily on first registration, so a server constructed with e.g.capabilities: { tools: {} }and zero registered tools answeredtools/listwith-32601. Low-levelServerusers remain responsible for registering handlers for declared capabilities (documented onServerOptions.capabilities).- Fixed pagination doc examples on
Client.listTools/listPrompts/listResourcesto loopwhile (cursor !== undefined)instead ofwhile (cursor)— per the draft spec, clients MUST NOT treat an empty-string cursor as the end of results.
-
#1834
42cb6b2Thanks @felixweinberger! - ExportInMemoryTransportfor in-process testing. -
#1788
df4b6ccThanks @claygeo! - Prevent stack overflow in StreamableHTTPServerTransport.close() with re-entrant guard -
#1855
2c0c481Thanks @Christian-Sidak! - Add| undefinedto optional callback and function properties onWebStandardStreamableHTTPServerTransportOptions(sessionIdGenerator,onsessioninitialized,onsessionclosed) and corresponding private fields.This fixes TS2430 errors for consumers using
exactOptionalPropertyTypes: truewithoutskipLibCheck, where optional properties with function types need explicit| undefinedto match their emitted declarations. -
#1898
2a7611dThanks @felixweinberger! - Add top-leveltypesfield (andtypesVersionson client/server for their subpath exports) so consumers on legacymoduleResolution: "node"can resolve type declarations. Theexportsmap remains the source of truth fornodenext/bundlerresolution. ThetypesVersionsmap includes entries for subpaths added by sibling PRs in this series (zod-schemas,stdio); those entries are no-ops until the correspondingdist/*.d.mtsfiles exist. -
#1901
e15a8efThanks @felixweinberger! -registerTool/registerPromptaccept a raw Zod shape ({ field: z.string() }) forinputSchema/outputSchema/argsSchemain addition to a wrapped Standard Schema. Raw shapes are auto-wrapped withz.object(). The raw-shape overloads are@deprecated; prefer wrapping withz.object().Also widens the
completable()constraint fromStandardSchemaWithJSONtoStandardSchemaV1so v1'scompletable(z.string(), fn)continues to work. -
#2268
49c0a71Thanks @mattzcarey! - Mark the roots, sampling, and logging runtime APIs as@deprecatedper SEP-2577 (deprecated as of protocol version 2026-07-28; functional for at least twelve months). AnnotatesServer.createMessage/listRoots/sendLoggingMessage,McpServer.sendLoggingMessage,Client.setLoggingLevel/sendRootsListChanged, theServerContext.mcpReq.log/requestSamplinghelpers, and theroots/sampling/loggingcapability schema fields. JSDoc/docs only — no behavior change. -
#2275
1b53a41Thanks @KKonstantinov! - Add a configurablemaxBufferSize(default 10 MB) to the stdio transports. When a single message would push the read buffer past the limit, the transport now emits anonerrorand closes instead of growing the buffer unbounded. Configure vianew StdioClientTransport({ ..., maxBufferSize })ornew StdioServerTransport(stdin, stdout, { maxBufferSize }). The default is exported from@modelcontextprotocol/client/@modelcontextprotocol/serverasSTDIO_DEFAULT_MAX_BUFFER_SIZE. -
#2088
16d13abThanks @mattzcarey! - Bundle automatic JSON Schema validator defaults in@modelcontextprotocol/clientand@modelcontextprotocol/serverruntime shims.Client and server pick the right validator automatically based on the runtime: the Node shim uses AJV, the browser/workerd shim uses
@cfworker/json-schema. Both backends are bundled into the shim chunks that select them, so the default code path needs no extra installs —import { McpServer } from '@modelcontextprotocol/server'does not pullajvor@cfworker/json-schemainto the root entry chunk.The named validator classes remain part of the public surface for consumers who want to customize the built-in backend (pre-register schemas by
$id, register custom AJV formats, switch dialects, change@cfworker/json-schemadraft). They are exposed through explicit subpaths so they do not bloat the root index chunk:import { AjvJsonSchemaValidator } from '@modelcontextprotocol/{client,server}/validators/ajv'import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/{client,server}/validators/cf-worker'
Importing from one of these subpaths means the corresponding peer dep (
ajv+ajv-formats, or@cfworker/json-schema) must be in yourpackage.json. The shim keeps its own vendored copy for the default path, so a project can use the subpath in some files and rely on the default in others.The
jsonSchemaValidatorinterface remains the public extension point for replacing validation entirely with a custom implementation. -
#1976
55b1f06Thanks @felixweinberger! - refactor: subclasses override_wrapHandlerhook instead of redeclaringsetRequestHandler. -
#1895
b256546Thanks @felixweinberger! - Fix runtime crash ontools/listwhen a tool'sinputSchemacomes from zod 4.0–4.1. The SDK requires~standard.jsonSchema(StandardJSONSchemaV1, added in zod 4.2.0); previously a missingjsonSchemacrashed atundefined[io].standardSchemaToJsonSchemanow detects zod 4 schemas lackingjsonSchemaand falls back to the SDK-bundledz.toJSONSchema(), emitting a one-time console warning. zod 3 schemas (which the bundled zod 4 converter cannot introspect) and non-zod schema libraries withoutjsonSchemaget a clear error pointing tofromJsonSchema(). The workspace zod catalog is also bumped to^4.2.0.
2.0.0-alpha.2
Patch Changes
- #1840
424cbaeThanks @KKonstantinov! - tsdown exports resolution fix
2.0.0-alpha.1
Major Changes
-
#1389
108f2f3Thanks @DePasqualeOrg! - Fix error handling for unknown tools and resources per MCP spec.Tools: Unknown or disabled tool calls now return JSON-RPC protocol errors with code
-32602(InvalidParams) instead ofCallToolResultwithisError: true. Callers who checkedresult.isErrorfor unknown tools should catch rejected promises instead.Resources: Unknown resource reads now return error code
-32002(ResourceNotFound) instead of-32602(InvalidParams).Added
ProtocolErrorCode.ResourceNotFound.
Minor Changes
-
#1673
462c3fcThanks @KKonstantinov! - refactor: extract task orchestration from Protocol into TaskManagerBreaking changes:
taskStore,taskMessageQueue,defaultTaskPollInterval, andmaxTaskQueueSizemoved fromProtocolOptionstocapabilities.tasksonClientOptions/ServerOptions
-
#1689
0784be1Thanks @felixweinberger! - Support Standard Schema for tool and prompt schemasTool and prompt registration now accepts any schema library that implements the Standard Schema spec: Zod v4, Valibot, ArkType, and others.
RegisteredTool.inputSchema,RegisteredTool.outputSchema, andRegisteredPrompt.argsSchemanow useStandardSchemaWithJSON(requires both~standard.validateand~standard.jsonSchema) instead of the Zod-specificAnySchematype.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
fromJsonSchemaadapter:import { fromJsonSchema } from '@modelcontextprotocol/server'; import { AjvJsonSchemaValidator } from '@modelcontextprotocol/server/validators/ajv'; server.registerTool( 'greet', { inputSchema: fromJsonSchema({ type: 'object', properties: { name: { type: 'string' } } }, new AjvJsonSchemaValidator()) }, handler );Breaking changes:
experimental.tasks.getTaskResult()no longer accepts aresultSchemaparameter. ReturnsGetTaskPayloadResult(a looseResult); 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 newstandardSchemaToJsonSchemaandvalidateStandardSchemainstead. completable()remains Zod-specific (it relies on Zod's.shapeintrospection).
Patch Changes
-
#1758
e86b183Thanks @KKonstantinov! - tasks - disallow requesting a null TTL -
#1363
0a75810Thanks @DevJanderson! - Fix ReDoS vulnerability in UriTemplate regex patterns (CVE-2026-0621) -
#1372
3466a9eThanks @mattzcarey! - missing change for fix(client): replace body.cancel() with text() to prevent hanging -
#1824
fcde488Thanks @felixweinberger! - DropzodfrompeerDependencies(kept as direct dependency)Since Standard Schema support landed,
zodis purely an internal runtime dependency used for protocol message parsing. User-facing schemas (registerTool,registerPrompt) accept any Standard Schema library.zodremains independenciesand auto-installs; users no longer need to install it alongside the SDK. -
#1761
01954e6Thanks @felixweinberger! - Convert remaining capability-assertion throws toSdkError(SdkErrorCode.CapabilityNotSupported, ...). Follow-up to #1454 which missedClient.assertCapability(), the task capability helpers inexperimental/tasks/helpers.ts, and the sampling/elicitation capability checks inexperimental/tasks/server.ts. -
#1433
78bae74Thanks @codewithkenzo! - Fix transport errors being silently swallowed by adding missingonerrorcallback invocations before allcreateJsonErrorResponsecalls inWebStandardStreamableHTTPServerTransport. This ensures errors like parse failures, invalid headers, and session validation errors are properly reported via theonerrorcallback. -
#1660
689148dThanks @rechedev9! - fix(server): propagate negotiated protocol version to transport in _oninitialize -
#1568
f1ade75Thanks @stakeswky! - Handle stdout errors (e.g. EPIPE) inStdioServerTransportgracefully instead of crashing. When the client disconnects abruptly, the transport now catches the stdout error, surfaces it viaonerror, and closes. -
#1419
dcf708dThanks @KKonstantinov! - remove deprecated .tool, .prompt, .resource method signatures -
#1388
f66a55bThanks @mattzcarey! - reverting application/json in notifications -
#1534
69a0626Thanks @josefaidt! - remove npm references, use pnpm -
#1534
69a0626Thanks @josefaidt! - clean up package manager usage, all pnpm -
#1419
dcf708dThanks @KKonstantinov! - deprecated .tool, .prompt, .resource method removal -
#1279
71ae3acThanks @KKonstantinov! - Initial 2.0.0-alpha.0 client and server package