@@ -47,15 +47,15 @@ Replace all `@modelcontextprotocol/sdk/...` imports using this table.
4747
4848### Server imports
4949
50- | v1 import path | v2 package |
51- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52- | ` @modelcontextprotocol/sdk/server/mcp.js ` | ` @modelcontextprotocol/server ` |
53- | ` @modelcontextprotocol/sdk/server/index.js ` | ` @modelcontextprotocol/server ` |
54- | ` @modelcontextprotocol/sdk/server/stdio.js ` | ` @modelcontextprotocol/server ` |
50+ | v1 import path | v2 package |
51+ | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
52+ | ` @modelcontextprotocol/sdk/server/mcp.js ` | ` @modelcontextprotocol/server ` |
53+ | ` @modelcontextprotocol/sdk/server/index.js ` | ` @modelcontextprotocol/server ` |
54+ | ` @modelcontextprotocol/sdk/server/stdio.js ` | ` @modelcontextprotocol/server ` |
5555| ` @modelcontextprotocol/sdk/server/streamableHttp.js ` | ` @modelcontextprotocol/node ` (class renamed to ` NodeStreamableHTTPServerTransport ` ) OR ` @modelcontextprotocol/server ` (web-standard ` WebStandardStreamableHTTPServerTransport ` for Cloudflare Workers, Deno, etc.) |
56- | ` @modelcontextprotocol/sdk/server/sse.js ` | REMOVED (migrate to Streamable HTTP) |
57- | ` @modelcontextprotocol/sdk/server/auth/* ` | REMOVED (use external auth library) |
58- | ` @modelcontextprotocol/sdk/server/middleware.js ` | ` @modelcontextprotocol/express ` (signature changed, see section 8) |
56+ | ` @modelcontextprotocol/sdk/server/sse.js ` | REMOVED (migrate to Streamable HTTP) |
57+ | ` @modelcontextprotocol/sdk/server/auth/* ` | REMOVED (use external auth library) |
58+ | ` @modelcontextprotocol/sdk/server/middleware.js ` | ` @modelcontextprotocol/express ` (signature changed, see section 8) |
5959
6060### Types / shared imports
6161
@@ -203,7 +203,8 @@ import { OAuthError, OAuthErrorCode } from '@modelcontextprotocol/core';
203203if (error instanceof OAuthError && error .code === OAuthErrorCode .InvalidClient ) { ... }
204204```
205205
206- ** Unchanged APIs** (only import paths changed): ` Client ` constructor and methods, ` McpServer ` constructor, ` server.connect() ` , ` server.close() ` , all client transports (` StreamableHTTPClientTransport ` , ` SSEClientTransport ` , ` StdioClientTransport ` ), ` StdioServerTransport ` , all Zod schemas, all callback return types.
206+ ** Unchanged APIs** (only import paths changed): ` Client ` constructor and methods, ` McpServer ` constructor, ` server.connect() ` , ` server.close() ` , all client transports (` StreamableHTTPClientTransport ` , ` SSEClientTransport ` , ` StdioClientTransport ` ), ` StdioServerTransport ` , all Zod
207+ schemas, all callback return types.
207208
208209## 6. McpServer API Changes
209210
@@ -279,12 +280,12 @@ Note: the third argument (`metadata`) is required — pass `{}` if no metadata.
279280
280281### Schema Migration Quick Reference
281282
282- | v1 (raw shape) | v2 (Zod schema) |
283- | ----------------| -----------------|
284- | ` { name: z.string() } ` | ` z.object({ name: z.string() }) ` |
283+ | v1 (raw shape) | v2 (Zod schema) |
284+ | ---------------------------------- | -------------------------------------------- |
285+ | ` { name: z.string() } ` | ` z.object({ name: z.string() }) ` |
285286| ` { count: z.number().optional() } ` | ` z.object({ count: z.number().optional() }) ` |
286- | ` {} ` (empty) | ` z.object({}) ` |
287- | ` undefined ` (no schema) | ` undefined ` or omit the field |
287+ | ` {} ` (empty) | ` z.object({}) ` |
288+ | ` undefined ` (no schema) | ` undefined ` or omit the field |
288289
289290## 7. Headers API
290291
@@ -370,31 +371,31 @@ Request/notification params remain fully typed. Remove unused schema imports aft
370371
371372` RequestHandlerExtra ` → structured context types with nested groups. Rename ` extra ` → ` ctx ` in all handler callbacks.
372373
373- | v1 | v2 |
374- | ----| -----|
375- | ` RequestHandlerExtra ` | ` ServerContext ` (server) / ` ClientContext ` (client) / ` BaseContext ` (base) |
376- | ` extra ` (param name) | ` ctx ` |
377- | ` extra.signal ` | ` ctx.mcpReq.signal ` |
378- | ` extra.requestId ` | ` ctx.mcpReq.id ` |
379- | ` extra._meta ` | ` ctx.mcpReq._meta ` |
380- | ` extra.sendRequest(...) ` | ` ctx.mcpReq.send(...) ` |
381- | ` extra.sendNotification(...) ` | ` ctx.mcpReq.notify(...) ` |
382- | ` extra.authInfo ` | ` ctx.http?.authInfo ` |
383- | ` extra.sessionId ` | ` ctx.sessionId ` |
384- | ` extra.requestInfo ` | ` ctx.http?.req ` (only ` ServerContext ` ) |
385- | ` extra.closeSSEStream ` | ` ctx.http?.closeSSE ` (only ` ServerContext ` ) |
386- | ` extra.closeStandaloneSSEStream ` | ` ctx.http?.closeStandaloneSSE ` (only ` ServerContext ` ) |
387- | ` extra.taskStore ` | ` ctx.task?.store ` |
388- | ` extra.taskId ` | ` ctx.task?.id ` |
389- | ` extra.taskRequestedTtl ` | ` ctx.task?.requestedTtl ` |
374+ | v1 | v2 |
375+ | -------------------------------- | -------------------------------------------------------------------------- |
376+ | ` RequestHandlerExtra ` | ` ServerContext ` (server) / ` ClientContext ` (client) / ` BaseContext ` (base) |
377+ | ` extra ` (param name) | ` ctx ` |
378+ | ` extra.signal ` | ` ctx.mcpReq.signal ` |
379+ | ` extra.requestId ` | ` ctx.mcpReq.id ` |
380+ | ` extra._meta ` | ` ctx.mcpReq._meta ` |
381+ | ` extra.sendRequest(...) ` | ` ctx.mcpReq.send(...) ` |
382+ | ` extra.sendNotification(...) ` | ` ctx.mcpReq.notify(...) ` |
383+ | ` extra.authInfo ` | ` ctx.http?.authInfo ` |
384+ | ` extra.sessionId ` | ` ctx.sessionId ` |
385+ | ` extra.requestInfo ` | ` ctx.http?.req ` (only ` ServerContext ` ) |
386+ | ` extra.closeSSEStream ` | ` ctx.http?.closeSSE ` (only ` ServerContext ` ) |
387+ | ` extra.closeStandaloneSSEStream ` | ` ctx.http?.closeStandaloneSSE ` (only ` ServerContext ` ) |
388+ | ` extra.taskStore ` | ` ctx.task?.store ` |
389+ | ` extra.taskId ` | ` ctx.task?.id ` |
390+ | ` extra.taskRequestedTtl ` | ` ctx.task?.requestedTtl ` |
390391
391392` ServerContext ` convenience methods (new in v2, no v1 equivalent):
392393
393- | Method | Description | Replaces |
394- | --------| -------------| ----------|
395- | ` ctx.mcpReq.log(level, data, logger?) ` | Send log notification (respects client's level filter) | ` server.sendLoggingMessage(...) ` from within handler |
396- | ` ctx.mcpReq.elicitInput(params, options?) ` | Elicit user input (form or URL) | ` server.elicitInput(...) ` from within handler |
397- | ` ctx.mcpReq.requestSampling(params, options?) ` | Request LLM sampling from client | ` server.createMessage(...) ` from within handler |
394+ | Method | Description | Replaces |
395+ | ---------------------------------------------- | ------------------------------------------------------ | ---------------------------------------------------- |
396+ | ` ctx.mcpReq.log(level, data, logger?) ` | Send log notification (respects client's level filter) | ` server.sendLoggingMessage(...) ` from within handler |
397+ | ` ctx.mcpReq.elicitInput(params, options?) ` | Elicit user input (form or URL) | ` server.elicitInput(...) ` from within handler |
398+ | ` ctx.mcpReq.requestSampling(params, options?) ` | Request LLM sampling from client | ` server.createMessage(...) ` from within handler |
398399
399400## 11. Client Behavioral Changes
400401
@@ -403,16 +404,20 @@ Request/notification params remain fully typed. Remove unused schema imports aft
403404## 12. Runtime-Specific JSON Schema Validators (Enhancement)
404405
405406The SDK now auto-selects the appropriate JSON Schema validator based on runtime:
407+
406408- Node.js → ` AjvJsonSchemaValidator ` (no change from v1)
407409- Cloudflare Workers (workerd) → ` CfWorkerJsonSchemaValidator ` (previously required manual config)
408410
409411** No action required** for most users. Cloudflare Workers users can remove explicit ` jsonSchemaValidator ` configuration:
410412
411413``` typescript
412414// v1 (Cloudflare Workers): Required explicit validator
413- new McpServer ({ name: ' server' , version: ' 1.0.0' }, {
414- jsonSchemaValidator: new CfWorkerJsonSchemaValidator ()
415- });
415+ new McpServer (
416+ { name: ' server' , version: ' 1.0.0' },
417+ {
418+ jsonSchemaValidator: new CfWorkerJsonSchemaValidator ()
419+ }
420+ );
416421
417422// v2 (Cloudflare Workers): Auto-selected, explicit config optional
418423new McpServer ({ name: ' server' , version: ' 1.0.0' }, {});
0 commit comments