Skip to content

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

test(mcp): reformat golden test fixtures and add http golden test module

Steven Enamakel730430476011
diff --git a/crates/openhuman-core/src/mcp/server/http_golden_tests.rs b/crates/openhuman-core/src/mcp/server/http_golden_tests.rs
new file mode 100644
index 0000000000..fe5098b345
--- /dev/null
+++ b/crates/openhuman-core/src/mcp/server/http_golden_tests.rs
@@ -0,0 +1,358 @@
+//! Golden fixtures for the Streamable HTTP transport OpenHuman serves.
+//!
+//! Status codes, plain-text rejection bodies, content types, the session
+//! header and the JSON bodies are all wire behavior a remote client depends
+//! on. Captured before the transport moved into `tinymcp::server`; they must
+//! keep passing through that move unchanged.
+
+use reqwest::{header::CONTENT_TYPE, Client, Response, StatusCode};
+use serde_json::{json, Value};
+use tinymcp_bus::{HEADER_PROTOCOL_VERSION, HEADER_SESSION_ID, LATEST_PROTOCOL_VERSION};
+
+use super::test_support::spawn_http;
+
+const PLAIN_TEXT: &str = "text/plain; charset=utf-8";
+
+async fn initialize(http: &Client, endpoint: &str) -> String {
+ let response = post(http, endpoint, None, None, &init_body()).await;
+ assert_eq!(response.status(), StatusCode::OK);
+ response
+ .headers()
+ .get(HEADER_SESSION_ID)
+ .and_then(|value| value.to_str().ok())
+ .expect("session header")
+ .to_string()
+}
+
+fn init_body() -> Value {
+ json!({
+ "jsonrpc": "2.0",
+ "id": 1,
+ "method": "initialize",
+ "params": {
+ "protocolVersion": LATEST_PROTOCOL_VERSION,
+ "capabilities": {},
+ "clientInfo": {"name": "golden", "version": "0"}
+ }
+ })
+}
+
+async fn post(
+ http: &Client,
+ endpoint: &str,
+ session: Option<&str>,
+ protocol: Option<&str>,
+ body: &Value,
+) -> Response {
+ let mut request = http.post(endpoint).json(body);
+ if let Some(session) = session {
+ request = request.header(HEADER_SESSION_ID, session);
+ }
+ if let Some(protocol) = protocol {
+ request = request.header(HEADER_PROTOCOL_VERSION, protocol);
+ }
+ request.send().await.expect("post")
+}
+
+async fn assert_text(response: Response, status: StatusCode, body: &str) {
+ assert_eq!(response.status(), status);
+ assert_eq!(
+ response
+ .headers()
+ .get(CONTENT_TYPE)
+ .and_then(|v| v.to_str().ok()),
+ Some(PLAIN_TEXT)
+ );
+ assert_eq!(response.text().await.expect("body"), body);
+}
+
+#[tokio::test]
+async fn initialize_answers_json_and_mints_a_session() {
+ let endpoint = spawn_http(None).await;
+ let response = post(&Client::new(), &endpoint, None, None, &init_body()).await;
+ assert_eq!(response.status(), StatusCode::OK);
+ assert_eq!(
+ response
+ .headers()
+ .get(CONTENT_TYPE)
+ .and_then(|v| v.to_str().ok()),
+ Some("application/json")
+ );
+ let session = response
+ .headers()
+ .get(HEADER_SESSION_ID)
+ .and_then(|v| v.to_str().ok())
+ .expect("session header")
+ .to_string();
+ assert_eq!(session.len(), 36, "a hyphenated v4 uuid: {session}");
+ let body: Value = response.json().await.expect("json");
+ assert_eq!(body["result"]["protocolVersion"], LATEST_PROTOCOL_VERSION);
+ assert_eq!(body["result"]["serverInfo"]["name"], "openhuman-core");
+ assert_eq!(
+ body["result"]["serverInfo"]["version"],
+ env!("CARGO_PKG_VERSION")
+ );
+}
+
+#[tokio::test]
+async fn failed_initialize_answers_the_error_without_a_session() {
+ let endpoint = spawn_http(None).await;
+ let response = post(
+ &Client::new(),
+ &endpoint,
+ None,
+ None,
+ &json!({"jsonrpc": "1.0", "id": 1, "method": "initialize"}),
+ )
+ .await;
+ assert_eq!(response.status(), StatusCode::OK);
+ assert!(response.headers().get(HEADER_SESSION_ID).is_none());
+ assert_eq!(
+ response.text().await.expect("body"),
+ r#"{"error":{"code":-32600,"data":"jsonrpc must be \"2.0\"","message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}"#
+ );
+}
+
+#[tokio::test]
+async fn session_and_protocol_rejections_are_plain_text() {
+ let endpoint = spawn_http(None).await;
+ let http = Client::new();
+ let ping = json!({"jsonrpc": "2.0", "id": 2, "method": "ping"});
+
+ let no_session = post(&http, &endpoint, None, None, &ping).await;
+ assert_text(
+ no_session,
+ StatusCode::BAD_REQUEST,
+ "missing or invalid Mcp-Session-Id header",
+ )
+ .await;
+
+ let unknown = post(
+ &http,
+ &endpoint,
+ Some("nope"),
+ Some(LATEST_PROTOCOL_VERSION),
+ &ping,
+ )
+ .await;
+ assert_text(
+ unknown,
+ StatusCode::NOT_FOUND,
+ "unknown or expired MCP session",
+ )
+ .await;
+
+ let session = initialize(&http, &endpoint).await;
+ let mismatch = post(&http, &endpoint, Some(&session), Some("2024-11-05"), &ping).await;
+ assert_text(
+ mismatch,
+ StatusCode::BAD_REQUEST,
+ "missing or invalid MCP-Protocol-Version header",
+ )
+ .await;
+ let missing = post(&http, &endpoint, Some(&session), None, &ping).await;
+ assert_text(
+ missing,
+ StatusCode::BAD_REQUEST,
+ "missing or invalid MCP-Protocol-Version header",
+ )
+ .await;
+}
+
+#[tokio::test]
+async fn requests_notifications_and_batches_on_a_session() {
+ let endpoint = spawn_http(None).await;
+ let http = Client::new();
+ let session = initialize(&http, &endpoint).await;
+ let protocol = Some(LATEST_PROTOCOL_VERSION);
+
+ let ping = post(
+ &http,
+ &endpoint,
+ Some(&session),
+ protocol,
+ &json!({"jsonrpc": "2.0", "id": 2, "method": "ping"}),
+ )
+ .await;
+ assert_eq!(ping.status(), StatusCode::OK);
+ assert_eq!(
+ ping.text().await.expect("body"),
+ r#"{"id":2,"jsonrpc":"2.0","result":{}}"#
+ );
+
+ let notification = post(
+ &http,
+ &endpoint,
+ Some(&session),
+ protocol,
+ &json!({"jsonrpc": "2.0", "method": "notifications/initialized"}),
+ )
+ .await;
+ assert_eq!(notification.status(), StatusCode::NO_CONTENT);
+ assert_eq!(notification.text().await.expect("body"), "");
+
+ // A batch body has no top-level `id`, so the transport answers 204 even
+ // when the batch holds requests. Pinned as-is: it is the current wire.
+ let batch = post(
+ &http,
+ &endpoint,
+ Some(&session),
+ protocol,
+ &json!([{"jsonrpc": "2.0", "id": 3, "method": "ping"}]),
+ )
+ .await;
+ assert_eq!(batch.status(), StatusCode::NO_CONTENT);
+
+ let unknown_method = post(
+ &http,
+ &endpoint,
+ Some(&session),
+ protocol,
+ &json!({"jsonrpc": "2.0", "id": 4, "method": "nope"}),
+ )
+ .await;
+ assert_eq!(unknown_method.status(), StatusCode::OK);
+ assert_eq!(
+ unknown_method.text().await.expect("body"),
+ r#"{"error":{"code":-32601,"data":"unsupported MCP method `nope`","message":"Method not found"},"id":4,"jsonrpc":"2.0"}"#
+ );
+}
+
+#[tokio::test]
+async fn non_json_body_is_rejected_by_the_extractor() {
+ let endpoint = spawn_http(None).await;
+ let response = Client::new()
+ .post(&endpoint)
+ .body("ping")
+ .send()
+ .await
+ .expect("post");
+ assert_eq!(response.status(), StatusCode::UNSUPPORTED_MEDIA_TYPE);
+ assert_eq!(
+ response.text().await.expect("body"),
+ "Expected request with `Content-Type: application/json`"
+ );
+}
+
+#[tokio::test]
+async fn get_and_delete_follow_the_session_lifecycle() {
+ let endpoint = spawn_http(None).await;
+ let http = Client::new();
+
+ let get_missing = http.get(&endpoint).send().await.expect("get");
+ assert_text(
+ get_missing,
+ StatusCode::BAD_REQUEST,
+ "missing Mcp-Session-Id header",
+ )
+ .await;
+ let get_unknown = http
+ .get(&endpoint)
+ .header(HEADER_SESSION_ID, "nope")
+ .send()
+ .await
+ .expect("get");
+ assert_text(
+ get_unknown,
+ StatusCode::NOT_FOUND,
+ "unknown or expired MCP session",
+ )
+ .await;
+
+ let session = initialize(&http, &endpoint).await;
+ let get_mismatch = http
+ .get(&endpoint)
+ .header(HEADER_SESSION_ID, session.as_str())
+ .send()
+ .await
+ .expect("get");
+ assert_text(
+ get_mismatch,
+ StatusCode::BAD_REQUEST,
+ "missing or invalid MCP-Protocol-Version header",
+ )
+ .await;
+ let events = http
+ .get(&endpoint)
+ .header(HEADER_SESSION_ID, session.as_str())
+ .header(HEADER_PROTOCOL_VERSION, LATEST_PROTOCOL_VERSION)
+ .send()
+ .await
+ .expect("get");
+ assert_eq!(events.status(), StatusCode::OK);
+ assert_eq!(
+ events
+ .headers()
+ .get(CONTENT_TYPE)
+ .and_then(|v| v.to_str().ok()),
+ Some("text/event-stream")
+ );
+ drop(events);
+
+ let delete_missing = http.delete(&endpoint).send().await.expect("delete");
+ assert_text(
+ delete_missing,
+ StatusCode::BAD_REQUEST,
+ "missing Mcp-Session-Id header",
+ )
+ .await;
+ let deleted = http
+ .delete(&endpoint)
+ .header(HEADER_SESSION_ID, session.as_str())
+ .send()
+ .await
+ .expect("delete");
+ assert_eq!(deleted.status(), StatusCode::NO_CONTENT);
+ let deleted_again = http
+ .delete(&endpoint)
+ .header(HEADER_SESSION_ID, session.as_str())
+ .send()
+ .await
+ .expect("delete");
+ assert_eq!(deleted_again.status(), StatusCode::NO_CONTENT);
+
+ let after = post(
+ &http,
+ &endpoint,
+ Some(&session),
+ Some(LATEST_PROTOCOL_VERSION),
+ &json!({"jsonrpc": "2.0", "id": 2, "method": "ping"}),
+ )
+ .await;
+ assert_text(
+ after,
+ StatusCode::NOT_FOUND,
+ "unknown or expired MCP session",
+ )
+ .await;
+}
+
+#[tokio::test]
+async fn bearer_auth_rejects_with_plain_text_before_anything_else() {
+ let endpoint = spawn_http(Some("golden-secret")).await;
+ let http = Client::new();
+
+ let missing = post(&http, &endpoint, None, None, &init_body()).await;
+ assert_text(missing, StatusCode::UNAUTHORIZED, "unauthorized").await;
+ let wrong = http
+ .post(&endpoint)
+ .bearer_auth("wrong")
+ .json(&init_body())
+ .send()
+ .await
+ .expect("post");
+ assert_eq!(wrong.status(), StatusCode::UNAUTHORIZED);
+ let get = http.get(&endpoint).send().await.expect("get");
+ assert_eq!(get.status(), StatusCode::UNAUTHORIZED);
+ let delete = http.delete(&endpoint).send().await.expect("delete");
+ assert_eq!(delete.status(), StatusCode::UNAUTHORIZED);
+
+ let allowed = http
+ .post(&endpoint)
+ .bearer_auth("golden-secret")
+ .json(&init_body())
+ .send()
+ .await
+ .expect("post");
+ assert_eq!(allowed.status(), StatusCode::OK);
+}
diff --git a/crates/openhuman-core/src/mcp/server/mod.rs b/crates/openhuman-core/src/mcp/server/mod.rs
index ca59cba661..e1a6774155 100644
--- a/crates/openhuman-core/src/mcp/server/mod.rs
+++ b/crates/openhuman-core/src/mcp/server/mod.rs
@@ -70,3 +70,13 @@ pub use tools::McpToolSpec;
mod stub;
#[cfg(not(feature = "mcp"))]
pub use stub::*;
+
+// Golden wire fixtures, and the one seam they call through (see each file).
+#[cfg(all(test, feature = "mcp", feature = "http-server"))]
+#[path = "http_golden_tests.rs"]
+mod http_golden_tests;
+#[cfg(all(test, feature = "mcp"))]
+mod test_support;
+#[cfg(all(test, feature = "mcp"))]
+#[path = "wire_golden_tests.rs"]
+mod wire_golden_tests;
diff --git a/crates/openhuman-core/src/mcp/server/test_support.rs b/crates/openhuman-core/src/mcp/server/test_support.rs
new file mode 100644
index 0000000000..da9922f651
--- /dev/null
+++ b/crates/openhuman-core/src/mcp/server/test_support.rs
@@ -0,0 +1,29 @@
+//! Test-only entry points into the served MCP surface.
+//!
+//! The golden suites call these instead of naming the protocol or transport
+//! directly, so the fixtures stay byte-for-byte unchanged while the machinery
+//! underneath them moves.
+
+/// Answer one newline-delimited JSON-RPC line on a fresh session, exactly as
+/// the stdio transport would.
+pub(super) async fn dispatch_line(line: &str) -> Option<String> {
+ super::protocol::handle_json_line(line).await
+}
+
+/// Start the Streamable HTTP server on an ephemeral loopback port and return
+/// its endpoint URL.
+#[cfg(feature = "http-server")]
+pub(super) async fn spawn_http(auth_token: Option<&str>) -> String {
+ let (tx, rx) = tokio::sync::oneshot::channel();
+ let config = super::HttpServerConfig {
+ bind_addr: "127.0.0.1:0".parse().expect("loopback address"),
+ auth_token: auth_token.map(str::to_string),
+ };
+ tokio::spawn(async move {
+ super::run_http_reporting(config, Some(tx))
+ .await
+ .expect("mcp http server runs");
+ });
+ let addr = rx.await.expect("server reports its bound address");
+ format!("http://{addr}/")
+}
diff --git a/crates/openhuman-core/src/mcp/server/wire_golden_tests.rs b/crates/openhuman-core/src/mcp/server/wire_golden_tests.rs
index 02d0ad51b0..f249ba0ac7 100644
--- a/crates/openhuman-core/src/mcp/server/wire_golden_tests.rs
+++ b/crates/openhuman-core/src/mcp/server/wire_golden_tests.rs
@@ -23,15 +23,21 @@ const CONFIG_GATED_TOOLS: &[&str] = &["searxng_search", "web_search", "web_answe
const LINE_CASES: &[(&str, Option<&str>)] = &[
(
r#"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"Claude Desktop","version":"0"}}}"#,
- Some(r#"{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"resources":{"listChanged":false,"subscribe":false},"tools":{}},"instructions":"OpenHuman MCP exposes first-level core integration: inspect the live tool catalog with core.list_tools or core.tool_instructions, inspect subagents with agent.list_subagents, run a standalone subagent with agent.run_subagent, use web_search or web_answer for live web lookups (and searxng_search when self-hosted search is enabled), and use memory.search or memory.recall plus tree.read_chunk for local memory reads.","protocolVersion":"2025-06-18","serverInfo":{"name":"openhuman-core","version":"{{CARGO_PKG_VERSION}}"}}}"#),
+ Some(
+ r#"{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"resources":{"listChanged":false,"subscribe":false},"tools":{}},"instructions":"OpenHuman MCP exposes first-level core integration: inspect the live tool catalog with core.list_tools or core.tool_instructions, inspect subagents with agent.list_subagents, run a standalone subagent with agent.run_subagent, use web_search or web_answer for live web lookups (and searxng_search when self-hosted search is enabled), and use memory.search or memory.recall plus tree.read_chunk for local memory reads.","protocolVersion":"2025-06-18","serverInfo":{"name":"openhuman-core","version":"{{CARGO_PKG_VERSION}}"}}}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":"init","method":"initialize","params":{"protocolVersion":"1999-01-01"}}"#,
- Some(r#"{"id":"init","jsonrpc":"2.0","result":{"capabilities":{"resources":{"listChanged":false,"subscribe":false},"tools":{}},"instructions":"OpenHuman MCP exposes first-level core integration: inspect the live tool catalog with core.list_tools or core.tool_instructions, inspect subagents with agent.list_subagents, run a standalone subagent with agent.run_subagent, use web_search or web_answer for live web lookups (and searxng_search when self-hosted search is enabled), and use memory.search or memory.recall plus tree.read_chunk for local memory reads.","protocolVersion":"2025-11-25","serverInfo":{"name":"openhuman-core","version":"{{CARGO_PKG_VERSION}}"}}}"#),
+ Some(
+ r#"{"id":"init","jsonrpc":"2.0","result":{"capabilities":{"resources":{"listChanged":false,"subscribe":false},"tools":{}},"instructions":"OpenHuman MCP exposes first-level core integration: inspect the live tool catalog with core.list_tools or core.tool_instructions, inspect subagents with agent.list_subagents, run a standalone subagent with agent.run_subagent, use web_search or web_answer for live web lookups (and searxng_search when self-hosted search is enabled), and use memory.search or memory.recall plus tree.read_chunk for local memory reads.","protocolVersion":"2025-11-25","serverInfo":{"name":"openhuman-core","version":"{{CARGO_PKG_VERSION}}"}}}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":7,"method":"initialize"}"#,
- Some(r#"{"id":7,"jsonrpc":"2.0","result":{"capabilities":{"resources":{"listChanged":false,"subscribe":false},"tools":{}},"instructions":"OpenHuman MCP exposes first-level core integration: inspect the live tool catalog with core.list_tools or core.tool_instructions, inspect subagents with agent.list_subagents, run a standalone subagent with agent.run_subagent, use web_search or web_answer for live web lookups (and searxng_search when self-hosted search is enabled), and use memory.search or memory.recall plus tree.read_chunk for local memory reads.","protocolVersion":"2025-11-25","serverInfo":{"name":"openhuman-core","version":"{{CARGO_PKG_VERSION}}"}}}"#),
+ Some(
+ r#"{"id":7,"jsonrpc":"2.0","result":{"capabilities":{"resources":{"listChanged":false,"subscribe":false},"tools":{}},"instructions":"OpenHuman MCP exposes first-level core integration: inspect the live tool catalog with core.list_tools or core.tool_instructions, inspect subagents with agent.list_subagents, run a standalone subagent with agent.run_subagent, use web_search or web_answer for live web lookups (and searxng_search when self-hosted search is enabled), and use memory.search or memory.recall plus tree.read_chunk for local memory reads.","protocolVersion":"2025-11-25","serverInfo":{"name":"openhuman-core","version":"{{CARGO_PKG_VERSION}}"}}}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":"abc","method":"ping"}"#,
@@ -45,17 +51,18 @@ const LINE_CASES: &[(&str, Option<&str>)] = &[
r#"{"jsonrpc":"2.0","method":"notifications/cancelled","params":{"requestId":1}}"#,
None,
),
- (
- r#"{"jsonrpc":"2.0","method":"notifications/other"}"#,
- None,
- ),
+ (r#"{"jsonrpc":"2.0","method":"notifications/other"}"#, None),
(
r#"[]"#,
- Some(r#"{"error":{"code":-32600,"data":"batch must not be empty","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32600,"data":"batch must not be empty","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"[{"jsonrpc":"2.0","id":1,"method":"ping"},{"jsonrpc":"2.0","method":"notifications/initialized"},42,{"jsonrpc":"2.0","id":3,"method":"nope"}]"#,
- Some(r#"[{"id":1,"jsonrpc":"2.0","result":{}},{"error":{"code":-32600,"data":"message must be a JSON object","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"},{"error":{"code":-32601,"data":"unsupported MCP method `nope`","message":"Method not found"},"id":3,"jsonrpc":"2.0"}]"#),
+ Some(
+ r#"[{"id":1,"jsonrpc":"2.0","result":{}},{"error":{"code":-32600,"data":"message must be a JSON object","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"},{"error":{"code":-32601,"data":"unsupported MCP method `nope`","message":"Method not found"},"id":3,"jsonrpc":"2.0"}]"#,
+ ),
),
(
r#"[{"jsonrpc":"2.0","method":"notifications/initialized"}]"#,
@@ -63,107 +70,159 @@ const LINE_CASES: &[(&str, Option<&str>)] = &[
),
(
r#"42"#,
- Some(r#"{"error":{"code":-32600,"data":"message must be a JSON object","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32600,"data":"message must be a JSON object","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1.5,"method":"ping"}"#,
- Some(r#"{"error":{"code":-32600,"data":"id must be a string or integer","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32600,"data":"id must be a string or integer","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":true,"method":"ping"}"#,
- Some(r#"{"error":{"code":-32600,"data":"id must be a string or integer","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32600,"data":"id must be a string or integer","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":null,"method":"ping"}"#,
- Some(r#"{"error":{"code":-32600,"data":"id must be a string or integer","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32600,"data":"id must be a string or integer","message":"Invalid Request"},"id":null,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"id":1,"method":"ping"}"#,
- Some(r#"{"error":{"code":-32600,"data":"jsonrpc must be \"2.0\"","message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32600,"data":"jsonrpc must be \"2.0\"","message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"1.0","id":1,"method":"ping"}"#,
- Some(r#"{"error":{"code":-32600,"data":"jsonrpc must be \"2.0\"","message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32600,"data":"jsonrpc must be \"2.0\"","message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1}"#,
- Some(r#"{"error":{"code":-32600,"data":"method must be a string","message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32600,"data":"method must be a string","message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":5}"#,
- Some(r#"{"error":{"code":-32600,"data":"method must be a string","message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32600,"data":"method must be a string","message":"Invalid Request"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"prompts/list"}"#,
- Some(r#"{"error":{"code":-32601,"data":"unsupported MCP method `prompts/list`","message":"Method not found"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32601,"data":"unsupported MCP method `prompts/list`","message":"Method not found"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{not-json"#,
- Some(r#"{"error":{"code":-32700,"data":"key must be a string at line 1 column 2","message":"Parse error"},"id":null,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32700,"data":"key must be a string at line 1 column 2","message":"Parse error"},"id":null,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call"}"#,
- Some(r#"{"error":{"code":-32602,"data":"tools/call params must be an object","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"tools/call params must be an object","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":[]}"#,
- Some(r#"{"error":{"code":-32602,"data":"tools/call params must be an object","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"tools/call params must be an object","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{}}"#,
- Some(r#"{"error":{"code":-32602,"data":"tools/call params.name must be a non-empty string","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"tools/call params.name must be a non-empty string","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":" "}}"#,
- Some(r#"{"error":{"code":-32602,"data":"tools/call params.name must be a non-empty string","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"tools/call params.name must be a non-empty string","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":[1,2]}}"#,
- Some(r#"{"error":{"code":-32602,"data":"tools/call params.arguments: tool arguments must be a JSON object, not an array","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"tools/call params.arguments: tool arguments must be a JSON object, not an array","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":"not json"}}"#,
- Some(r#"{"error":{"code":-32602,"data":"tools/call params.arguments: tool arguments must be a JSON object, not a string that is not JSON","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"tools/call params.arguments: tool arguments must be a JSON object, not a string that is not JSON","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":7}}"#,
- Some(r#"{"error":{"code":-32602,"data":"tools/call params.arguments: tool arguments must be a JSON object, not a number","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"tools/call params.arguments: tool arguments must be a JSON object, not a number","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":{}}}"#,
- Some(r#"{"error":{"code":-32602,"data":"missing required argument `query`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"missing required argument `query`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":"{}"}}"#,
- Some(r#"{"error":{"code":-32602,"data":"missing required argument `query`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"missing required argument `query`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search"}}"#,
- Some(r#"{"error":{"code":-32602,"data":"missing required argument `query`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"missing required argument `query`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":{"query":"x","bogus":1}}}"#,
- Some(r#"{"error":{"code":-32602,"data":"unexpected argument `bogus`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"unexpected argument `bogus`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"no.such_tool","arguments":{}}}"#,
- Some(r#"{"error":{"code":-32602,"data":"unknown MCP tool `no.such_tool`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"unknown MCP tool `no.such_tool`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":12,"method":"resources/read","params":{"uri":"openhuman://prompts/agents/does_not_exist"}}"#,
- Some(r#"{"error":{"code":-32002,"data":"no resource with uri `openhuman://prompts/agents/does_not_exist`","message":"Resource not found"},"id":12,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32002,"data":"no resource with uri `openhuman://prompts/agents/does_not_exist`","message":"Resource not found"},"id":12,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":13,"method":"resources/read","params":{}}"#,
- Some(r#"{"error":{"code":-32602,"data":"resources/read params.uri must be a non-empty string","message":"Invalid params"},"id":13,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"resources/read params.uri must be a non-empty string","message":"Invalid params"},"id":13,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":13,"method":"resources/read","params":{"uri":" "}}"#,
- Some(r#"{"error":{"code":-32602,"data":"resources/read params.uri must be a non-empty string","message":"Invalid params"},"id":13,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"resources/read params.uri must be a non-empty string","message":"Invalid params"},"id":13,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":13,"method":"resources/read"}"#,
- Some(r#"{"error":{"code":-32602,"data":"resources/read params.uri must be a non-empty string","message":"Invalid params"},"id":13,"jsonrpc":"2.0"}"#),
+ Some(
+ r#"{"error":{"code":-32602,"data":"resources/read params.uri must be a non-empty string","message":"Invalid params"},"id":13,"jsonrpc":"2.0"}"#,
+ ),
),
(
r#"{"jsonrpc":"2.0","id":14,"method":"resources/templates/list"}"#,
@@ -206,9 +265,7 @@ async fn tools_list_answers_with_the_golden_base_catalog() {
response["result"]["tools"]
.as_array_mut()
.expect("tools array")
- .retain(|tool| {
- !CONFIG_GATED_TOOLS.contains(&tool["name"].as_str().expect("tool name"))
- });
+ .retain(|tool| !CONFIG_GATED_TOOLS.contains(&tool["name"].as_str().expect("tool name")));
assert_eq!(response.to_string(), TOOLS_LIST_BASE);
}