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

Function withConnection

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

isMcpInvocationErrorFunction · 0.85
runFunction · 0.70

Tested by

no test coverage detected