( response: Response, )
| 68 | |
| 69 | /** Read the POST's SSE body to completion and return the JSON-RPC payloads. */ |
| 70 | const 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 | |
| 87 | scenario( |
| 88 | "MCP streamable HTTP · a response beyond the DO storage value cap is delivered live (the ui:// shell resource)", |
no test coverage detected