Skip to content

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

feat(mcp): add local mcp_list_servers tool

Steven Enamakel8e53d843e63f
diff --git a/crates/openhuman-core/src/tools/impl/network/mcp.rs b/crates/openhuman-core/src/tools/impl/network/mcp.rs
index 47c89e22b7..78b7ee0e70 100644
--- a/crates/openhuman-core/src/tools/impl/network/mcp.rs
+++ b/crates/openhuman-core/src/tools/impl/network/mcp.rs
@@ -16,7 +16,110 @@ use crate::{
security::{SecurityPolicy, ToolOperation},
};
-pub use tinymcp::tools::McpListServersTool;
+/// Lists configured MCP servers through TinyMCP's safe summary operation.
+pub struct McpListServersTool {
+ config: Arc<Config>,
+}
+
+impl McpListServersTool {
+ /// Builds the server-list tool for one configured workspace.
+ #[must_use]
+ pub fn new(config: Arc<Config>) -> Self {
+ Self { config }
+ }
+}
+
+#[async_trait]
+impl Tool for McpListServersTool {
+ fn name(&self) -> &str {
+ "mcp_list_servers"
+ }
+
+ fn description(&self) -> &str {
+ "List named remote MCP servers registered in OpenHuman core. Use this before browsing tools on a specific MCP server."
+ }
+
+ fn parameters_schema(&self) -> Value {
+ json!({
+ "type": "object",
+ "properties": {},
+ "additionalProperties": false
+ })
+ }
+
+ fn permission_level(&self) -> PermissionLevel {
+ PermissionLevel::ReadOnly
+ }
+
+ fn supports_markdown(&self) -> bool {
+ true
+ }
+
+ async fn execute(&self, _args: Value) -> anyhow::Result<ToolResult> {
+ let client = match McpConfiguredClient::for_config(&self.config) {
+ Ok(client) => client,
+ Err(_) => return Ok(ToolResult::error("mcp_list_servers failed: TinyMCP is unavailable")),
+ };
+ let config = host::client_config(&self.config);
+ let summaries: Vec<tinymcp_bus::StaticServerSummary> = match client
+ .call_confidential(
+ &config,
+ tinymcp_bus::names::methods::STATIC_SERVER_SUMMARIES,
+ (),
+ )
+ .await
+ {
+ Ok(summaries) => summaries,
+ Err(_) => return Ok(ToolResult::error("mcp_list_servers failed: module call failed")),
+ };
+ let servers = summaries
+ .iter()
+ .map(|server| {
+ json!({
+ "name": server.name,
+ "endpoint": server.endpoint,
+ "description": server.description,
+ "timeout_secs": server.timeout_secs,
+ "allowed_tools": server.allowed_tools,
+ "disallowed_tools": server.disallowed_tools,
+ "auth_configured": server.auth_configured,
+ "auth_kind": server.auth_kind,
+ "source": server.source,
+ })
+ })
+ .collect::<Vec<_>>();
+ let mut markdown = String::from("# MCP Servers\n");
+ if summaries.is_empty() {
+ markdown.push_str("\nNo remote MCP servers are registered.");
+ } else {
+ for server in &summaries {
+ markdown.push_str(&format!(
+ "\n- **{}** ({})\n - endpoint: `{}`\n - auth: `{}`",
+ server.name, server.source, server.endpoint, server.auth_kind
+ ));
+ if let Some(description) = server.description.as_deref() {
+ markdown.push_str(&format!("\n - {description}"));
+ }
+ if !server.allowed_tools.is_empty() {
+ markdown.push_str(&format!(
+ "\n - allowed tools: `{}`",
+ server.allowed_tools.join("`, `")
+ ));
+ }
+ if !server.disallowed_tools.is_empty() {
+ markdown.push_str(&format!(
+ "\n - disallowed tools: `{}`",
+ server.disallowed_tools.join("`, `")
+ ));
+ }
+ }
+ }
+ Ok(ToolResult::success_with_markdown(
+ json!({ "servers": servers }),
+ markdown,
+ ))
+ }
+}
/// The host adapter for browsing tools on one configured static server.
pub struct McpListToolsTool {
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index 388f1d5128..d727a0dafe 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -642,8 +642,9 @@ pub fn all_tools_with_runtime(
mcp_registry.list().len()
);
if !mcp_registry.is_empty() {
- tools.push(Box::new(McpListServersTool::new(Arc::clone(&mcp_registry))));
- tools.push(Box::new(McpListToolsTool::new(Arc::clone(&mcp_registry))));
+ let mcp_config = Arc::new(root_config.clone());
+ tools.push(Box::new(McpListServersTool::new(Arc::clone(&mcp_config))));
+ tools.push(Box::new(McpListToolsTool::new(Arc::clone(&mcp_config))));
tools.push(Box::new(mcp_call_tool(
Arc::new(root_config.clone()),
security.clone(),