Skip to content

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

feat(mcp): scrub credentials from static remote tool metadata

Steven Enamakelc82115ac6b9d
diff --git a/crates/openhuman-core/src/mcp/module_client.rs b/crates/openhuman-core/src/mcp/module_client.rs
index 16da6c467a..eeb3a1371b 100644
--- a/crates/openhuman-core/src/mcp/module_client.rs
+++ b/crates/openhuman-core/src/mcp/module_client.rs
@@ -22,7 +22,7 @@ use serde_json::Value;
use tinymcp_bus::{
agent_tools::{McpToolPresentation, PrepareAgentToolsRequest},
config::{McpClientConfig, OpenConfiguredRequest, OpenConfiguredResponse, TransitionStatus},
- names, SupervisorBatch,
+ names, McpRemoteTool, ScrubStaticToolsRequest, SupervisorBatch,
};
use crate::{
@@ -353,6 +353,25 @@ impl McpConfiguredClient {
self.port.prepare_agent_tools(request).await
}
+ /// Scrubs configured credentials from static remote tool metadata inside
+ /// TinyMCP before the host screens or presents that metadata.
+ pub(crate) async fn scrub_static_tools(
+ &self,
+ config: &McpClientConfig,
+ server: &str,
+ tools: Vec<McpRemoteTool>,
+ ) -> Result<Vec<McpRemoteTool>, ModuleCallError> {
+ self.call_confidential(
+ config,
+ names::methods::STATIC_SCRUB_TOOLS,
+ (ScrubStaticToolsRequest {
+ server: server.to_owned(),
+ tools,
+ },),
+ )
+ .await
+ }
+
async fn call_inner<R: DeserializeOwned>(
&self,
config: &McpClientConfig,
diff --git a/crates/openhuman-core/src/mcp/module_client_tests.rs b/crates/openhuman-core/src/mcp/module_client_tests.rs
index 35e6a4e5a3..54da2a8e11 100644
--- a/crates/openhuman-core/src/mcp/module_client_tests.rs
+++ b/crates/openhuman-core/src/mcp/module_client_tests.rs
@@ -98,6 +98,14 @@ impl McpModulePort for FakePort {
if self.block_calls.load(std::sync::atomic::Ordering::SeqCst) {
self.release_call.notified().await;
}
+ if member == names::methods::STATIC_SCRUB_TOOLS {
+ let tools = args
+ .get(0)
+ .and_then(|request| request.get("tools"))
+ .cloned()
+ .ok_or(ModuleCallError::ModuleFault)?;
+ return Ok(tools);
+ }
Ok(Value::Bool(true))
}
@@ -152,6 +160,34 @@ async fn agent_tool_names_are_requested_from_the_module_root() {
assert_eq!(requests.lock().unwrap().as_slice(), &[request]);
}
+#[tokio::test]
+async fn static_tool_metadata_scrubbing_uses_confidential_module_delivery() {
+ let port = FakePort::default();
+ let calls = Arc::clone(&port.calls);
+ let client = client(port);
+ let config = configured("docs");
+ let tool = McpRemoteTool {
+ name: "search".to_owned(),
+ title: Some("Docs search".to_owned()),
+ description: Some("Search docs".to_owned()),
+ input_schema: serde_json::json!({"type":"object"}),
+ meta: Some(serde_json::json!({"ui":{"resourceUri":"ui://search"}})),
+ };
+
+ let returned = client
+ .scrub_static_tools(&config, "docs", vec![tool.clone()])
+ .await
+ .unwrap();
+
+ assert_eq!(returned, [tool]);
+ let calls = calls.lock().unwrap();
+ assert_eq!(calls.len(), 1);
+ assert_eq!(calls[0].1, names::methods::STATIC_SCRUB_TOOLS);
+ assert_eq!(calls[0].2[0]["server"], "docs");
+ assert_eq!(calls[0].2[0]["tools"][0]["name"], "search");
+ assert!(calls[0].3, "raw remote metadata must cross confidentially");
+}
+
#[tokio::test]
async fn supervisor_drain_only_uses_an_open_object_and_keeps_the_bounded_limit() {
let port = FakePort::default();