From c4b014c15e1d693df17997cc08a03699f4b5c26e Mon Sep 17 00:00:00 2001 From: root Date: Mon, 1 Jun 2026 22:01:26 +1000 Subject: [PATCH] fix(companion): pass DATABASE_URL/OLLAMA_URL to MCP stdio child explicitly Don't rely on env inheritance/cwd-dotenv for the claude-spawned MCP server. Co-Authored-By: Claude Opus 4.8 --- lib/api/routes/companion.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/api/routes/companion.js b/lib/api/routes/companion.js index 9e7b797..50fdf40 100644 --- a/lib/api/routes/companion.js +++ b/lib/api/routes/companion.js @@ -62,7 +62,9 @@ spacesScopedRouter.post('/turn', const send = (event, data) => res.write(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`); // Write a per-turn MCP config temp file declaring the companion stdio server. - // DB connection env is inherited from the void-server process — no creds needed here. + // The stdio child is spawned by `claude`; pass the DB/Ollama connection env + // explicitly so the tools work regardless of how claude propagates env to + // MCP children (don't rely on inheritance or cwd-based dotenv). const mcpConfigPath = join(tmpdir(), `void-mcp-${randomUUID()}.json`); const agentActor = { kind: 'agent', @@ -78,7 +80,9 @@ spacesScopedRouter.post('/turn', env: { VOID_SPACE_ID: req.params.space_id, VOID_AGENT_JSON: JSON.stringify(agentActor), - VOID_VIEW_JSON: view ? JSON.stringify(view) : '' + VOID_VIEW_JSON: view ? JSON.stringify(view) : '', + DATABASE_URL: process.env.DATABASE_URL || '', + OLLAMA_URL: process.env.OLLAMA_URL || '' } } }