Skip to content

Commit eb5b3f5

Browse files
authored
Merge branch 'main' into fix/close-transport-on-connection-failure
2 parents e500803 + 42cb6b2 commit eb5b3f5

6 files changed

Lines changed: 51 additions & 49 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@modelcontextprotocol/server': patch
3+
'@modelcontextprotocol/client': patch
4+
---
5+
6+
Export `InMemoryTransport` for in-process testing.

README.md

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- [Overview](#overview)
1515
- [Packages](#packages)
1616
- [Installation](#installation)
17-
- [Quick Start (runnable examples)](#quick-start-runnable-examples)
17+
- [Getting Started](#getting-started)
1818
- [Documentation](#documentation)
1919
- [Contributing](#contributing)
2020
- [License](#license)
@@ -90,59 +90,53 @@ npm install @modelcontextprotocol/express express
9090
npm install @modelcontextprotocol/hono hono
9191
```
9292

93-
## Quick Start (runnable examples)
93+
## Getting Started
9494

95-
The runnable examples live under `examples/` and are kept in sync with the docs.
95+
Here is what an MCP server looks like. This minimal example exposes a single `greet` tool over stdio:
9696

97-
1. **Install dependencies** (from repo root):
97+
```typescript
98+
import { McpServer, StdioServerTransport } from '@modelcontextprotocol/server';
99+
import * as z from 'zod/v4';
98100

99-
```bash
100-
pnpm install
101-
```
102-
103-
2. **Run a Streamable HTTP example server**:
104-
105-
```bash
106-
pnpm --filter @modelcontextprotocol/examples-server exec tsx src/simpleStreamableHttp.ts
107-
```
101+
const server = new McpServer({ name: 'greeting-server', version: '1.0.0' });
108102

109-
Alternatively, from within the example package:
103+
server.registerTool(
104+
'greet',
105+
{
106+
description: 'Greet someone by name',
107+
inputSchema: z.object({ name: z.string() }),
108+
},
109+
async ({ name }) => ({
110+
content: [{ type: 'text', text: `Hello, ${name}!` }],
111+
}),
112+
);
110113

111-
```bash
112-
cd examples/server
113-
pnpm tsx src/simpleStreamableHttp.ts
114-
```
115-
116-
3. **Run the interactive client in another terminal**:
114+
async function main() {
115+
const transport = new StdioServerTransport();
116+
await server.connect(transport);
117+
}
117118

118-
```bash
119-
pnpm --filter @modelcontextprotocol/examples-client exec tsx src/simpleStreamableHttp.ts
119+
main();
120120
```
121121

122-
Alternatively, from within the example package:
122+
Ready to build something real? Follow the step-by-step quickstart tutorials:
123123

124-
```bash
125-
cd examples/client
126-
pnpm tsx src/simpleStreamableHttp.ts
127-
```
124+
- [Build a weather server](docs/server-quickstart.md) — server quickstart
125+
- [Build an LLM-powered chatbot](docs/client-quickstart.md) — client quickstart
128126

129-
Next steps:
127+
The complete code for each tutorial is in [`examples/server-quickstart/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/server-quickstart/) and [`examples/client-quickstart/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/client-quickstart/). For more advanced runnable examples, see:
130128

131-
- Server examples index: [`examples/server/README.md`](examples/server/README.md)
132-
- Client examples index: [`examples/client/README.md`](examples/client/README.md)
133-
- Guided walkthroughs: [`docs/server.md`](docs/server.md) and [`docs/client.md`](docs/client.md)
129+
- [`examples/server/README.md`](examples/server/README.md) — server examples index
130+
- [`examples/client/README.md`](examples/client/README.md) — client examples index
134131

135132
## Documentation
136133

137-
- Local SDK docs:
138-
- [docs/server.md](docs/server.md) – building MCP servers: transports, tools, resources, prompts, server-initiated requests, and deployment
139-
- [docs/client.md](docs/client.md) – building MCP clients: connecting, tools, resources, prompts, server-initiated requests, and error handling
140-
- [docs/faq.md](docs/faq.md) – frequently asked questions and troubleshooting
141-
- External references:
142-
- [SDK API documentation](https://ts.sdk.modelcontextprotocol.io/)
143-
- [Model Context Protocol documentation](https://modelcontextprotocol.io)
144-
- [MCP Specification](https://spec.modelcontextprotocol.io)
145-
- [Example Servers](https://github.com/modelcontextprotocol/servers)
134+
- [Server Guide](docs/server.md) — building MCP servers: transports, tools, resources, prompts, server-initiated requests, and deployment
135+
- [Client Guide](docs/client.md) — building MCP clients: connecting, tools, resources, prompts, server-initiated requests, and error handling
136+
- [FAQ](docs/faq.md) — frequently asked questions and troubleshooting
137+
- [API docs](https://modelcontextprotocol.github.io/typescript-sdk/)
138+
- [MCP documentation](https://modelcontextprotocol.io/docs)
139+
- [MCP specification](https://modelcontextprotocol.io/specification/latest)
146140

147141
### Building docs locally
148142

docs/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ For production use, you can either:
6767

6868
### Where can I find runnable server examples?
6969

70-
The SDK ships several runnable server examples under `examples/server/src`. Start from the server examples index in [`examples/server/README.md`](../examples/server/README.md) and the entry-point quick start in the root [`README.md`](../README.md).
70+
The [server quickstart](./server-quickstart.md) walks you through building a weather server from scratch. Its complete source lives in [`examples/server-quickstart/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/server-quickstart/). For more advanced examples (OAuth, streaming, sessions, etc.), see the server examples index in [`examples/server/README.md`](../examples/server/README.md).
7171

7272
### Why did we remove `server` auth exports?
7373

docs/migration.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -469,22 +469,20 @@ const client = new Client(
469469
);
470470
```
471471

472-
### `InMemoryTransport` removed from public API
472+
### `InMemoryTransport` moved
473473

474-
`InMemoryTransport` has been removed from the public API surface. It was previously used for in-process client-server connections and testing.
475-
476-
For **testing**, import it directly from the internal core package:
474+
`InMemoryTransport` is now exported from `@modelcontextprotocol/client` and `@modelcontextprotocol/server` (both re-export it). It is still intended for in-process client-server connections and testing.
477475

478476
```typescript
479477
// v1
480478
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
481479

482-
// v2 (testing only — @modelcontextprotocol/core is internal, not for production use)
483-
import { InMemoryTransport } from '@modelcontextprotocol/core';
480+
// v2
481+
import { InMemoryTransport } from '@modelcontextprotocol/server';
482+
// or
483+
import { InMemoryTransport } from '@modelcontextprotocol/client';
484484
```
485485

486-
For **production in-process connections**, use `StreamableHTTPClientTransport` with a local server URL, or connect client and server via paired streams.
487-
488486
### Removed type aliases and deprecated exports
489487

490488
The following deprecated type aliases have been removed from `@modelcontextprotocol/core`:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export { deserializeMessage, ReadBuffer, serializeMessage } from '../../shared/s
7070
// Transport types (NOT normalizeHeaders)
7171
export type { FetchLike, Transport, TransportSendOptions } from '../../shared/transport.js';
7272
export { createFetchWithInit } from '../../shared/transport.js';
73+
export { InMemoryTransport } from '../../util/inMemory.js';
7374

7475
// URI Template
7576
export type { Variables } from '../../shared/uriTemplate.js';

packages/core/src/util/inMemory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ interface QueuedMessage {
99

1010
/**
1111
* In-memory transport for creating clients and servers that talk to each other within the same process.
12+
*
13+
* Intended for testing and development. For production in-process connections, use
14+
* `StreamableHTTPClientTransport` against a local server URL.
1215
*/
1316
export class InMemoryTransport implements Transport {
1417
private _otherTransport?: InMemoryTransport;

0 commit comments

Comments
 (0)