Skip to content

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

chore: files changed crates/openhuman-core/src/mcp/registry/config_ops.rs

Steven Enamakel4c27615d0784
diff --git a/crates/openhuman-core/src/mcp/registry/config_ops.rs b/crates/openhuman-core/src/mcp/registry/config_ops.rs
index 653f89a5c9..f5303b027a 100644
--- a/crates/openhuman-core/src/mcp/registry/config_ops.rs
+++ b/crates/openhuman-core/src/mcp/registry/config_ops.rs
@@ -1,12 +1,7 @@
//! The `mcp.json` RPC handlers: reading the install store as one document and
-//! replacing it from one.
-//!
-//! The contract — what a read shows, what a write may say — and the
-//! reconciliation against the store are `tinymcp`'s
-//! (`tinymcp::registry::config_doc`, `McpRegistry::apply_config_doc`). What is
-//! left here is this application's: the `Outcome` envelope, the domain
-//! events a change publishes, and connecting the changed servers in the
-//! background so the editor that saved the document does not wait on them.
+//! replacing it from one. TinyMCP owns document validation and reconciliation;
+//! this adapter publishes product events and schedules connections after the
+//! module returns.
use serde_json::{json, Value};
@@ -15,20 +10,23 @@ use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
use crate::core::Outcome;
-use super::helpers::resolve;
-
// ── mcp.json ─────────────────────────────────────────────────────────────────
/// Renders the install store as the `mcp.json` document.
///
/// Credential *names* ride along as `envKeys`; values never do.
pub async fn mcp_clients_config_get(config: &Config) -> Result<Outcome<Value>, String> {
- let service = resolve(config)?;
- let doc = service
- .dynamic()
- .render_config_doc()
+ let client = super::super::module_client::McpConfiguredClient::for_config(config)
+ .map_err(|error| error.to_string())?;
+ let doc: Value = client
+ .call(
+ &super::super::host::client_config(config),
+ tinymcp_bus::names::methods::CONFIG_DOCUMENT_GET,
+ (),
+ )
+ .await
.map_err(|error| error.to_string())?;
- let count = doc[tinymcp::registry::config_doc::ROOT_KEY]
+ let count = doc["mcpServers"]
.as_object()
.map_or(0, serde_json::Map::len);
@@ -45,12 +43,17 @@ pub async fn mcp_clients_config_get(config: &Config) -> Result<Outcome<Value>, S
/// status poll reports how that went. The reply carries the re-rendered
/// document and what changed, so the editor can show both.
pub async fn mcp_clients_config_set(config: &Config, doc: Value) -> Result<Outcome<Value>, String> {
- let service = resolve(config)?;
- let registry = service.dynamic();
- let report = registry
- .apply_config_doc(&doc)
+ let client = super::super::module_client::McpConfiguredClient::for_config(config)
+ .map_err(|error| error.to_string())?;
+ let applied: tinymcp_bus::ConfigApplyResponse = client
+ .call_confidential(
+ &super::super::host::client_config(config),
+ tinymcp_bus::names::methods::CONFIG_DOCUMENT_APPLY,
+ (doc,),
+ )
.await
.map_err(|error| error.to_string())?;
+ let report = applied.report;
for server in &report.removed {
BUS.publish(DomainEvent::McpServerDisconnected {
@@ -69,9 +72,17 @@ pub async fn mcp_clients_config_set(config: &Config, doc: Value) -> Result<Outco
// must not wait on it. The status poll shows each attempt's outcome, and a
// failure is recorded against the server either way.
for server_id in report.connect_queued.clone() {
- let service = std::sync::Arc::clone(&service);
+ let client = std::sync::Arc::clone(&client);
+ let config = config.clone();
tokio::spawn(async move {
- match service.dynamic().connect(&server_id).await {
+ let outcome: Result<tinymcp_bus::ConnectOutcome, _> = client
+ .call(
+ &super::super::host::client_config(&config),
+ tinymcp_bus::names::methods::CONNECT,
+ (server_id.clone(),),
+ )
+ .await;
+ match outcome {
Ok(outcome) => {
let tool_count = u32::try_from(outcome.tools.len()).unwrap_or(u32::MAX);
tracing::debug!(
@@ -94,11 +105,9 @@ pub async fn mcp_clients_config_set(config: &Config, doc: Value) -> Result<Outco
});
}
- let mut rendered = registry
- .render_config_doc()
- .map_err(|error| error.to_string())?;
+ let mut rendered = applied.document;
- let names = |servers: &[tinymcp::AppliedServer]| -> Vec<String> {
+ let names = |servers: &[tinymcp_bus::AppliedServer]| -> Vec<String> {
servers.iter().map(|server| server.name.clone()).collect()
};
let note = format!(