(mcpUrl: string, bearer: string)
| 40 | }); |
| 41 | |
| 42 | const openSession = async (mcpUrl: string, bearer: string): Promise<string> => { |
| 43 | const initialized = await postJson(mcpUrl, bearer, { |
| 44 | jsonrpc: "2.0" as const, |
| 45 | id: "initialize", |
| 46 | method: "initialize", |
| 47 | params: { |
| 48 | protocolVersion: PROTOCOL_VERSION, |
| 49 | capabilities: {}, |
| 50 | clientInfo: { name: "executor-e2e-oversize-response", version: "0.0.1" }, |
| 51 | }, |
| 52 | }); |
| 53 | const sessionId = initialized.headers.get("mcp-session-id"); |
| 54 | await initialized.text(); |
| 55 | if (initialized.status !== 200 || !sessionId) { |
| 56 | throw new Error(`openSession: initialize failed (${initialized.status})`); |
| 57 | } |
| 58 | const notification = await postJson( |
| 59 | mcpUrl, |
| 60 | bearer, |
| 61 | { jsonrpc: "2.0" as const, method: "notifications/initialized" }, |
| 62 | sessionId, |
| 63 | ); |
| 64 | await notification.text(); |
| 65 | expect(notification.status, "notifications/initialized is accepted").toBe(202); |
| 66 | return sessionId; |
| 67 | }; |
| 68 | |
| 69 | /** Read the POST's SSE body to completion and return the JSON-RPC payloads. */ |
| 70 | const readSseMessages = async ( |
no test coverage detected