From 2a0326e81cd9b8359e61ea554d80f4c818ec174a Mon Sep 17 00:00:00 2001 From: Achim Nierbeck Date: Sun, 5 Apr 2026 23:26:20 +0200 Subject: [PATCH 1/2] Combined MCP improvements: security, token updates, and cleanup --- crates/openfang-runtime/src/mcp.rs | 28 +++++++++++++++++++++++----- docs/mcp-a2a.md | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/crates/openfang-runtime/src/mcp.rs b/crates/openfang-runtime/src/mcp.rs index b9f5f3819f..ea73c1648d 100644 --- a/crates/openfang-runtime/src/mcp.rs +++ b/crates/openfang-runtime/src/mcp.rs @@ -290,6 +290,7 @@ impl McpConnection { use rmcp::transport::streamable_http_client::StreamableHttpClientTransportConfig; use rmcp::transport::StreamableHttpClientTransport; + tracing::debug!(url, "MCP connect_http called with {} headers", headers.len()); Self::check_ssrf(url)?; // Parse custom headers (e.g., "Authorization: Bearer "). @@ -307,11 +308,28 @@ impl McpConnection { } } - let config = StreamableHttpClientTransportConfig { - uri: Arc::from(url), - custom_headers, - ..Default::default() - }; + // Debug: Log the headers being sent (redact sensitive headers like Authorization) + if !custom_headers.is_empty() { + tracing::debug!(url = %url, "MCP connect_http called with {} headers", headers.len()); + + // Log header names but redact values for sensitive headers + let header_logs: Vec = custom_headers.iter() + .map(|(k, v)| { + let name = k.as_str(); + if name.eq_ignore_ascii_case("authorization") { + format!("{}: [REDACTED]", name) + } else { + format!("{}: {:?}", name, v) + } + }) + .collect(); + + tracing::debug!(url = %url, "MCP custom headers: {:?}", header_logs); + } + + let mut config = StreamableHttpClientTransportConfig::default(); + config.uri = Arc::from(url); + config.custom_headers = custom_headers; let transport = StreamableHttpClientTransport::from_config(config); diff --git a/docs/mcp-a2a.md b/docs/mcp-a2a.md index 47789a68b0..998f2c3513 100644 --- a/docs/mcp-a2a.md +++ b/docs/mcp-a2a.md @@ -71,9 +71,32 @@ Each entry maps to a `McpServerConfigEntry` struct: | `transport` | `McpTransportEntry` | required | How to connect (stdio or SSE) | | `timeout_secs` | `u64` | `30` | JSON-RPC request timeout | | `env` | `Vec` | `[]` | Env vars to pass through to the subprocess | +| `headers` | `Vec` | `[]` | Custom HTTP headers for authentication (e.g., `["Authorization: Bearer "]`) | #### Transport Types +##### Header Configuration + +MCP servers can include custom HTTP headers for authentication and other requirements: + +```toml +[[mcp_servers]] +name = "homeassistant" +timeout_secs = 10 +headers = [ + "Authorization: Bearer " +] + +[mcp_servers.transport] +type = "http" +url = "http://homeassistant:8123/api/mcp" +method = "POST" +``` + +**Important**: Do not manually set reserved headers like `Accept`, `Content-Type`, or `User-Agent` as these are automatically set by the HTTP client. Only include custom headers required by the MCP server. + +**Security Note**: Authorization tokens in debug logs are automatically redacted as `[REDACTED]` to prevent accidental exposure. + OpenFang supports two MCP transports, defined by `McpTransport`: **Stdio** -- Spawns a subprocess and communicates via stdin/stdout with newline-delimited JSON-RPC: From 6f48fa1f7e2059f1298f95174769770dd8548887 Mon Sep 17 00:00:00 2001 From: Achim Nierbeck Date: Tue, 7 Apr 2026 10:58:13 +0200 Subject: [PATCH 2/2] Feat: Add inline approval UI and fix audio file errors This commit includes: - Inline approval UI for both TUI and WebUI - Keyboard shortcuts for quick approval/rejection (A/R keys) - Risk level visualization and navigation - WebUI API integration for approval actions - Fixed undefined _audioFile property access - Enhanced global state management for approvals - Automatic approval loading and polling Resolves the UX issue where users had to navigate to a separate Approval menu that didn't show pending requests properly. --- crates/openfang-api/static/index_body.html | 36 ++++- crates/openfang-api/static/js/app.js | 7 + crates/openfang-api/static/js/pages/chat.js | 80 ++++++++++- crates/openfang-cli/src/tui/chat_runner.rs | 31 ++++ crates/openfang-cli/src/tui/mod.rs | 31 ++++ crates/openfang-cli/src/tui/screens/chat.rs | 150 +++++++++++++++++++- 6 files changed, 329 insertions(+), 6 deletions(-) diff --git a/crates/openfang-api/static/index_body.html b/crates/openfang-api/static/index_body.html index b8f7f3d8d9..d380d43d35 100644 --- a/crates/openfang-api/static/index_body.html +++ b/crates/openfang-api/static/index_body.html @@ -670,10 +670,10 @@

Select an agent to sta -
+
- +
@@ -775,6 +775,38 @@

Select an agent to sta

+ +
+
+ + Pending Approvals + +
+
+ +
+
+ ↑↓ Navigate + A Approve + R Reject +
+