MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / openSession

Function openSession

e2e/cloud/mcp-oversize-response.test.ts:42–67  ·  view source on GitHub ↗
(mcpUrl: string, bearer: string)

Source from the content-addressed store, hash-verified

40 });
41
42const 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. */
70const readSseMessages = async (

Callers 1

Calls 3

postJsonFunction · 0.70
getMethod · 0.65
textMethod · 0.65

Tested by

no test coverage detected