Skip to content

Commit 9e7f4ae

Browse files
felixweinbergershellRaining
authored andcommitted
fix: v2 follow-up improvements (modelcontextprotocol#1318)
1 parent 322377a commit 9e7f4ae

File tree

5 files changed

+80
-90
lines changed

5 files changed

+80
-90
lines changed

CONTRIBUTING.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,40 @@
22

33
We welcome contributions to the Model Context Protocol TypeScript SDK! This document outlines the process for contributing to the project.
44

5+
## Branches
6+
7+
This repository has two main branches:
8+
9+
- **`main`** – v2 of the SDK (currently in development). This is a monorepo with split packages.
10+
- **`v1.x`** – stable v1 release. Bug fixes and patches for v1 should target this branch.
11+
12+
**Which branch should I use as a base?**
13+
14+
- For **new features** or **v2-related work**: base your PR on `main`
15+
- For **v1 bug fixes** or **patches**: base your PR on `v1.x`
16+
517
## Getting Started
618

19+
This project uses [pnpm](https://pnpm.io/) as its package manager. If you don't have pnpm installed, enable it via [corepack](https://nodejs.org/api/corepack.html) (included with Node.js 16.9+):
20+
21+
```bash
22+
corepack enable
23+
```
24+
25+
Then:
26+
727
1. Fork the repository
828
2. Clone your fork: `git clone https://github.com/YOUR-USERNAME/typescript-sdk.git`
9-
3. Install dependencies: `npm install`
10-
4. Build the project: `npm run build`
11-
5. Run tests: `npm test`
29+
3. Install dependencies: `pnpm install`
30+
4. Build the project: `pnpm build:all`
31+
5. Run tests: `pnpm test:all`
1232

1333
## Development Process
1434

15-
1. Create a new branch for your changes
35+
1. Create a new branch for your changes (based on `main` or `v1.x` as appropriate)
1636
2. Make your changes
17-
3. Run `npm run lint` to ensure code style compliance
18-
4. Run `npm test` to verify all tests pass
37+
3. Run `pnpm lint:all` to ensure code style compliance
38+
4. Run `pnpm test:all` to verify all tests pass
1939
5. Submit a pull request
2040

2141
## Pull Request Guidelines
@@ -28,8 +48,17 @@ We welcome contributions to the Model Context Protocol TypeScript SDK! This docu
2848

2949
## Running Examples
3050

31-
- Start the server: `npm run server`
32-
- Run the client: `npm run client`
51+
See [`examples/server/README.md`](examples/server/README.md) and [`examples/client/README.md`](examples/client/README.md) for a full list of runnable examples.
52+
53+
Quick start:
54+
55+
```bash
56+
# Run a server example
57+
pnpm --filter @modelcontextprotocol/examples-server exec tsx src/simpleStreamableHttp.ts
58+
59+
# Run a client example (in another terminal)
60+
pnpm --filter @modelcontextprotocol/examples-client exec tsx src/simpleStreamableHttp.ts
61+
```
3362

3463
## Code of Conduct
3564

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# MCP TypeScript SDK
22

3-
![NPM Version](https://img.shields.io/npm/v/%40modelcontextprotocol%server) ![NPM Version](https://img.shields.io/npm/v/%40modelcontextprotocol%client) ![MIT licensed](https://img.shields.io/npm/l/%40modelcontextprotocol%server)
3+
> [!IMPORTANT]
4+
> **This is the `main` branch which contains v2 of the SDK (currently in development, pre-alpha).**
5+
>
6+
> We anticipate a stable v2 release in Q1 2026. Until then, **v1.x remains the recommended version** for production use. v1.x will continue to receive bug fixes and security updates for at least 6 months after v2 ships to give people time to upgrade.
7+
>
8+
> For v1 documentation and code, see the [`v1.x` branch](https://github.com/modelcontextprotocol/typescript-sdk/tree/v1.x).
9+
10+
![NPM Version](https://img.shields.io/npm/v/%40modelcontextprotocol%2Fserver) ![NPM Version](https://img.shields.io/npm/v/%40modelcontextprotocol%2Fclient) ![MIT licensed](https://img.shields.io/npm/l/%40modelcontextprotocol%2Fserver)
411

512
<details>
613
<summary>Table of Contents</summary>

packages/server/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export * from './server/completable.js';
22
export * from './server/express.js';
3-
export * from './server/inMemoryEventStore.js';
43
export * from './server/mcp.js';
54
export * from './server/server.js';
65
export * from './server/sse.js';

packages/server/src/server/inMemoryEventStore.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

test/integration/test/taskResumability.test.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,48 @@ import { createServer, type Server } from 'node:http';
44
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
55
import {
66
CallToolResultSchema,
7-
InMemoryEventStore,
87
LoggingMessageNotificationSchema,
98
McpServer,
109
StreamableHTTPServerTransport
1110
} from '@modelcontextprotocol/server';
11+
import type { EventStore, JSONRPCMessage } from '@modelcontextprotocol/server';
1212
import type { ZodMatrixEntry } from '@modelcontextprotocol/test-helpers';
1313
import { listenOnRandomPort, zodTestMatrix } from '@modelcontextprotocol/test-helpers';
1414

15+
/**
16+
* Simple in-memory EventStore for testing resumability.
17+
*/
18+
class InMemoryEventStore implements EventStore {
19+
private events = new Map<string, { streamId: string; message: JSONRPCMessage }>();
20+
21+
async storeEvent(streamId: string, message: JSONRPCMessage): Promise<string> {
22+
const eventId = `${streamId}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
23+
this.events.set(eventId, { streamId, message });
24+
return eventId;
25+
}
26+
27+
async replayEventsAfter(
28+
lastEventId: string,
29+
{ send }: { send: (eventId: string, message: JSONRPCMessage) => Promise<void> }
30+
): Promise<string> {
31+
if (!lastEventId || !this.events.has(lastEventId)) return '';
32+
const streamId = lastEventId.split('_')[0] ?? '';
33+
if (!streamId) return '';
34+
35+
let found = false;
36+
const sorted = [...this.events.entries()].sort((a, b) => a[0].localeCompare(b[0]));
37+
for (const [eventId, { streamId: sid, message }] of sorted) {
38+
if (sid !== streamId) continue;
39+
if (eventId === lastEventId) {
40+
found = true;
41+
continue;
42+
}
43+
if (found) await send(eventId, message);
44+
}
45+
return streamId;
46+
}
47+
}
48+
1549
describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
1650
const { z } = entry;
1751
describe('Transport resumability', () => {

0 commit comments

Comments
 (0)