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

Function connectClient

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

connectMethod · 0.65

Tested by

no test coverage detected