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
feat(core): restore v1 Zod-schema overloads on setRequestHandler/setNotificationHandler/request
Adds to Protocol (inherited by Client/Server):
- setRequestHandler/setNotificationHandler(ZodSchema, handler) — the v1 form, first-class
- request(req, resultSchema, opts?) — the v1 explicit-schema form, first-class
- callTool(params, resultSchema?, opts?) — accepts the v1 schema arg (ignored) for source compat
- removeRequestHandler/removeNotificationHandler/assertCanSetRequestHandler accept any method string
Custom (non-spec) methods work via the Zod-schema form, same as v1.
schema.ts/standardSchema.ts unchanged from main.
`setRequestHandler`/`setNotificationHandler` accept the v1 `(ZodSchema, handler)` form as a first-class alternative to `(methodString, handler)`. `request()` accepts an explicit result schema (`request(req, resultSchema, options?)`) and has a method-keyed return type for spec methods. `callTool(params, resultSchema?)` accepts the v1 schema arg (ignored). `removeRequestHandler`/`removeNotificationHandler`/`assertCanSetRequestHandler` accept any method string.
**Custom (non-standard) methods** — vendor extensions or sub-protocols whose method strings are not in the MCP spec — work on `Client`/`Server` directly using the same v1 Zod-schema form:
### `Protocol.request()`, `ctx.mcpReq.send()`, and `Client.callTool()` no longer take a schema parameter
385
+
### Custom (non-standard) protocol methods
386
386
387
-
The public `Protocol.request()`, `BaseContext.mcpReq.send()`, and `Client.callTool()` methods no longer accept a Zod result schema argument. The SDK now resolves the correct result schema internally based on the method name. This means you no longer need to import result schemas
387
+
Vendor-specific methods are registered directly on `Client` or `Server` using the same Zod-schema form as v1: `setRequestHandler(zodSchemaWithMethodLiteral, handler)`. `request({ method, params }, ResultSchema)` and `notification({ method, params })` are unchanged from v1.
388
+
389
+
```typescript
390
+
import { Server } from'@modelcontextprotocol/server';
### `Protocol.request()`, `ctx.mcpReq.send()`, and `Client.callTool()` schema parameter is now optional
401
+
402
+
The public `Protocol.request()`, `BaseContext.mcpReq.send()`, and `Client.callTool()` methods still accept a result schema argument, but for spec methods it is optional — the SDK resolves the correct schema internally from the method name. You no longer need to import result schemas
388
403
like `CallToolResultSchema` or `ElicitResultSchema` when making requests.
| Task interactive server | Task-based execution with interactive server→client requests. |[`src/simpleTaskInteractive.ts`](src/simpleTaskInteractive.ts)|
39
39
| Hono Streamable HTTP server | Streamable HTTP server built with Hono instead of Express. |[`src/honoWebStandardStreamableHttp.ts`](src/honoWebStandardStreamableHttp.ts)|
40
40
| SSE polling demo server | Legacy SSE server intended for polling demos. |[`src/ssePollingExample.ts`](src/ssePollingExample.ts)|
41
+
| Custom (non-standard) methods server | Registers `acme/*` custom request handlers and sends custom notifications. |[`src/customMethodExample.ts`](src/customMethodExample.ts)|
0 commit comments