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
Make `Protocol` concrete and exported. `setRequestHandler`/`setNotificationHandler`/`request`/`notification` gain a 3-arg `(method: string, paramsSchema, handler)` overload for non-standard methods alongside the spec-typed form. Optional `Protocol<S extends ProtocolSpec>` generic
7
+
for declaring a typed method vocabulary. The five `assert*Capability` abstracts are now no-op virtuals (`Client`/`Server` override to enforce).
**Custom (non-standard) methods** — vendor extensions or sub-protocols whose method strings are not in the MCP spec — use the three-arg overloads of `setRequestHandler`/`setNotificationHandler`/`request`. `Protocol` is now concrete and exported, so MCP-dialect protocols can subclass it directly:
|`class X extends Protocol<Req, Notif, Res>`|`class X extends Client` (or `Server`), or compose a `Client` instance |
389
+
390
+
`notification()` keeps a single object-form signature so tests can replace it with a mock without TS overload-intersection errors. To send a custom notification, use `notification({ method: 'vendor/x', params })` (unchanged from v1).
391
+
392
+
The v1 schema's `.shape.params` becomes the `ParamsSchema` argument; the `method: z.literal('...')` value becomes the string argument.
393
+
394
+
380
395
## 10. Request Handler Context Types
381
396
382
397
`RequestHandlerExtra` → structured context types with nested groups. Rename `extra` → `ctx` in all handler callbacks.
In v1, vendor-specific methods were registered the same way as spec methods (`setRequestHandler(zodSchemaWithMethodLiteral, handler)`), and `Protocol<SendRequestT, SendNotificationT, SendResultT>` widened the send-side type unions.
388
+
389
+
In v2, `Protocol` is concrete and exported. Its `setRequestHandler`, `setNotificationHandler`, `request` and `notification` each have a string-method overload that accepts any method name with a caller-supplied params/result schema:
The `ProtocolSpec` type argument is optional — omit it for ad-hoc method strings without autocomplete. For a single vendor method on a stock `Client` or `Server`, call the three-arg overload directly: `server.setRequestHandler('acme/search', SearchParams, handler)`.
428
+
429
+
The five `assert*Capability` abstract methods are now no-op virtuals on `Protocol`, so subclasses no longer need to stub them.
430
+
385
431
### `Protocol.request()`, `ctx.mcpReq.send()`, and `Client.callTool()` no longer take a schema parameter
386
432
387
433
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
| 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