Skip to content

Commit 26b1ddc

Browse files
fix(core): export InMemoryTransport, tighten migration docs
InMemoryTransport was unreachable: the migration doc said to import it from @modelcontextprotocol/core, but core is private (no exports field, no dist). Adding it to core/public makes it available via the server/client re-exports. migration.md: - Rewrite the InMemoryTransport section to match the new export reality (was: 'removed from public API, import from internal core' — neither half of that worked) - Add SSE-to-StreamableHTTP before/after example - Method-string table: add tasks/get, tasks/result, notifications/elicitation/complete - Mention callToolStream() in the schema-removal section header migration-SKILL.md: - Fix 'core is installed automatically as a dependency' (it's internal) - Add the same method-string rows
1 parent babaa50 commit 26b1ddc

File tree

3 files changed

+67
-10
lines changed

3 files changed

+67
-10
lines changed

docs/migration-SKILL.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ npm uninstall @modelcontextprotocol/sdk
2828
| Server + Express | `npm install @modelcontextprotocol/server @modelcontextprotocol/express` |
2929
| Server + Hono | `npm install @modelcontextprotocol/server @modelcontextprotocol/hono` |
3030

31-
`@modelcontextprotocol/core` is installed automatically as a dependency.
31+
`@modelcontextprotocol/core` is an internal package — never install or import it directly. Both `@modelcontextprotocol/client` and `@modelcontextprotocol/server` re-export everything you need.
3232

3333
## 3. Import Mapping
3434

@@ -373,6 +373,9 @@ Schema to method string mapping:
373373
| `PromptListChangedNotificationSchema` | `'notifications/prompts/list_changed'` |
374374
| `ProgressNotificationSchema` | `'notifications/progress'` |
375375
| `CancelledNotificationSchema` | `'notifications/cancelled'` |
376+
| `GetTaskRequestSchema` | `'tasks/get'` |
377+
| `GetTaskPayloadRequestSchema` | `'tasks/result'` |
378+
| `ElicitationCompleteNotificationSchema` | `'notifications/elicitation/complete'` |
376379
| `InitializedNotificationSchema` | `'notifications/initialized'` |
377380

378381
Request/notification params remain fully typed. Remove unused schema imports after migration.
@@ -407,9 +410,9 @@ Request/notification params remain fully typed. Remove unused schema imports aft
407410
| `ctx.mcpReq.elicitInput(params, options?)` | Elicit user input (form or URL) | `server.elicitInput(...)` from within handler |
408411
| `ctx.mcpReq.requestSampling(params, options?)` | Request LLM sampling from client | `server.createMessage(...)` from within handler |
409412

410-
## 11. Schema parameter removed from `request()`, `send()`, and `callTool()`
413+
## 11. Schema parameter removed from `request()`, `send()`, `callTool()`, and `callToolStream()`
411414

412-
`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.
415+
`Protocol.request()`, `BaseContext.mcpReq.send()`, `Client.callTool()`, and `client.experimental.tasks.callToolStream()` no longer take a Zod result schema argument. The SDK resolves the schema internally from the method name.
413416

414417
```typescript
415418
// v1: schema required
@@ -428,6 +431,7 @@ const tool = await client.callTool({ name: 'my-tool', arguments: {} });
428431
| ------------------------------------------------------------ | ---------------------------------- |
429432
| `client.request(req, ResultSchema)` | `client.request(req)` |
430433
| `client.request(req, ResultSchema, options)` | `client.request(req, options)` |
434+
| `client.experimental.tasks.callToolStream(params, ResultSchema, options?)` | `client.experimental.tasks.callToolStream(params, options?)` |
431435
| `ctx.mcpReq.send(req, ResultSchema)` | `ctx.mcpReq.send(req)` |
432436
| `ctx.mcpReq.send(req, ResultSchema, options)` | `ctx.mcpReq.send(req, options)` |
433437
| `client.callTool(params, CompatibilityCallToolResultSchema)` | `client.callTool(params)` |

docs/migration.md

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,36 @@ const transport = new NodeStreamableHTTPServerTransport({ sessionIdGenerator: ()
110110

111111
The SSE transport has been removed from the server. Servers should migrate to Streamable HTTP. The client-side SSE transport remains available for connecting to legacy SSE servers.
112112

113+
**Before (v1):**
114+
115+
```typescript
116+
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
117+
118+
let transport: SSEServerTransport;
119+
120+
app.get('/sse', async (req, res) => {
121+
transport = new SSEServerTransport('/messages', res);
122+
await server.connect(transport);
123+
});
124+
app.post('/messages', async (req, res) => {
125+
await transport.handlePostMessage(req, res);
126+
});
127+
```
128+
129+
**After (v2, stateless):**
130+
131+
```typescript
132+
import { NodeStreamableHTTPServerTransport } from '@modelcontextprotocol/node';
133+
134+
app.all('/mcp', async (req, res) => {
135+
const transport = new NodeStreamableHTTPServerTransport({ sessionIdGenerator: undefined });
136+
await server.connect(transport);
137+
await transport.handleRequest(req, res);
138+
});
139+
```
140+
141+
With `sessionIdGenerator: undefined` the transport runs in stateless mode, so creating a fresh instance per request is correct. For stateful sessions, the transport must be created once per session and stored in a `Map<string, NodeStreamableHTTPServerTransport>` keyed by session ID — see `examples/server/src/simpleStreamableHttp.ts` for the full pattern.
142+
113143
### `WebSocketClientTransport` removed
114144

115145
`WebSocketClientTransport` has been removed. WebSocket is not a spec-defined MCP transport, and keeping it in the SDK encouraged transport proliferation without a conformance baseline.
@@ -381,10 +411,14 @@ Common method string replacements:
381411
| `ToolListChangedNotificationSchema` | `'notifications/tools/list_changed'` |
382412
| `ResourceListChangedNotificationSchema` | `'notifications/resources/list_changed'` |
383413
| `PromptListChangedNotificationSchema` | `'notifications/prompts/list_changed'` |
414+
| `GetTaskRequestSchema` | `'tasks/get'` |
415+
| `GetTaskPayloadRequestSchema` | `'tasks/result'` |
416+
| `ElicitationCompleteNotificationSchema` | `'notifications/elicitation/complete'` |
417+
| `InitializedNotificationSchema` | `'notifications/initialized'` |
384418

385419
### `Protocol.request()`, `ctx.mcpReq.send()`, and `Client.callTool()` no longer take a schema parameter
386420

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
421+
The public `Protocol.request()`, `BaseContext.mcpReq.send()`, `Client.callTool()`, and `client.experimental.tasks.callToolStream()` 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
388422
like `CallToolResultSchema` or `ElicitResultSchema` when making requests.
389423

390424
**`client.request()` — Before (v1):**
@@ -440,6 +474,24 @@ const result = await client.callTool({ name: 'my-tool', arguments: {} }, Compati
440474
const result = await client.callTool({ name: 'my-tool', arguments: {} });
441475
```
442476

477+
**`client.experimental.tasks.callToolStream()` — Before (v1):**
478+
479+
```typescript
480+
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
481+
482+
for await (const event of client.experimental.tasks.callToolStream({ name: 'my-tool', arguments: {} }, CallToolResultSchema)) {
483+
// ...
484+
}
485+
```
486+
487+
**After (v2):**
488+
489+
```typescript
490+
for await (const event of client.experimental.tasks.callToolStream({ name: 'my-tool', arguments: {} })) {
491+
// ...
492+
}
493+
```
494+
443495
The return type is now inferred from the method name via `ResultTypeMap`. For example, `client.request({ method: 'tools/call', ... })` returns `Promise<CallToolResult | CreateTaskResult>`.
444496

445497
### Client list methods return empty results for missing capabilities
@@ -459,19 +511,17 @@ const client = new Client(
459511

460512
### `InMemoryTransport` removed from public API
461513

462-
`InMemoryTransport` has been removed from the public API surface. It was previously used for in-process client-server connections and testing.
463-
464-
For **testing**, import it directly from the internal core package:
514+
`InMemoryTransport` is intended for testing client/server interactions within a single process. It is re-exported from both `@modelcontextprotocol/server` and `@modelcontextprotocol/client`.
465515

466516
```typescript
467517
// v1
468518
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
469519

470-
// v2 (testing only — @modelcontextprotocol/core is internal, not for production use)
471-
import { InMemoryTransport } from '@modelcontextprotocol/core';
520+
// v2
521+
import { InMemoryTransport } from '@modelcontextprotocol/server';
472522
```
473523

474-
For **production in-process connections**, use `StreamableHTTPClientTransport` with a local server URL, or connect client and server via paired streams.
524+
For **production in-process connections**, prefer `StreamableHTTPClientTransport` with a local server URL.
475525

476526
### Removed type aliases and deprecated exports
477527

packages/core/src/exports/public/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export { deserializeMessage, ReadBuffer, serializeMessage } from '../../shared/s
6969

7070
// Transport types (NOT normalizeHeaders)
7171
export type { FetchLike, Transport, TransportSendOptions } from '../../shared/transport.js';
72+
73+
// In-memory transport (for testing client/server in the same process)
74+
export { InMemoryTransport } from '../../util/inMemory.js';
7275
export { createFetchWithInit } from '../../shared/transport.js';
7376

7477
// URI Template

0 commit comments

Comments
 (0)