You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both packages have a **required peer dependency** on `zod` for schema validation. The SDK internally imports from `zod/v4`, but remains compatible with projects using Zod v3.25+.
42
+
Both packages have a **required peer dependency** on `zod` for schema validation. The SDK uses Zod v4.
|`@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) |
if (errorinstanceofOAuthError&&error.code===OAuthErrorCode.InvalidClient) { ... }
204
204
```
205
205
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.
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.
208
207
209
208
## 6. McpServer API Changes
210
209
211
210
The variadic `.tool()`, `.prompt()`, `.resource()` methods are removed. Use the `register*` methods with a config object.
212
211
212
+
**IMPORTANT**: v2 requires full Zod schemas — raw shapes like `{ name: z.string() }` are no longer supported. You must wrap with `z.object()`. This applies to `inputSchema`, `outputSchema`, and `argsSchema`.
213
+
213
214
### Tools
214
215
215
216
```typescript
216
-
// v1: server.tool(name, schema, callback)
217
+
// v1: server.tool(name, schema, callback) - raw shape worked
`ServerContext` convenience methods (new in v2, no v1 equivalent):
392
+
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 |
398
+
399
+
## 11. Client Behavioral Changes
360
400
361
401
`Client.listPrompts()`, `listResources()`, `listResourceTemplates()`, `listTools()` now return empty results when the server lacks the corresponding capability (instead of sending the request). Set `enforceStrictCapabilities: true` in `ClientOptions` to throw an error instead.
2. Replace all imports from `@modelcontextprotocol/sdk/...` using the import mapping tables (sections 3-4), including `StreamableHTTPServerTransport` → `NodeStreamableHTTPServerTransport`
367
427
3. Replace removed type aliases (`JSONRPCError` → `JSONRPCErrorResponse`, etc.) per section 5
368
428
4. Replace `.tool()` / `.prompt()` / `.resource()` calls with `registerTool` / `registerPrompt` / `registerResource` per section 6
369
-
5. Replace plain header objects with `new Headers({...})` and bracket access (`headers['x']`) with `.get()` calls per section 7
370
-
6. If using `hostHeaderValidation` from server, update import and signature per section 8
371
-
7. If using server SSE transport, migrate to Streamable HTTP
372
-
8. If using server auth from the SDK, migrate to an external auth library
373
-
9. If relying on `listTools()`/`listPrompts()`/etc. throwing on missing capabilities, set `enforceStrictCapabilities: true`
374
-
10. Verify: build with `tsc` / run tests
429
+
5.**Wrap all raw Zod shapes with `z.object()`**: Change `inputSchema: { name: z.string() }` → `inputSchema: z.object({ name: z.string() })`. Same for `outputSchema` in tools and `argsSchema` in prompts.
430
+
6. Replace plain header objects with `new Headers({...})` and bracket access (`headers['x']`) with `.get()` calls per section 7
431
+
7. If using `hostHeaderValidation` from server, update import and signature per section 8
432
+
8. If using server SSE transport, migrate to Streamable HTTP
433
+
9. If using server auth from the SDK, migrate to an external auth library
434
+
10. If relying on `listTools()`/`listPrompts()`/etc. throwing on missing capabilities, set `enforceStrictCapabilities: true`
0 commit comments