Skip to content

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

chore: files changed src/openhuman/mcp/registry/custom/ops.rs

Steven Enamakelb31f6a87cf73
diff --git a/src/openhuman/mcp/registry/custom/ops.rs b/src/openhuman/mcp/registry/custom/ops.rs
index 0947cac607..c43876e88b 100644
--- a/src/openhuman/mcp/registry/custom/ops.rs
+++ b/src/openhuman/mcp/registry/custom/ops.rs
@@ -115,9 +115,6 @@ pub async fn mcp_clients_add_custom(
provenance: ServerProvenance::Custom,
};
- let reg = registry(config)?;
- let store = reg.store();
-
// `allocate_qualified_name` and this insert are separate statements, so a
// concurrent add can take the slug in between. Surface that instead of
// refreshing onto the winner the way `mcp_clients_install` does: two custom
@@ -126,15 +123,16 @@ pub async fn mcp_clients_add_custom(
// Row and env commit together: a row that lands without its env is a server
// the caller was told did not save, holding the name and relaunched by the
// supervisor every tick with no credentials.
- store
- .insert_server(&server)
- .map_err(|e| format!("failed to create the server record: {e}"))?;
-
- // Store the env values.
- let env_map: std::collections::BTreeMap<String, String> = env.into_iter().collect();
- store
- .set_env_values(&server_id, &env_map)
- .map_err(|e| format!("failed to store credentials: {e}"))?;
+ if !crate::openhuman::mcp::registry::store::insert_custom_server_with_env(
+ config, &server, &env,
+ )
+ .map_err(|e| format!("failed to create the server record: {e}"))?
+ {
+ return Err(format!(
+ "custom server name `{}` was claimed concurrently; retry the add",
+ server.qualified_name
+ ));
+ }
tracing::debug!(
"[mcp-custom] add ok server_id={} qualified_name={}",
@@ -260,4 +258,4 @@ pub async fn mcp_clients_update_custom(
json!({ "server": updated }),
vec![format!("updated custom server_id={server_id}")],
))
-}
\ No newline at end of file
+}