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

Function withClient

packages/hosts/mcp/src/passthrough-tools.test.ts:117–139  ·  view source on GitHub ↗
(
  config: ExecutorMcpServerConfig<E>,
  fn: (client: Client) => Promise<void>,
)

Source from the content-addressed store, hash-verified

115};
116
117const withClient = async <E extends Cause.YieldableError>(
118 config: ExecutorMcpServerConfig<E>,
119 fn: (client: Client) => Promise<void>,
120) => {
121 const mcpServer = await Effect.runPromise(
122 createExecutorMcpServer({
123 connections: { list: () => Effect.succeed([]) },
124 integrations: { list: () => Effect.succeed([]) },
125 ...config,
126 }),
127 );
128 const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
129 const client = new Client({ name: "test-client", version: "1.0.0" }, { capabilities: {} });
130 await mcpServer.connect(serverTransport);
131 await client.connect(clientTransport);
132 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: test helper must close MCP transports after async client assertions
133 try {
134 await fn(client);
135 } finally {
136 await clientTransport.close();
137 await serverTransport.close();
138 }
139};
140
141const decodeJsonString = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.String));
142const decodeJsonRecord = Schema.decodeUnknownSync(

Callers 1

Calls 3

createExecutorMcpServerFunction · 0.90
connectMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected