inject HYPERHIVE_STATE_DIR into container env + extra MCP server envs

This commit is contained in:
damocles 2026-05-20 12:46:41 +02:00
parent 9cbb05bb86
commit f21ae1ff98
2 changed files with 19 additions and 1 deletions

View file

@ -1383,13 +1383,20 @@ pub fn render_claude_config(agent_binary: &str, socket: &std::path::Path) -> Str
"env": {}
}),
);
for (name, spec) in load_extra_mcp() {
// Auto-inject HYPERHIVE_STATE_DIR so extra MCP servers can resolve the
// agent's durable state dir without the agent author hard-coding it.
// User-supplied env takes precedence — we only fill in the missing key.
let state_dir = crate::paths::state_dir();
for (name, mut spec) in load_extra_mcp() {
if name == SERVER_NAME {
tracing::warn!(
"extra MCP server name `{SERVER_NAME}` collides with the built-in surface; ignoring",
);
continue;
}
spec.env
.entry("HYPERHIVE_STATE_DIR".to_owned())
.or_insert_with(|| state_dir.display().to_string());
servers.insert(
name,
serde_json::json!({