Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(host): handle missing MCP server gracefully on shutdown

Steven Enamakele0f7375505e3
diff --git a/src/openhuman/mcp/host.rs b/src/openhuman/mcp/host.rs
index b392399b8a..33a408db20 100644
--- a/src/openhuman/mcp/host.rs
+++ b/src/openhuman/mcp/host.rs
@@ -269,15 +269,18 @@ pub fn try_service() -> Option<Arc<McpHost>> {
/// two `OnceLock`s and a process-wide map that every case in this suite shares,
/// so a test driving `try_service` directly could only assert whatever the rest
/// of the suite happened to leave behind — which is to say, nothing.
-fn resolve(default: Option<&Path>, hosts: &HashMap<PathBuf, Arc<McpHost>>) -> Option<Arc<McpHost>> {
+fn resolve(
+ default: Option<&Path>,
+ hosts: &HashMap<PathBuf, HostEntry>,
+) -> Option<Arc<McpHost>> {
if let Some(workspace) = default {
- if let Some(service) = hosts.get(workspace) {
- return Some(Arc::clone(service));
+ if let Some(entry) = hosts.get(workspace) {
+ return Some(Arc::clone(&entry.host));
}
}
match hosts.len() {
- 1 => hosts.values().next().map(Arc::clone),
+ 1 => hosts.values().next().map(|entry| Arc::clone(&entry.host)),
_ => None,
}
}