Skip to content

Commit 7218aa2

Browse files
docs: v2 follow-up improvements
- Add v2 development notice at top of README - Fix npm badge URLs (add missing %2F encoding) - Update CONTRIBUTING.md for pnpm/corepack workflow - Document branch strategy (main vs v1.x) - Remove InMemoryEventStore from server exports (inline in test instead)
1 parent 81a8288 commit 7218aa2

File tree

3 files changed

+36
-79
lines changed

3 files changed

+36
-79
lines changed

test/helpers/src/helpers/inMemoryEventStore.ts

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

test/helpers/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './fixtures/zodTestMatrix.js';
22
export * from './helpers/http.js';
3-
export * from './helpers/inMemoryEventStore.js';
43
export * from './helpers/oauth.js';
54
export * from './helpers/tasks.js';

test/integration/test/taskResumability.test.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,43 @@ import {
88
McpServer,
99
StreamableHTTPServerTransport
1010
} from '@modelcontextprotocol/server';
11+
import type { EventStore, JSONRPCMessage } from '@modelcontextprotocol/server';
1112
import type { ZodMatrixEntry } from '@modelcontextprotocol/test-helpers';
12-
import { InMemoryEventStore, listenOnRandomPort, zodTestMatrix } from '@modelcontextprotocol/test-helpers';
13+
import { listenOnRandomPort, zodTestMatrix } from '@modelcontextprotocol/test-helpers';
14+
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+
}
1348

1449
describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
1550
const { z } = entry;

0 commit comments

Comments
 (0)