feat(#2038): render http mcp url when HYPERHIVE_MCP_HTTP_PORT set
This commit is contained in:
parent
ecba548787
commit
4a82ed02cf
1 changed files with 17 additions and 4 deletions
|
|
@ -2212,14 +2212,27 @@ fn load_extra_mcp() -> std::collections::BTreeMap<String, ExtraMcpServer> {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn render_claude_config(agent_binary: &str, socket: &std::path::Path) -> String {
|
pub fn render_claude_config(agent_binary: &str, socket: &std::path::Path) -> String {
|
||||||
let mut servers = serde_json::Map::new();
|
let mut servers = serde_json::Map::new();
|
||||||
servers.insert(
|
// When the harness is configured to run the built-in server as a
|
||||||
SERVER_NAME.to_owned(),
|
// persistent streamable-http daemon (loopback port in
|
||||||
serde_json::json!({
|
// `HYPERHIVE_MCP_HTTP_PORT`), point claude at the stable URL instead of
|
||||||
|
// respawning a fresh stdio child each turn. The URL survives the per-turn
|
||||||
|
// claude re-spawn, so there is no per-turn re-registration race for the
|
||||||
|
// hyperhive surface. Extra servers (matrix/bash) stay stdio bridges.
|
||||||
|
let hyperhive_entry = match std::env::var("HYPERHIVE_MCP_HTTP_PORT")
|
||||||
|
.ok()
|
||||||
|
.and_then(|p| p.trim().parse::<u16>().ok())
|
||||||
|
{
|
||||||
|
Some(port) => serde_json::json!({
|
||||||
|
"type": "http",
|
||||||
|
"url": format!("http://127.0.0.1:{port}/mcp"),
|
||||||
|
}),
|
||||||
|
None => serde_json::json!({
|
||||||
"command": agent_binary,
|
"command": agent_binary,
|
||||||
"args": ["--socket", socket.display().to_string(), "mcp"],
|
"args": ["--socket", socket.display().to_string(), "mcp"],
|
||||||
"env": {}
|
"env": {}
|
||||||
}),
|
}),
|
||||||
);
|
};
|
||||||
|
servers.insert(SERVER_NAME.to_owned(), hyperhive_entry);
|
||||||
// Auto-inject HYPERHIVE_STATE_DIR so extra MCP servers can resolve the
|
// Auto-inject HYPERHIVE_STATE_DIR so extra MCP servers can resolve the
|
||||||
// agent's durable state dir without the agent author hard-coding it.
|
// agent's durable state dir without the agent author hard-coding it.
|
||||||
// User-supplied env takes precedence — we only fill in the missing key.
|
// User-supplied env takes precedence — we only fill in the missing key.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue