MCPcopy Create free account
hub / github.com/modelcontextprotocol/typescript-sdk / readAllSSEEvents

Function readAllSSEEvents

test/server/sse.test.ts:57–78  ·  view source on GitHub ↗
(response: Response)

Source from the content-addressed store, hash-verified

55};
56
57async function readAllSSEEvents(response: Response): Promise<string[]> {
58 const reader = response.body?.getReader();
59 if (!reader) throw new Error('No readable stream');
60
61 const events: string[] = [];
62 const decoder = new TextDecoder();
63
64 try {
65 while (true) {
66 const { done, value } = await reader.read();
67 if (done) break;
68
69 if (value) {
70 events.push(decoder.decode(value));
71 }
72 }
73 } finally {
74 reader.releaseLock();
75 }
76
77 return events;
78}
79
80/**
81 * Helper to send JSON-RPC request

Callers 1

initializeServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…