(
url: string | URL,
init: { readonly bearer: string; readonly sessionId?: string; readonly body: unknown },
)
| 50 | const emailOf = (identity: Identity): string => identity.credentials?.email ?? identity.label; |
| 51 | |
| 52 | const mcpPost = ( |
| 53 | url: string | URL, |
| 54 | init: { readonly bearer: string; readonly sessionId?: string; readonly body: unknown }, |
| 55 | ): Promise<Response> => |
| 56 | fetch(url, { |
| 57 | method: "POST", |
| 58 | headers: { |
| 59 | accept: JSON_AND_SSE, |
| 60 | "content-type": "application/json", |
| 61 | authorization: `Bearer ${init.bearer}`, |
| 62 | ...(init.sessionId ? { "mcp-session-id": init.sessionId } : {}), |
| 63 | }, |
| 64 | body: JSON.stringify(init.body), |
| 65 | }); |
| 66 | |
| 67 | const openSession = async (mcpUrl: string, bearer: string): Promise<string> => { |
| 68 | const initialize = await mcpPost(mcpUrl, { bearer, body: INITIALIZE_REQUEST }); |
no test coverage detected