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

Function openSession

e2e/cloud/mcp-protocol.test.ts:79–96  ·  view source on GitHub ↗
(mcpUrl: string, bearer: string)

Source from the content-addressed store, hash-verified

77
78/** initialize → session id (asserted present) → notifications/initialized. */
79const openSession = async (mcpUrl: string, bearer: string): Promise<string> => {
80 const initialize = await mcpPost(mcpUrl, { bearer, body: INITIALIZE_REQUEST });
81 const sessionId = initialize.headers.get("mcp-session-id");
82 await initialize.text();
83 if (initialize.status !== 200 || !sessionId) {
84 throw new Error(`openSession: initialize failed (${initialize.status})`);
85 }
86 const initialized = await mcpPost(mcpUrl, {
87 bearer,
88 sessionId,
89 body: INITIALIZED_NOTIFICATION,
90 });
91 await initialized.text();
92 if (initialized.status !== 202) {
93 throw new Error(`openSession: notifications/initialized failed (${initialized.status})`);
94 }
95 return sessionId;
96};
97
98scenario(
99 "MCP protocol · /mcp answers a CORS preflight allowing the headers an MCP client sends",

Callers 1

Calls 3

mcpPostFunction · 0.70
getMethod · 0.65
textMethod · 0.65

Tested by

no test coverage detected