Skip to content

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

feat(mcp): add list_tools controller schema and handler

Steven Enamakelbaf1cde6363f
diff --git a/crates/openhuman-core/src/mcp/registry/schemas/handlers.rs b/crates/openhuman-core/src/mcp/registry/schemas/handlers.rs
index c4446af787..882330c210 100644
--- a/crates/openhuman-core/src/mcp/registry/schemas/handlers.rs
+++ b/crates/openhuman-core/src/mcp/registry/schemas/handlers.rs
@@ -112,6 +112,14 @@ pub(super) fn handle_status(params: Map<String, Value>) -> ControllerFuture {
})
}
+pub(super) fn handle_list_tools(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ let server_id = read_required::<String>(&params, "server_id")?;
+ to_json(crate::mcp::registry::ops::mcp_clients_list_tools(&config, server_id).await?)
+ })
+}
+
pub(super) fn handle_tool_call(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let server_id = read_required::<String>(&params, "server_id")?;
diff --git a/crates/openhuman-core/src/mcp/registry/schemas/registry.rs b/crates/openhuman-core/src/mcp/registry/schemas/registry.rs
index c62eedfdd4..2f308b798e 100644
--- a/crates/openhuman-core/src/mcp/registry/schemas/registry.rs
+++ b/crates/openhuman-core/src/mcp/registry/schemas/registry.rs
@@ -7,9 +7,9 @@ use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
use super::handlers::{
handle_config_get, handle_config_set, handle_connect, handle_detect_auth, handle_disconnect,
- handle_installed_list, handle_oauth_begin, handle_registry_get, handle_registry_search,
- handle_registry_settings_get, handle_registry_settings_set, handle_set_enabled, handle_status,
- handle_tool_call, handle_uninstall, handle_update_env,
+ handle_installed_list, handle_list_tools, handle_oauth_begin, handle_registry_get,
+ handle_registry_search, handle_registry_settings_get, handle_registry_settings_set,
+ handle_set_enabled, handle_status, handle_tool_call, handle_uninstall, handle_update_env,
};
// ── Schema registry ──────────────────────────────────────────────────────────
@@ -28,6 +28,7 @@ pub fn all_controller_schemas() -> Vec<ControllerSchema> {
schemas("connect"),
schemas("disconnect"),
schemas("status"),
+ schemas("list_tools"),
schemas("tool_call"),
schemas("registry_settings_get"),
schemas("registry_settings_set"),
@@ -85,6 +86,10 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
schema: schemas("status"),
handler: handle_status,
},
+ RegisteredController {
+ schema: schemas("list_tools"),
+ handler: handle_list_tools,
+ },
RegisteredController {
schema: schemas("tool_call"),
handler: handle_tool_call,
@@ -441,6 +446,32 @@ pub fn schemas(function: &str) -> ControllerSchema {
}],
},
+ "list_tools" => ControllerSchema {
+ namespace: "mcp_clients",
+ function: "list_tools",
+ description: "The tools a connected server advertises, after the prompt-injection scan. Errors when the server is not connected.",
+ inputs: vec![FieldSchema {
+ name: "server_id",
+ ty: TypeSchema::String,
+ comment: "UUID of a connected server.",
+ required: true,
+ }],
+ outputs: vec![
+ FieldSchema {
+ name: "server_id",
+ ty: TypeSchema::String,
+ comment: "The server asked about.",
+ required: true,
+ },
+ FieldSchema {
+ name: "tools",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Ref("McpTool"))),
+ comment: "The advertised tools.",
+ required: true,
+ },
+ ],
+ },
+
"tool_call" => ControllerSchema {
namespace: "mcp_clients",
function: "tool_call",
diff --git a/crates/openhuman-core/src/mcp/registry/schemas_tests.rs b/crates/openhuman-core/src/mcp/registry/schemas_tests.rs
index bb92e71988..d736752f2e 100644
--- a/crates/openhuman-core/src/mcp/registry/schemas_tests.rs
+++ b/crates/openhuman-core/src/mcp/registry/schemas_tests.rs
@@ -72,13 +72,15 @@ fn schemas_unknown_function_returns_placeholder() {
#[test]
fn all_controller_schemas_covers_expected_methods() {
let schemas = all_controller_schemas();
- // 16 mcp_clients: the catalog install and the configuration assistant went
- // with the setup agent; config_get / config_set (mcp.json) took their place.
- assert_eq!(schemas.len(), 16);
+ // 17 mcp_clients: the catalog install and the configuration assistant went
+ // with the setup agent; config_get / config_set (mcp.json) and list_tools
+ // took their place.
+ assert_eq!(schemas.len(), 17);
assert!(schemas.iter().all(|s| s.namespace == "mcp_clients"));
let functions: Vec<_> = schemas.iter().map(|s| s.function).collect();
assert!(functions.contains(&"config_get"));
assert!(functions.contains(&"config_set"));
+ assert!(functions.contains(&"list_tools"));
assert!(!functions.contains(&"install"));
assert!(!functions.contains(&"config_assist"));
// The #3039 + #3196 additions are present.
@@ -94,7 +96,7 @@ fn all_controller_schemas_covers_expected_methods() {
#[test]
fn all_registered_controllers_has_handler_per_schema() {
let controllers = all_registered_controllers();
- assert_eq!(controllers.len(), 16);
+ assert_eq!(controllers.len(), 17);
}
#[test]