(mcpUrl: string, bearer: string, sessionId: string)
| 84 | /** A raw SSE GET (the "listen" stream) on an existing session id. We only need |
| 85 | * the response head — status + start of body — to see whether it 500s. */ |
| 86 | const rawSseGet = async (mcpUrl: string, bearer: string, sessionId: string): Promise<RawResult> => { |
| 87 | const res = await fetch(mcpUrl, { |
| 88 | method: "GET", |
| 89 | headers: { |
| 90 | authorization: `Bearer ${bearer}`, |
| 91 | accept: "text/event-stream", |
| 92 | "mcp-session-id": sessionId, |
| 93 | "mcp-protocol-version": "2025-06-18", |
| 94 | }, |
| 95 | }); |
| 96 | // A 200 opens a long-lived stream; don't hang reading it. A 500 has a short |
| 97 | // (usually empty) body we can read fully. |
| 98 | let body = ""; |
| 99 | if (res.status !== 200) { |
| 100 | body = await res.text().catch(() => ""); |
| 101 | } else { |
| 102 | // Cancel the stream immediately; we only wanted the status. |
| 103 | await res.body?.cancel().catch(() => undefined); |
| 104 | } |
| 105 | return { status: res.status, body }; |
| 106 | }; |
| 107 | |
| 108 | const toolsListMessage = { jsonrpc: "2.0" as const, id: "brick-tools-list", method: "tools/list" }; |
| 109 |
no test coverage detected