Skip to content

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

fix(mcp): tolerate string-encoded JSON arguments in tool calls

Steven Enamakel72da9b37f191
diff --git a/crates/openhuman-core/src/mcp/registry/tools.rs b/crates/openhuman-core/src/mcp/registry/tools.rs
index b5a8670bea..5658af2cfb 100644
--- a/crates/openhuman-core/src/mcp/registry/tools.rs
+++ b/crates/openhuman-core/src/mcp/registry/tools.rs
@@ -24,7 +24,7 @@
use std::sync::Arc;
use async_trait::async_trait;
-use serde_json::{Value};
+use serde_json::Value;
use crate::config::Config;
use tinymcp_bus::agent_tools::{
@@ -125,7 +125,6 @@ registry_tool! {
impl Tool for McpRegistrySearchTool {
spec_metadata!();
-
async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
let query = args
.get("query")
@@ -155,7 +154,6 @@ registry_tool! {
impl Tool for McpRegistryGetTool {
spec_metadata!();
-
async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
let qn = req_str(&args, "qualified_name")?;
emit!(
@@ -173,7 +171,6 @@ registry_tool! {
impl Tool for McpRegistryInstalledListTool {
spec_metadata!();
-
async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {
emit!(
ops::mcp_clients_installed_list(&self.config).await,
@@ -260,7 +257,12 @@ impl Tool for McpRegistryToolCallTool {
async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
let sid = req_str(&args, "server_id")?;
let tool_name = req_str(&args, "tool_name")?;
- let arguments = args.get("arguments").cloned().unwrap_or(json!({}));
+ // Tolerant at execution, unchanged in the schema: an object that
+ // arrived JSON-encoded in a string is decoded, and anything that
+ // cannot hold one is refused here, naming what arrived.
+ let arguments = normalize_tool_arguments(args.get("arguments").cloned())
+ .map(Value::Object)
+ .map_err(|error| anyhow::anyhow!("mcp_registry_tool_call: {error}"))?;
emit!(
ops::mcp_clients_tool_call(&self.config, sid, tool_name, arguments).await,
"mcp_registry_tool_call"