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

Function connectClient

e2e/cloud/mcp-client-sessions.test.ts:36–51  ·  view source on GitHub ↗
(
  mcpUrl: string,
  bearer: string,
  sessionId?: string,
)

Source from the content-addressed store, hash-verified

34
35/** A real SDK client over StreamableHTTP; `sessionId` resumes an existing session. */
36const connectClient = async (
37 mcpUrl: string,
38 bearer: string,
39 sessionId?: string,
40): Promise<Connected> => {
41 const client = new Client(
42 { name: "executor-e2e-sessions", version: "0.0.1" },
43 { capabilities: {} },
44 );
45 const transport = new StreamableHTTPClientTransport(new URL(mcpUrl), {
46 requestInit: { headers: { authorization: `Bearer ${bearer}` } },
47 ...(sessionId === undefined ? {} : { sessionId }),
48 });
49 await client.connect(transport);
50 return { client, transport };
51};
52
53const textOf = (result: { content?: unknown; toolResult?: unknown }): string =>
54 ((result.content ?? []) as Array<{ type: string; text?: string }>)

Callers 1

Calls 1

connectMethod · 0.65

Tested by

no test coverage detected