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

Function initSession

apps/host-selfhost/src/mcp/mcp.test.ts:75–98  ·  view source on GitHub ↗
(token: string, browser = false)

Source from the content-addressed store, hash-verified

73 );
74
75const initSession = async (token: string, browser = false): Promise<string> => {
76 const res = await mcp(
77 token,
78 {
79 jsonrpc: "2.0",
80 id: 1,
81 method: "initialize",
82 params: {
83 protocolVersion: "2025-03-26",
84 capabilities: {},
85 clientInfo: { name: "t", version: "1" },
86 },
87 },
88 undefined,
89 browser,
90 );
91 expect(res.status).toBe(200);
92 expect(res.headers.get("content-type")).toContain("application/json");
93 const sessionId = res.headers.get("mcp-session-id") ?? "";
94 expect(sessionId).not.toBe("");
95 await res.text();
96 await mcp(token, { jsonrpc: "2.0", method: "notifications/initialized" }, sessionId, browser);
97 return sessionId;
98};
99
100const account = (token: string, path: string, init?: RequestInit) =>
101 handler(

Callers 1

mcp.test.tsFile · 0.85

Calls 3

mcpFunction · 0.70
getMethod · 0.65
textMethod · 0.65

Tested by

no test coverage detected