Skip to content

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

test(openhuman-embed): add mcp module smoke test

Steven Enamakel044caab79735
diff --git a/Cargo.lock b/Cargo.lock
index 39d22b7339..d5b065038f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5908,6 +5908,7 @@ dependencies = [
"tinyflows-module",
"tinyinference-embeddings",
"tinyinference-llm 0.5.0",
+ "tinymcp",
"tinymcp-bus",
"tinymemory-api",
"tinymemory-tools",
diff --git a/crates/openhuman-embed/Cargo.toml b/crates/openhuman-embed/Cargo.toml
index a8e5859fe8..65a0379bc7 100644
--- a/crates/openhuman-embed/Cargo.toml
+++ b/crates/openhuman-embed/Cargo.toml
@@ -115,6 +115,9 @@ tinyflows-bus = { path = "../../vendor/tinyflows/crates/tinyflows-bus" }
# the scheduler runtime and job store that `cron` reaches over the bus.
tinyflows-module = { path = "../../vendor/tinyflows/crates/tinyflows-module", features = ["static-link"] }
env_logger = "0.11"
+# The real tinymcp module, linked into the MCP module smoke test (never the
+# product): `mcp_call_tool` reaches it over the bus.
+tinymcp = { path = "../../vendor/tinymcp/crates/tinymcp", features = ["static-link"] }
# The profile tests and example implement a stub `BackendTransport`, whose
# `http_client` hands out a `reqwest::Client`. Same features as the core's, so
# the dev graph adds no reqwest feature (see the unification note below).
@@ -187,3 +190,9 @@ required-features = ["channels"]
[[example]]
name = "profiles"
required-features = ["profiles"]
+
+# One host smoke test for tinymcp: an embedded runtime calls a tool on a
+# scripted HTTP MCP server through the module.
+[[test]]
+name = "mcp_module"
+required-features = ["mcp", "modules"]
diff --git a/crates/openhuman-embed/tests/mcp_module.rs b/crates/openhuman-embed/tests/mcp_module.rs
new file mode 100644
index 0000000000..83e89f2bb6
--- /dev/null
+++ b/crates/openhuman-embed/tests/mcp_module.rs
@@ -0,0 +1,110 @@
+//! Host smoke test for the tinymcp module: an embedded runtime that declares an
+//! HTTP MCP server reaches a tool on it through the module.
+//!
+//! The module is linked into the test binary (`register_linked`) instead of
+//! downloaded; the host still supplies everything a released module gets.
+
+mod common;
+
+use common::{chat_completion, offline_config, route, runtime, scripted_provider, stub_backend};
+use openhuman_core::config::schema::{ModuleOverride, ModuleSourceMode};
+use openhuman_embed::{Access, AgentSpec, McpServer, Runtime, RuntimeModule, ServiceSet, Workspace};
+
+struct McpStub;
+
+impl wiremock::Respond for McpStub {
+ fn respond(&self, request: &wiremock::Request) -> wiremock::ResponseTemplate {
+ let body: serde_json::Value = serde_json::from_slice(&request.body).unwrap_or_default();
+ let result = match body["method"].as_str().unwrap_or_default() {
+ "initialize" => serde_json::json!({
+ "protocolVersion": "2025-06-18",
+ "capabilities": { "tools": {} },
+ "serverInfo": { "name": "forecast", "version": "1" }
+ }),
+ "notifications/initialized" => return wiremock::ResponseTemplate::new(202),
+ "tools/list" => serde_json::json!({ "tools": [{
+ "name": "forecast",
+ "description": "Local forecast",
+ "inputSchema": { "type": "object" }
+ }] }),
+ "tools/call" => serde_json::json!({ "content": [{ "type": "text", "text": "sunny" }] }),
+ _ => serde_json::json!({}),
+ };
+ wiremock::ResponseTemplate::new(200)
+ .set_body_json(serde_json::json!({ "jsonrpc": "2.0", "id": body["id"], "result": result }))
+ }
+}
+
+#[test]
+fn an_embedded_runtime_calls_a_tool_through_the_tinymcp_module() {
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter("debug,hyper=info,reqwest=info")
+ .with_test_writer()
+ .try_init();
+ let rt = runtime();
+ openhuman_embed::modules::register_linked("tinymcp", tinymcp::linked_module);
+ rt.block_on(async {
+ let backend = stub_backend().await;
+ let mcp = wiremock::MockServer::start().await;
+ wiremock::Mock::given(wiremock::matchers::method("POST"))
+ .respond_with(McpStub)
+ .mount(&mcp)
+ .await;
+ let model = scripted_provider(
+ vec![common::tool_call_completion(
+ "mcp_call_tool",
+ r#"{"server":"forecast","tool":"forecast","arguments":{}}"#,
+ )],
+ "done",
+ )
+ .await;
+ let mut config = offline_config();
+ config.modules.allow_download = false;
+ config.modules.overrides.push(ModuleOverride::with_source(
+ "tinymcp",
+ ModuleSourceMode::Linked,
+ ));
+ let runtime = Runtime::builder()
+ .config(config)
+ .workspace(Workspace::Ephemeral)
+ .backend_url(backend.uri())
+ .provider(route(&model, "fixture"))
+ .services(ServiceSet::none())
+ .modules([
+ RuntimeModule::Agent,
+ RuntimeModule::Inference,
+ RuntimeModule::Memory,
+ RuntimeModule::Mcp,
+ RuntimeModule::Skills,
+ RuntimeModule::Automation,
+ ])
+ .build()
+ .await
+ .expect("runtime builds");
+ let agent = runtime
+ .agent(
+ AgentSpec::new("mcp-client")
+ .provider(route(&model, "fixture"))
+ .mcp(
+ McpServer::http("forecast", format!("{}/mcp", mcp.uri()))
+ .allow_tools(["forecast"]),
+ )
+ .access(Access::full()),
+ )
+ .expect("agent");
+ let reply = agent.run("call forecast").await.expect("turn");
+ let requests = common::chat_requests(&model).await;
+ let results = common::tool_results(requests.last().expect("a follow-up request"));
+ let methods: Vec<String> = mcp
+ .received_requests()
+ .await
+ .expect("recorded")
+ .iter()
+ .filter_map(|r| serde_json::from_slice::<serde_json::Value>(&r.body).ok()?["method"].as_str().map(str::to_string))
+ .collect();
+ eprintln!("REPLY={} RESULTS={results} METHODS={methods:?}", reply.reply);
+ assert!(methods.iter().any(|m| m == "tools/call"), "{methods:?} / {results}");
+ assert!(results.contains("sunny"), "{results}");
+ let _ = chat_completion;
+ });
+}