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

Function openSession

e2e/cloud/api-key-validation-cache.test.ts:93–110  ·  view source on GitHub ↗
(mcpUrl: string, bearer: string)

Source from the content-addressed store, hash-verified

91
92/** initialize → session id → notifications/initialized, all on the API key. */
93const openSession = async (mcpUrl: string, bearer: string): Promise<string> => {
94 const initialize = await mcpPost(mcpUrl, { bearer, body: INITIALIZE_REQUEST });
95 const sessionId = initialize.headers.get("mcp-session-id");
96 await initialize.text();
97 if (initialize.status !== 200 || !sessionId) {
98 throw new Error(`openSession: initialize failed (${initialize.status})`);
99 }
100 const initialized = await mcpPost(mcpUrl, {
101 bearer,
102 sessionId,
103 body: INITIALIZED_NOTIFICATION,
104 });
105 await initialized.text();
106 if (initialized.status !== 202) {
107 throw new Error(`openSession: notifications/initialized failed (${initialized.status})`);
108 }
109 return sessionId;
110};
111
112/** One tools/list on an open session; the response must be a real tool list,
113 * so a validation count of one can never come from requests that bounced at

Calls 3

mcpPostFunction · 0.70
getMethod · 0.65
textMethod · 0.65

Tested by

no test coverage detected