MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / runProxy

Function runProxy

src/mcp/proxy.ts:121–138  ·  view source on GitHub ↗
(
  socketPath: string,
  expectedVersion: string = CodeGraphPackageVersion,
)

Source from the content-addressed store, hash-verified

119 * price of never silently running a stale daemon against newer client code.)
120 */
121export async function runProxy(
122 socketPath: string,
123 expectedVersion: string = CodeGraphPackageVersion,
124): Promise<ProxyResult> {
125 // The same connect as every session's: the hello, the version and the
126 // daemon's proof that it runs as this user, before any byte is piped.
127 const socket = await connectWithHello(socketPath, expectedVersion);
128 if (!socket) return { outcome: 'fallback-needed', reason: 'no daemon answered' };
129 if (typeof socket === 'string') {
130 return { outcome: 'fallback-needed', reason: socket === 'unproven' ? 'daemon could not prove it runs as this user' : 'version mismatch' };
131 }
132 startPpidWatchdog(socket);
133 await pipeUntilClose(socket);
134 // Host disconnected (or the daemon went away). The proxy's only job is the
135 // pipe; exit now so we don't linger — process.stdin's 'data' listener would
136 // otherwise keep the event loop alive and leave a zombie launcher behind.
137 process.exit(0);
138}
139
140/**
141 * Connect to a daemon at `socketPath`, verify its hello (exact version match),

Callers

nothing calls this directly

Calls 4

connectWithHelloFunction · 0.85
startPpidWatchdogFunction · 0.85
pipeUntilCloseFunction · 0.85
exitMethod · 0.80

Tested by

no test coverage detected