Skip to content

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

test(embed): add test that Debug redacts credentials

Steven Enamakel80e66fa749a4
diff --git a/src/embed/harness/mcp_tests.rs b/src/embed/harness/mcp_tests.rs
index b6b3647fa2..c28e570095 100644
--- a/src/embed/harness/mcp_tests.rs
+++ b/src/embed/harness/mcp_tests.rs
@@ -66,3 +66,23 @@ fn the_name_is_the_agent_facing_slug() {
assert_eq!(server.name(), "github");
assert_eq!(server.into_config().name, "github");
}
+
+#[test]
+fn debug_redacts_credentials() {
+ // The derived Debug would print bearer tokens, passwords, header values and
+ // stdio env values. The manual implementation must redact all of them while
+ // keeping the identifying fields readable.
+ let server = McpServer::http("remote", "https://mcp.example/v1")
+ .auth(McpAuthConfig::BearerToken { token: "super-secret-token".into() })
+ .env([("AUTH_KEY", "env-secret"), ("TOKEN", "another-secret")]);
+ let debug = format!("{server:?}");
+
+ assert!(debug.contains("remote"), "name stays readable");
+ assert!(debug.contains("mcp.example"), "endpoint stays readable");
+ assert!(
+ !debug.contains("super-secret-token") && !debug.contains("env-secret")
+ && !debug.contains("another-secret"),
+ "credentials leaked into Debug: {debug}"
+ );
+ assert!(debug.contains("redacted"));
+}