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
Add custom (non-spec) method support: a 3-arg `setRequestHandler(method, schemas, handler)` / `setNotificationHandler(method, schemas, handler)` form for vendor-prefixed methods, and a `request(req, resultSchema)` overload (also on `ctx.mcpReq.send`) for typed custom-method results. Spec-method calls are unchanged.
8
+
9
+
Response result-schema validation failure now rejects with `SdkError(InvalidResult)` instead of a raw `ZodError`. Adds `SdkErrorCode.InvalidResult`.
|`ctx.mcpReq.elicitInput(params, options?)`| Elicit user input (form or URL) |`server.elicitInput(...)` from within handler |
407
431
|`ctx.mcpReq.requestSampling(params, options?)`| Request LLM sampling from client |`server.createMessage(...)` from within handler |
408
432
409
-
## 11. Schema parameter removed from `request()`, `send()`, and `callTool()`
433
+
## 11. Schema parameter removed from `request()`, `send()`, and `callTool()` (spec methods)
410
434
411
-
`Protocol.request()`, `BaseContext.mcpReq.send()`, and `Client.callTool()` no longer take a Zod result schema argument. The SDK resolves the schema internally from the method name.
435
+
For **spec** methods, `Protocol.request()`, `BaseContext.mcpReq.send()`, and `Client.callTool()` no longer require a Zod result schema argument. The SDK resolves the schema internally from the method name.
For **custom (non-spec)** methods, keep the result-schema argument — see §9. Only apply the rewrites above when `req.method` is a spec method.
460
+
435
461
Remove unused schema imports: `CallToolResultSchema`, `CompatibilityCallToolResultSchema`, `ElicitResultSchema`, `CreateMessageResultSchema`, etc., when they were only used in `request()`/`send()`/`callTool()` calls.
436
462
437
463
If `CallToolResultSchema` was used for **runtime validation** (not just as a `request()` argument), replace with the `isCallToolResult` type guard:
The request and notification parameters remain fully typed via `RequestTypeMap` and `NotificationTypeMap`. You no longer need to import the individual `*RequestSchema` or `*NotificationSchema` constants for handler registration.
368
368
369
+
#### Custom (non-spec) methods
370
+
371
+
For vendor-prefixed methods (anything not in the MCP spec), use the 3-arg form: pass the method string, a `{ params, result? }` schemas object, and the handler. Any [Standard Schema](https://standardschema.dev) library works (Zod, Valibot, ArkType).
The handler receives the parsed `params` directly (not the full request envelope). `_meta` is stripped before validation and is available as `ctx.mcpReq._meta`. Supplying `result` types the handler's return value; omit it to return any `Result`.
397
+
398
+
For `setNotificationHandler`, the 3-arg handler is `(params, notification) => void`. The raw notification is the second argument, so `_meta` is recoverable via `notification.params?._meta`.
399
+
400
+
#### Sending custom-method requests
401
+
402
+
`request()` and `ctx.mcpReq.send()` accept a result schema as the second argument; for custom methods this is required:
### `Protocol.request()`, `ctx.mcpReq.send()`, and `Client.callTool()` no longer take a schema parameter
429
+
### `Protocol.request()`, `ctx.mcpReq.send()`, and `Client.callTool()` no longer require a schema parameter for spec methods
388
430
389
-
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
390
-
like `CallToolResultSchema` or `ElicitResultSchema` when making requests.
431
+
For **spec** methods, the public `Protocol.request()`, `BaseContext.mcpReq.send()`, and `Client.callTool()` methods no longer require 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
432
+
like `CallToolResultSchema` or `ElicitResultSchema` when making spec-method requests.
The return type is now inferred from the method name via `ResultTypeMap`. For example, `client.request({ method: 'tools/call', ... })` returns `Promise<CallToolResult | CreateTaskResult>`.
446
488
489
+
For **custom (non-spec)** methods, keep the result-schema argument — see [Sending custom-method requests](#sending-custom-method-requests). Only drop the schema when calling a spec method.
490
+
447
491
If you were using `CallToolResultSchema` for **runtime validation** (not just in `request()`/`callTool()` calls), use the new `isCallToolResult` type guard instead:
448
492
449
493
```typescript
@@ -658,6 +702,7 @@ The new `SdkErrorCode` enum contains string-valued codes for local SDK errors:
658
702
|`SdkErrorCode.RequestTimeout`| Request timed out waiting for response |
659
703
|`SdkErrorCode.ConnectionClosed`| Connection was closed |
660
704
|`SdkErrorCode.SendFailed`| Failed to send message |
705
+
|`SdkErrorCode.InvalidResult`| Response result failed local schema validation |
661
706
|`SdkErrorCode.ClientHttpNotImplemented`| HTTP POST request failed |
662
707
|`SdkErrorCode.ClientHttpAuthentication`| Server returned 401 after re-authentication |
663
708
|`SdkErrorCode.ClientHttpForbidden`| Server returned 403 after trying upscoping |
0 commit comments