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 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 22:01:26 +10:00
parent 51bc5912ff
commit c4b014c15e

View File

@@ -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 || ''
}
}
}