Skip to content

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

fix(mcp): route tool argument normalization through the module port

Steven Enamakel8605ed77917f
diff --git a/crates/openhuman-core/src/mcp/module_client.rs b/crates/openhuman-core/src/mcp/module_client.rs
index 90eeb87495..dfa4d45cc8 100644
--- a/crates/openhuman-core/src/mcp/module_client.rs
+++ b/crates/openhuman-core/src/mcp/module_client.rs
@@ -96,6 +96,14 @@ pub(crate) trait McpModulePort: Send + Sync {
&self,
request: ValidateServerArgumentsRequest,
) -> Result<ServerArgumentsValidation, ModuleCallError>;
+
+ /// Normalizes model-supplied arguments through TinyMCP's root operation.
+ async fn normalize_tool_arguments(
+ &self,
+ _arguments: Option<Value>,
+ ) -> Result<Map<String, Value>, ModuleCallError> {
+ Err(ModuleCallError::IncompatibleContract)
+ }
}
struct TinyMcpPort {
@@ -184,6 +192,15 @@ impl McpModulePort for TinyMcpPort {
)
.await
}
+
+ async fn normalize_tool_arguments(
+ &self,
+ arguments: Option<Value>,
+ ) -> Result<Map<String, Value>, ModuleCallError> {
+ self.root
+ .call(MODULE, names::methods::NORMALIZE_TOOL_ARGUMENTS, (arguments,))
+ .await
+ }
}
/// One workspace's serialized TinyMCP lifecycle and private object proxy.
@@ -405,15 +422,12 @@ impl McpConfiguredClient {
/// implementation operation.
pub(crate) async fn normalize_tool_arguments(
&self,
- config: &McpClientConfig,
arguments: Value,
) -> Result<Map<String, Value>, ModuleCallError> {
- self.call_confidential(
- config,
- names::methods::NORMALIZE_TOOL_ARGUMENTS,
- (Some(arguments),),
- )
- .await
+ if SHUTTING_DOWN.load(Ordering::Acquire) {
+ return Err(ModuleCallError::Unavailable);
+ }
+ self.port.normalize_tool_arguments(Some(arguments)).await
}
/// Loads and prepares configured-server tools from TinyMCP's persistent
diff --git a/crates/openhuman-core/src/tools/impl/network/mcp.rs b/crates/openhuman-core/src/tools/impl/network/mcp.rs
index ccb2a6390e..bc98c18327 100644
--- a/crates/openhuman-core/src/tools/impl/network/mcp.rs
+++ b/crates/openhuman-core/src/tools/impl/network/mcp.rs
@@ -360,7 +360,7 @@ impl Tool for McpCallTool {
.cloned()
.ok_or_else(|| anyhow::anyhow!("missing MCP tool arguments"))?;
let arguments = client
- .normalize_tool_arguments(&client_config, arguments)
+ .normalize_tool_arguments(arguments)
.await
.map_err(|_| anyhow::anyhow!("invalid MCP tool arguments"))?;
Ok(Some(call.with_arguments(Value::Object(arguments))))
@@ -393,7 +393,7 @@ impl Tool for McpCallTool {
};
let client_config = host::client_config(&self.config);
let arguments = match client
- .normalize_tool_arguments(&client_config, arguments)
+ .normalize_tool_arguments(arguments)
.await
{
Ok(arguments) => Value::Object(arguments),