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

Function withClient

packages/hosts/mcp/src/tool-server.test.ts:57–83  ·  view source on GitHub ↗
(
  engine: ExecutionEngine<E>,
  capabilities: ClientCapabilities,
  fn: (client: Client) => Promise<void>,
  config?: Pick<
    ExecutorMcpServerConfig<E>,
    | "debug"
    | "elicitationMode"
    | "browserApprovalStore"
    | "pausedExecutionHooks"
    | "pausedExecutionLeaseMs"
    | "resumeFallback"
  >,
)

Source from the content-addressed store, hash-verified

55
56/** Connect a real MCP Client to our executor MCP server over in-memory transports. */
57const withClient = async <E extends Cause.YieldableError>(
58 engine: ExecutionEngine<E>,
59 capabilities: ClientCapabilities,
60 fn: (client: Client) => Promise<void>,
61 config?: Pick<
62 ExecutorMcpServerConfig<E>,
63 | "debug"
64 | "elicitationMode"
65 | "browserApprovalStore"
66 | "pausedExecutionHooks"
67 | "pausedExecutionLeaseMs"
68 | "resumeFallback"
69 >,
70) => {
71 const mcpServer = await Effect.runPromise(createExecutorMcpServer({ engine, ...config }));
72 const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
73 const client = new Client({ name: "test-client", version: "1.0.0" }, { capabilities });
74 await mcpServer.connect(serverTransport);
75 await client.connect(clientTransport);
76 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: test helper must close MCP transports after async client assertions
77 try {
78 await fn(client);
79 } finally {
80 await clientTransport.close();
81 await serverTransport.close();
82 }
83};
84
85const withNativeClient = async <E extends Cause.YieldableError>(
86 engine: ExecutionEngine<E>,

Callers 2

withNativeClientFunction · 0.85

Calls 3

createExecutorMcpServerFunction · 0.90
connectMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected