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

Function withConnection

packages/plugins/mcp/src/sdk/connection-pool.ts:108–127  ·  view source on GitHub ↗
(key, connector, use)

Source from the content-addressed store, hash-verified

106 });
107
108 const withConnection: McpConnectionPool["withConnection"] = (key, connector, use) => {
109 let reused = false;
110 const run = (forceFresh: boolean) =>
111 Effect.acquireUseRelease(
112 acquire(key, connector, forceFresh),
113 (lease) => {
114 if (!forceFresh) reused = lease.reused;
115 return use(lease.connection);
116 },
117 (lease, exit) => release(key, lease, exit),
118 );
119
120 return run(false).pipe(
121 Effect.catch((error) =>
122 reused && isMcpInvocationError(error) && error.status === 404
123 ? run(true)
124 : Effect.fail(error),
125 ),
126 );
127 };
128
129 const close = () =>
130 Effect.gen(function* () {

Callers

nothing calls this directly

Calls 2

isMcpInvocationErrorFunction · 0.85
runFunction · 0.70

Tested by

no test coverage detected