The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: files changed crates/openhuman-core/src/mcp/module_client_tests.rs,crates/openhuman-core/src/
Steven Enamakelc4373e6a8f54
diff --git a/crates/openhuman-core/src/mcp/module_client_tests.rs b/crates/openhuman-core/src/mcp/module_client_tests.rsindex 989040ba60..6928ddab33 100644--- a/crates/openhuman-core/src/mcp/module_client_tests.rs+++ b/crates/openhuman-core/src/mcp/module_client_tests.rs@@ -8,6 +8,7 @@ struct FakePort {closed: Arc<Mutex<Vec<String>>>,calls: Arc<Mutex<Vec<(String, String, Value, bool)>>>,prepared_requests: Arc<Mutex<Vec<PrepareAgentToolsRequest>>>,+ validation_requests: Arc<Mutex<Vec<ValidateServerArgumentsRequest>>>,open_started: Arc<Notify>,close_started: Arc<Notify>,call_started: Arc<Notify>,@@ -149,6 +150,15 @@ impl McpModulePort for FakePort {}).collect())}++ async fn validate_server_arguments(+ &self,+ request: ValidateServerArgumentsRequest,+ ) -> Result<ServerArgumentsValidation, ModuleCallError> {+ let arguments = request.arguments.as_object().cloned().unwrap_or_default();+ self.validation_requests.lock().unwrap().push(request);+ Ok(ServerArgumentsValidation::Valid(arguments))+ }}#[tokio::test]@@ -174,6 +184,28 @@ async fn agent_tool_names_are_requested_from_the_module_root() {assert_eq!(requests.lock().unwrap().as_slice(), &[request]);}+#[tokio::test]+async fn generic_server_argument_validation_uses_the_module_root() {+ let port = FakePort::default();+ let requests = Arc::clone(&port.validation_requests);+ let client = client(port);+ let request = ValidateServerArgumentsRequest {+ arguments: serde_json::json!({"query": " topic "}),+ allowed: vec!["query".to_owned()],+ rules: vec![tinymcp_bus::ServerArgumentRule::RequiredNonEmptyString {+ key: "query".to_owned(),+ }],+ };++ let result = client+ .validate_server_arguments(request.clone())+ .await+ .expect("module validation");++ assert_eq!(result, ServerArgumentsValidation::Valid(serde_json::json!({"query": " topic "}).as_object().unwrap().clone()));+ assert_eq!(requests.lock().unwrap().as_slice(), &[request]);+}+#[tokio::test]async fn static_tool_metadata_scrubbing_uses_confidential_module_delivery() {let port = FakePort::default();diff --git a/crates/openhuman-core/src/tools/impl/network/gitbooks.rs b/crates/openhuman-core/src/tools/impl/network/gitbooks.rsindex ecfca19350..041a307cb3 100644--- a/crates/openhuman-core/src/tools/impl/network/gitbooks.rs+++ b/crates/openhuman-core/src/tools/impl/network/gitbooks.rs@@ -1,34 +1,47 @@-//! `gitbooks` — answer questions about OpenHuman by talking to the-//! GitBook MCP server through the shared `crate::mcp::http_client` path.--use crate::mcp::http_client::{redact_endpoint, McpHttpClient};+//! `gitbooks` — answer questions about OpenHuman through the TinyMCP module's+//! confidential one-shot tool-call contract.++use crate::{+ config::Config,+ mcp::http_client::redact_endpoint,+ modules::client::{ModuleCallError, ModuleClient},+};use async_trait::async_trait;use serde_json::{json, Value};-use std::sync::Arc;+use std::time::Duration;use tinytools::{PermissionLevel, Tool, ToolResult};pub struct GitbooksSearchTool {- client: Arc<McpHttpClient>,+ endpoint: String,+ timeout_secs: u64,+ client: ModuleClient,}impl GitbooksSearchTool {/// Builds the tool.///- /// Fallible because the client is: a malformed proxy URL or an unusable- /// TLS setting stops one being built. It used to panic on that; a- /// documentation tool taking the process down over a proxy setting is not- /// a trade anyone would choose.+ /// The endpoint and timeout are retained as one-shot server configuration;+ /// TinyMCP owns the HTTP client and transport lifecycle.////// # Errors///- /// Returns the reason the client could not be built.- pub fn new(endpoint: String, timeout_secs: u64) -> Result<Self, String> {+ /// Returns the reason the tool configuration could not be built.+ pub fn new(endpoint: String, timeout_secs: u64, config: Config) -> Result<Self, String> {Ok(Self {- client: Arc::new(- McpHttpClient::new(endpoint, timeout_secs).map_err(|error| error.to_string())?,- ),+ endpoint,+ timeout_secs,+ client: ModuleClient::new(config).with_timeout(Duration::from_secs(timeout_secs)),})}++ #[cfg(test)]+ fn with_client(endpoint: String, timeout_secs: u64, client: ModuleClient) -> Self {+ Self {+ endpoint,+ timeout_secs,+ client,+ }+ }}#[async_trait]@@ -76,44 +89,48 @@ impl Tool for GitbooksSearchTool {tracing::debug!(target: "[gitbooks]",- endpoint = %redact_endpoint(self.client.endpoint()),+ endpoint = %redact_endpoint(&self.endpoint),tool = "searchDocumentation","dispatching via shared MCP client");- match self- .client- .call_tool("searchDocumentation", json!({ "query": query }))- .await- {- Ok(result) => Ok(tinymcp::tools::tool_result(result.rendered)),- Err(e) => Ok(ToolResult::error(format!("gitbooks_search failed: {e}"))),- }+ Ok(self+ .call("searchDocumentation", json!({ "query": query }), "gitbooks_search")+ .await)}}pub struct GitbooksGetPageTool {- client: Arc<McpHttpClient>,+ endpoint: String,+ timeout_secs: u64,+ client: ModuleClient,}impl GitbooksGetPageTool {/// Builds the tool.///- /// Fallible because the client is: a malformed proxy URL or an unusable- /// TLS setting stops one being built. It used to panic on that; a- /// documentation tool taking the process down over a proxy setting is not- /// a trade anyone would choose.+ /// The endpoint and timeout are retained as one-shot server configuration;+ /// TinyMCP owns the HTTP client and transport lifecycle.////// # Errors///- /// Returns the reason the client could not be built.- pub fn new(endpoint: String, timeout_secs: u64) -> Result<Self, String> {+ /// Returns the reason the tool configuration could not be built.+ pub fn new(endpoint: String, timeout_secs: u64, config: Config) -> Result<Self, String> {Ok(Self {- client: Arc::new(- McpHttpClient::new(endpoint, timeout_secs).map_err(|error| error.to_string())?,- ),+ endpoint,+ timeout_secs,+ client: ModuleClient::new(config).with_timeout(Duration::from_secs(timeout_secs)),})}++ #[cfg(test)]+ fn with_client(endpoint: String, timeout_secs: u64, client: ModuleClient) -> Self {+ Self {+ endpoint,+ timeout_secs,+ client,+ }+ }}#[async_trait]@@ -160,19 +177,67 @@ impl Tool for GitbooksGetPageTool {tracing::debug!(target: "[gitbooks]",- endpoint = %redact_endpoint(self.client.endpoint()),+ endpoint = %redact_endpoint(&self.endpoint),tool = "getPage","dispatching via shared MCP client");- match self- .client- .call_tool("getPage", json!({ "url": url }))+ Ok(self+ .call("getPage", json!({ "url": url }), "gitbooks_get_page")+ .await)+ }+}++impl GitbooksSearchTool {+ async fn call(&self, tool: &str, arguments: Value, label: &str) -> ToolResult {+ configured_call(&self.client, &self.endpoint, self.timeout_secs, tool, arguments, label).await- {- Ok(result) => Ok(tinymcp::tools::tool_result(result.rendered)),- Err(e) => Ok(ToolResult::error(format!("gitbooks_get_page failed: {e}"))),- }+ }+}++impl GitbooksGetPageTool {+ async fn call(&self, tool: &str, arguments: Value, label: &str) -> ToolResult {+ configured_call(&self.client, &self.endpoint, self.timeout_secs, tool, arguments, label)+ .await+ }+}++async fn configured_call(+ client: &ModuleClient,+ endpoint: &str,+ timeout_secs: u64,+ tool: &str,+ arguments: Value,+ label: &str,+) -> ToolResult {+ let request = tinymcp_bus::ConfiguredToolCallRequest {+ server: tinymcp_bus::McpServerConfig {+ name: "openhuman-gitbooks".to_owned(),+ endpoint: endpoint.to_owned(),+ timeout_secs,+ ..Default::default()+ },+ tool: tool.to_owned(),+ arguments,+ };+ match client+ .call_confidential(+ "tinymcp",+ tinymcp_bus::names::methods::CONFIGURED_TOOL_CALL,+ (request,),+ )+ .await+ {+ Ok(call) if call.outcome.ok => call+ .rendered+ .map(tinymcp::tools::tool_result)+ .unwrap_or_else(|| ToolResult::error(format!("{label} failed: empty module result"))),+ Ok(call) => ToolResult::error(format!(+ "{label} failed: {}",+ call.error_message+ .unwrap_or_else(|| "MCP server call failed".to_owned())+ )),+ Err(error) => ToolResult::error(format!("{label} failed: {error}")),}}diff --git a/crates/openhuman-core/src/tools/impl/network/gitbooks_tests.rs b/crates/openhuman-core/src/tools/impl/network/gitbooks_tests.rsindex a37d2988cb..01583873f2 100644--- a/crates/openhuman-core/src/tools/impl/network/gitbooks_tests.rs+++ b/crates/openhuman-core/src/tools/impl/network/gitbooks_tests.rs@@ -181,7 +181,12 @@ fn redact_endpoint_keeps_only_origin() {#[tokio::test]async fn search_rejects_empty_query() {- let t = GitbooksSearchTool::new("https://example.com/mcp".into(), 5).expect("a client builds");+ let t = GitbooksSearchTool::new(+ "https://example.com/mcp".into(),+ 5,+ crate::config::Config::default(),+ )+ .expect("a tool builds");let result = t.execute(json!({"query": " "})).await.unwrap();assert!(result.is_error);assert!(result.output().contains("empty"));@@ -189,7 +194,12 @@ async fn search_rejects_empty_query() {#[tokio::test]async fn get_page_rejects_empty_url() {- let t = GitbooksGetPageTool::new("https://example.com/mcp".into(), 5).expect("a client builds");+ let t = GitbooksGetPageTool::new(+ "https://example.com/mcp".into(),+ 5,+ crate::config::Config::default(),+ )+ .expect("a tool builds");let result = t.execute(json!({"url": ""})).await.unwrap();assert!(result.is_error);}