( mcpUrl: string, bearer: string, sessionId: string, message: unknown, )
| 60 | |
| 61 | /** A raw POST of a JSON-RPC request onto an existing session id. */ |
| 62 | const rawPost = async ( |
| 63 | mcpUrl: string, |
| 64 | bearer: string, |
| 65 | sessionId: string, |
| 66 | message: unknown, |
| 67 | ): Promise<RawResult> => { |
| 68 | const res = await fetch(mcpUrl, { |
| 69 | method: "POST", |
| 70 | headers: { |
| 71 | authorization: `Bearer ${bearer}`, |
| 72 | "content-type": "application/json", |
| 73 | // The streamable-http transport requires the client accept both. |
| 74 | accept: "application/json, text/event-stream", |
| 75 | "mcp-session-id": sessionId, |
| 76 | "mcp-protocol-version": "2025-06-18", |
| 77 | }, |
| 78 | body: JSON.stringify(message), |
| 79 | }); |
| 80 | const body = await res.text().catch(() => ""); |
| 81 | return { status: res.status, body }; |
| 82 | }; |
| 83 | |
| 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. */ |
no test coverage detected