MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / readSseMessages

Function readSseMessages

e2e/cloud/mcp-oversize-response.test.ts:70–85  ·  view source on GitHub ↗
(
  response: Response,
)

Source from the content-addressed store, hash-verified

68
69/** Read the POST's SSE body to completion and return the JSON-RPC payloads. */
70const readSseMessages = async (
71 response: Response,
72): Promise<ReadonlyArray<{ readonly id?: unknown; readonly result?: unknown }>> => {
73 const text = await response.text();
74 const messages: Array<{ readonly id?: unknown; readonly result?: unknown }> = [];
75 for (const block of text.replace(/\r/g, "").split("\n\n")) {
76 const data = block
77 .split("\n")
78 .filter((line) => line.startsWith("data:"))
79 .map((line) => line.slice("data:".length).trimStart())
80 .join("\n")
81 .trim();
82 if (data) messages.push(JSON.parse(data) as { readonly id?: unknown });
83 }
84 return messages;
85};
86
87scenario(
88 "MCP streamable HTTP · a response beyond the DO storage value cap is delivered live (the ui:// shell resource)",

Callers 1

Calls 3

pushMethod · 0.80
textMethod · 0.65
replaceMethod · 0.65

Tested by

no test coverage detected