The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(registry): remove custom server RPC handlers and inline schema definitions
Steven Enamakelc11cf89ff64f
diff --git a/src/openhuman/mcp/registry/custom/ops.rs b/src/openhuman/mcp/registry/custom/ops.rsindex 9e61b6a0ca..622c8e7954 100644--- a/src/openhuman/mcp/registry/custom/ops.rs+++ b/src/openhuman/mcp/registry/custom/ops.rs@@ -6,23 +6,27 @@use std::collections::HashMap;-use crate::core::bus::BUS;-use crate::core::events::DomainEvent;use serde_json::{json, Value};+use tinymcp_bus::{InstalledServer, ServerProvenance};use uuid::Uuid;+use crate::core::event_bus::{publish_global, DomainEvent};use crate::openhuman::config::Config;use crate::openhuman::mcp::host;use crate::rpc::RpcOutcome;-use super::super::store;-use super::super::types::{InstalledServer, ServerProvenance};use super::validate::{base_slug, build_custom_transport, clean_description, credential_scope, env_key_list,resolve_env, resolve_env_for_transport, validate_env,};use super::{CustomServerInput, CUSTOM_QUALIFIED_PREFIX, MAX_SLUG_ATTEMPTS};+fn registry(config: &Config) -> Result<&tinymcp::McpRegistry, String> {+ host::for_config(config)+ .map(|service| service.dynamic())+ .map_err(|error| format!("failed to open the MCP service: {error}"))+}+/// The dynamic registry for `config`'s workspace, or an error string.fn allocate_qualified_name(config: &Config,@@ -39,7 +43,9 @@ fn allocate_qualified_name(} else {format!("{base}-{}", attempt + 1)};- let taken = store::find_server_by_qualified_name(config, &candidate)+ let taken = registry(config)?+ .store()+ .find_server_by_qualified_name(&candidate).map_err(|e| e.to_string())?.is_some();if !taken {@@ -132,7 +138,7 @@ pub async fn mcp_clients_add_custom(server.qualified_name);- BUS.publish(DomainEvent::McpServerInstalled {+ publish_global(DomainEvent::McpServerInstalled {server_id: server_id.clone(),qualified_name: server.qualified_name.clone(),});@@ -175,7 +181,10 @@ pub async fn mcp_clients_update_custom(// `update_custom` could switch transport and store new-scope credentials —// and a stale snapshot could revert the token or mis-scope and carry the// new credentials across origins.- let updated = store::update_custom_server_rmw(config, &server_id, |current, stored_env| {+ let reg = registry(config)?;+ let store = reg.store();+ let updated = store+ .update_server_rmw(&server_id, |current, stored_env| {if current.provenance != ServerProvenance::Custom {return Err(tinymcp::Error::other(format!("server `{server_id}` was installed from a registry; its command and endpoint \@@ -233,9 +242,7 @@ pub async fn mcp_clients_update_custom(// pins the server to the pre-edit command indefinitely — it stays healthy, so// no later tick reconnects it. `update_env` persists first for the same// reason.- if let Ok(service) = host::for_config(config) {- service.dynamic().connections().disconnect(&server_id).await;- }+ reg.connections().disconnect(&server_id).await;tracing::debug!("[mcp-custom] update ok server_id={}", server_id);diff --git a/src/openhuman/mcp/registry/custom/validate.rs b/src/openhuman/mcp/registry/custom/validate.rsindex 55dad8e4e2..498f97d7b6 100644--- a/src/openhuman/mcp/registry/custom/validate.rs+++ b/src/openhuman/mcp/registry/custom/validate.rs@@ -3,9 +3,10 @@use std::collections::HashMap;+use tinymcp_bus::{CommandKind, Transport};+use super::CustomServerInput;use super::RESERVED_ENV_PREFIX;-use crate::openhuman::mcp::registry::types::{CommandKind, Transport};// ── validation ───────────────────────────────────────────────────────────────diff --git a/src/openhuman/mcp/registry/mod.rs b/src/openhuman/mcp/registry/mod.rsindex ffac125fa4..e22f64e233 100644--- a/src/openhuman/mcp/registry/mod.rs+++ b/src/openhuman/mcp/registry/mod.rs@@ -35,8 +35,6 @@#[cfg(feature = "mcp")]pub mod bus;#[cfg(feature = "mcp")]-pub mod custom;-#[cfg(feature = "mcp")]pub(crate) mod helpers;#[cfg(feature = "mcp")]pub mod ops;diff --git a/src/openhuman/mcp/registry/schemas_part_01.rs b/src/openhuman/mcp/registry/schemas_part_01.rsindex 98fc0eac14..015c2385f6 100644--- a/src/openhuman/mcp/registry/schemas_part_01.rs+++ b/src/openhuman/mcp/registry/schemas_part_01.rs@@ -26,8 +26,6 @@ pub fn all_controller_schemas() -> Vec<ControllerSchema> {schemas("registry_settings_get"),schemas("registry_settings_set"),schemas("set_enabled"),- schemas("add_custom"),- schemas("update_custom"),// Setup-agent surface (mcp_setup namespace, lives in setup_ops.rs).setup_schemas("search"),setup_schemas("get"),@@ -104,14 +102,6 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {schema: schemas("set_enabled"),handler: handle_set_enabled,},- RegisteredController {- schema: schemas("add_custom"),- handler: handle_add_custom,- },- RegisteredController {- schema: schemas("update_custom"),- handler: handle_update_custom,- },RegisteredController {schema: setup_schemas("search"),handler: handle_setup_search,@@ -646,10 +636,6 @@ pub fn schemas(function: &str) -> ControllerSchema {],},- "add_custom" => custom_server_schema(false),-- "update_custom" => custom_server_schema(true),-// Handled by setup_schemas() — surface a clearer error rather than// falling through to the generic unknown sink."setup_search"@@ -678,77 +664,3 @@ pub fn schemas(function: &str) -> ControllerSchema {},}}--fn custom_server_schema(include_server_id: bool) -> ControllerSchema {- let mut inputs = vec![- FieldSchema {- name: "display_name",- ty: TypeSchema::String,- comment: "User-visible name for the hand-entered server.",- required: true,- },- FieldSchema {- name: "transport",- ty: TypeSchema::String,- comment: "Transport: `stdio` or `http_remote`.",- required: true,- },- FieldSchema {- name: "command",- ty: TypeSchema::Option(Box::new(TypeSchema::String)),- comment: "Executable for a stdio server.",- required: false,- },- FieldSchema {- name: "args",- ty: TypeSchema::Option(Box::new(TypeSchema::Array(Box::new(TypeSchema::String)))),- comment: "Arguments for a stdio server.",- required: false,- },- FieldSchema {- name: "url",- ty: TypeSchema::Option(Box::new(TypeSchema::String)),- comment: "HTTP(S) endpoint for an http_remote server.",- required: false,- },- FieldSchema {- name: "env",- ty: TypeSchema::Option(Box::new(TypeSchema::Map(Box::new(TypeSchema::String)))),- comment: "Environment variables or HTTP headers; values are write-only.",- required: false,- },- FieldSchema {- name: "description",- ty: TypeSchema::Option(Box::new(TypeSchema::String)),- comment: "Optional description.",- required: false,- },- ];- if include_server_id {- inputs.insert(- 0,- FieldSchema {- name: "server_id",- ty: TypeSchema::String,- comment: "UUID of the custom server to edit.",- required: true,- },- );- }- ControllerSchema {- namespace: "mcp_clients",- function: if include_server_id { "update_custom" } else { "add_custom" },- description: if include_server_id {- "Update a hand-entered MCP server."- } else {- "Add a hand-entered MCP server."- },- inputs,- outputs: vec![FieldSchema {- name: "server",- ty: TypeSchema::Ref("InstalledServer"),- comment: "The saved server record; secret values are omitted.",- required: true,- }],- }-}diff --git a/src/openhuman/mcp/registry/schemas_part_02.rs b/src/openhuman/mcp/registry/schemas_part_02.rsindex 7ffb1e9a0a..e43f12cd2f 100644--- a/src/openhuman/mcp/registry/schemas_part_02.rs+++ b/src/openhuman/mcp/registry/schemas_part_02.rs@@ -132,44 +132,6 @@ fn handle_set_enabled(params: Map<String, Value>) -> ControllerFuture {})}-fn custom_input(- params: &Map<String, Value>,-) -> Result<crate::openhuman::mcp::registry::custom::CustomServerInput, String> {- Ok(crate::openhuman::mcp::registry::custom::CustomServerInput {- display_name: read_required(params, "display_name")?,- transport: read_required(params, "transport")?,- command: read_optional(params, "command")?,- args: read_optional(params, "args")?.unwrap_or_default(),- url: read_optional(params, "url")?,- env: read_optional(params, "env")?.unwrap_or_default(),- description: read_optional(params, "description")?,- })-}--fn handle_add_custom(params: Map<String, Value>) -> ControllerFuture {- Box::pin(async move {- let config = config_rpc::load_config_with_timeout().await?;- let input = custom_input(¶ms)?;- to_json(- crate::openhuman::mcp::registry::custom::ops::mcp_clients_add_custom(&config, input)- .await?,- )- })-}--fn handle_update_custom(params: Map<String, Value>) -> ControllerFuture {- Box::pin(async move {- let config = config_rpc::load_config_with_timeout().await?;- let server_id = read_required::<String>(¶ms, "server_id")?;- let input = custom_input(¶ms)?;- to_json(- crate::openhuman::mcp::registry::custom::ops::mcp_clients_update_custom(- &config, server_id, input,- )- .await?,- )- })-}fn handle_status(params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {