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

Function handleLocally

src/mcp/proxy.ts:257–278  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

255 };
256 // Daemon-unavailable fallback: serve a client message in-process.
257 const handleLocally = async (line: string): Promise<void> => {
258 let msg: JsonRpc; try { msg = JSON.parse(line) as JsonRpc; } catch { return; }
259 const id = msg.id;
260 if (msg.method === 'tools/call' && id !== undefined) {
261 try {
262 await ensureEngine();
263 const params = (msg.params || {}) as { name: string; arguments?: Record<string, unknown> };
264 const result = await engine!.getToolHandler().execute(params.name, params.arguments || {});
265 writeClient({ jsonrpc: '2.0', id, result });
266 getTelemetry().recordUsage('mcp_tool', params.name, !result.isError, telemetryClient);
267 } catch (err) {
268 writeClient({ jsonrpc: '2.0', id, error: { code: -32603, message: err instanceof Error ? err.message : String(err) } });
269 }
270 } else if (msg.method === 'ping' && id !== undefined) {
271 writeClient({ jsonrpc: '2.0', id, result: {} });
272 } else if (id !== undefined && msg.method !== 'initialize') {
273 // A request we can't serve in-process (and the daemon is gone) — answer
274 // with an error rather than let the host hang on a reply that won't come.
275 writeClient({ jsonrpc: '2.0', id, error: { code: -32603, message: 'CodeGraph daemon unavailable' } });
276 }
277 // initialize already answered locally; notifications (initialized) need no reply.
278 };
279 const routeToDaemon = (line: string): void => {
280 if (daemonStatus === 'ready' && daemonSocket) {
281 trackInflight(line);

Callers 3

routeToDaemonFunction · 0.85
onDaemonLostFunction · 0.85
runLocalHandshakeProxyFunction · 0.85

Calls 6

getTelemetryFunction · 0.90
ensureEngineFunction · 0.85
writeClientFunction · 0.85
executeMethod · 0.80
getToolHandlerMethod · 0.80
recordUsageMethod · 0.80

Tested by

no test coverage detected