(mcpUrl: string, bearer: string)
| 65 | }); |
| 66 | |
| 67 | const openSession = async (mcpUrl: string, bearer: string): Promise<string> => { |
| 68 | const initialize = await mcpPost(mcpUrl, { bearer, body: INITIALIZE_REQUEST }); |
| 69 | const sessionId = initialize.headers.get("mcp-session-id"); |
| 70 | await initialize.text(); |
| 71 | if (initialize.status !== 200 || !sessionId) { |
| 72 | throw new Error(`openSession: initialize failed (${initialize.status})`); |
| 73 | } |
| 74 | const initialized = await mcpPost(mcpUrl, { bearer, sessionId, body: INITIALIZED_NOTIFICATION }); |
| 75 | await initialized.text(); |
| 76 | if (initialized.status !== 202) { |
| 77 | throw new Error(`openSession: notifications/initialized failed (${initialized.status})`); |
| 78 | } |
| 79 | return sessionId; |
| 80 | }; |
| 81 | |
| 82 | type Probe = { |
| 83 | readonly atMs: number; |
no test coverage detected