Skip to content

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

test(tool_registry): exercise real loopback MCP server in approval e2e

Steven Enamakeld6a451ca906b
diff --git a/scripts/test-rust-with-mock.sh b/scripts/test-rust-with-mock.sh
index 706505843e..5ecb7cd107 100755
--- a/scripts/test-rust-with-mock.sh
+++ b/scripts/test-rust-with-mock.sh
@@ -241,7 +241,8 @@ run_raw_coverage_modules() {
# path. These groups verify the host-to-module round trip, so inject the
# pinned connector only for their processes.
if [ "$module" = "composio_direct_client_e2e" ] ||
- [ "$module" = "composio_direct_tools_e2e" ]; then
+ [ "$module" = "composio_direct_tools_e2e" ] ||
+ [ "$module" = "composio_host_helpers_e2e" ]; then
OPENHUMAN_MODULE_PATH="$connectors_module_path" \
cargo_test --test raw_coverage_all -- "${module}::" --test-threads=1 "$@"
elif [ "$module" = "automation_scheduling_e2e" ]; then
diff --git a/tests/raw_coverage/host_inference_http_e2e.rs b/tests/raw_coverage/host_inference_http_e2e.rs
index c810928671..a647017e0e 100644
--- a/tests/raw_coverage/host_inference_http_e2e.rs
+++ b/tests/raw_coverage/host_inference_http_e2e.rs
@@ -342,9 +342,11 @@ fn remember(state: &MockState, path: &str, body: Value) {
fn temp_config(tmp: &TempDir) -> Config {
let root = tmp.path().join(".openhuman");
std::fs::create_dir_all(root.join("workspace")).expect("workspace dir");
- let mut config = Config::default();
- config.config_path = root.join("config.toml");
- config.workspace_dir = root.join("workspace");
+ let mut config = Config {
+ config_path: root.join("config.toml"),
+ workspace_dir: root.join("workspace"),
+ ..Config::default()
+ };
config.secrets.encrypt = false;
config.api_url = Some("http://127.0.0.1:9".to_string());
config
diff --git a/tests/raw_coverage/tool_registry_approval_e2e.rs b/tests/raw_coverage/tool_registry_approval_e2e.rs
index 59d5f5739c..ed7372d3bd 100644
--- a/tests/raw_coverage/tool_registry_approval_e2e.rs
+++ b/tests/raw_coverage/tool_registry_approval_e2e.rs
@@ -197,7 +197,7 @@ async fn rpc(rpc_base: &str, id: i64, method: &str, params: Value) -> Value {
.unwrap_or_else(|err| panic!("json for {method}: {err}"))
}
-fn test_mcp_server() -> InstalledServer {
+fn test_mcp_server(endpoint: &str) -> InstalledServer {
InstalledServer {
server_id: format!("tool-registry-test-{}", uuid::Uuid::new_v4()),
qualified_name: "@openhuman-test/echo".to_string(),
@@ -205,13 +205,15 @@ fn test_mcp_server() -> InstalledServer {
description: Some("Stub MCP server used by tool registry coverage tests.".to_string()),
icon_url: None,
command_kind: CommandKind::Binary,
- command: env!("CARGO_BIN_EXE_test-mcp-stub").to_string(),
+ command: String::new(),
args: Vec::new(),
env_keys: Vec::new(),
config: None,
installed_at: 0,
last_connected_at: None,
- transport: Transport::Stdio,
+ transport: Transport::HttpRemote {
+ url: endpoint.to_string(),
+ },
enabled: true,
}
}
@@ -222,12 +224,8 @@ async fn install_test_mcp_server(config: &Config, server: &InstalledServer) -> I
json!({
"mcpServers": {
server.qualified_name.clone(): {
- "command": server.command.clone(),
- "args": server.args.clone(),
+ "url": server.transport.deployment_url().expect("HTTP fixture URL"),
"enabled": false,
- // This test owns the local stub executable and vouches for
- // it explicitly; production-installed servers stay untrusted.
- "operator_trusted": true,
}
}
}),
@@ -400,12 +398,13 @@ enabled = true
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn tool_registry_entries_include_connected_mcp_client_tools() {
+ let mcp_server = crate::local_mcp_http::LocalMcpHttpServer::start_echo().await;
let tmp = tempdir().expect("tempdir");
let config = Config {
workspace_dir: tmp.path().to_path_buf(),
..Config::default()
};
- let server = install_test_mcp_server(&config, &test_mcp_server()).await;
+ let server = install_test_mcp_server(&config, &test_mcp_server(mcp_server.endpoint())).await;
openhuman_core::mcp::registry::ops::mcp_clients_set_enabled(
&config,
server.server_id.clone(),
@@ -417,6 +416,22 @@ async fn tool_registry_entries_include_connected_mcp_client_tools() {
.await
.expect("connect test mcp server");
assert_eq!(tools.first().map(|tool| tool.name.as_str()), Some("echo"));
+ let canary = "TOOL_REGISTRY_MCP_ECHO_CANARY";
+ let call = openhuman_core::mcp::registry::ops::mcp_clients_tool_call(
+ &config,
+ server.server_id.clone(),
+ "echo".to_string(),
+ json!({ "message": canary }),
+ )
+ .await
+ .expect("call test MCP tool");
+ assert_eq!(call.value["is_error"], false);
+ assert_eq!(call.value["result"]["content"][0]["text"], canary);
+ assert_eq!(
+ mcp_server.tool_calls(),
+ vec![json!({ "name": "echo", "arguments": { "message": canary } })],
+ "the actual loopback MCP server must receive the tool call"
+ );
// A second workspace, so that scoping is what the assertions below actually
// test. With one workspace open, `registry_entries()` and the config-scoped
@@ -426,7 +441,12 @@ async fn tool_registry_entries_include_connected_mcp_client_tools() {
workspace_dir: other_tmp.path().to_path_buf(),
..Config::default()
};
- let other_server = install_test_mcp_server(&other_config, &test_mcp_server()).await;
+ let other_mcp_server = crate::local_mcp_http::LocalMcpHttpServer::start_echo().await;
+ let other_server = install_test_mcp_server(
+ &other_config,
+ &test_mcp_server(other_mcp_server.endpoint()),
+ )
+ .await;
openhuman_core::mcp::registry::ops::mcp_clients_set_enabled(
&other_config,
other_server.server_id.clone(),
diff --git a/tests/raw_coverage_all.rs b/tests/raw_coverage_all.rs
index 60d79140c1..824c015ddf 100644
--- a/tests/raw_coverage_all.rs
+++ b/tests/raw_coverage_all.rs
@@ -90,5 +90,9 @@ pub mod env_guard;
pub mod rpc_auth;
#[path = "support/rpc_harness.rs"]
pub mod rpc_harness;
+/// A loopback Streamable HTTP MCP server for tests that exercise the real
+/// TinyMCP client without involving stdio trust or sandbox policy.
+#[path = "support/local_mcp_http.rs"]
+pub mod local_mcp_http;
include!(concat!(env!("OUT_DIR"), "/raw_coverage_mods.rs"));