Skip to content

Commit 90fbcd9

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 90fbcd9

File tree

3 files changed

+37
-79
lines changed

3 files changed

+37
-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: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,48 @@ import { createServer, type Server } from 'node:http';
44
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
55
import {
66
CallToolResultSchema,
7+
type EventStore,
8+
type JSONRPCMessage,
79
LoggingMessageNotificationSchema,
810
McpServer,
911
StreamableHTTPServerTransport
1012
} from '@modelcontextprotocol/server';
1113
import type { ZodMatrixEntry } from '@modelcontextprotocol/test-helpers';
12-
import { InMemoryEventStore, listenOnRandomPort, zodTestMatrix } from '@modelcontextprotocol/test-helpers';
14+
import { listenOnRandomPort, zodTestMatrix } from '@modelcontextprotocol/test-helpers';
15+
16+
/**
17+
* Simple in-memory EventStore for testing resumability.
18+
*/
19+
class InMemoryEventStore implements EventStore {
20+
private events = new Map<string, { streamId: string; message: JSONRPCMessage }>();
21+
22+
async storeEvent(streamId: string, message: JSONRPCMessage): Promise<string> {
23+
const eventId = `${streamId}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
24+
this.events.set(eventId, { streamId, message });
25+
return eventId;
26+
}
27+
28+
async replayEventsAfter(
29+
lastEventId: string,
30+
{ send }: { send: (eventId: string, message: JSONRPCMessage) => Promise<void> }
31+
): Promise<string> {
32+
if (!lastEventId || !this.events.has(lastEventId)) return '';
33+
const streamId = lastEventId.split('_')[0] ?? '';
34+
if (!streamId) return '';
35+
36+
let found = false;
37+
const sorted = [...this.events.entries()].sort((a, b) => a[0].localeCompare(b[0]));
38+
for (const [eventId, { streamId: sid, message }] of sorted) {
39+
if (sid !== streamId) continue;
40+
if (eventId === lastEventId) {
41+
found = true;
42+
continue;
43+
}
44+
if (found) await send(eventId, message);
45+
}
46+
return streamId;
47+
}
48+
}
1349

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

0 commit comments

Comments
 (0)