The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(mcp): route audit writes and reads through the module client
Steven Enamakel605ca6e8415b
diff --git a/crates/openhuman-core/src/mcp/audit/mod.rs b/crates/openhuman-core/src/mcp/audit/mod.rsindex d7c7081c5f..d880794b50 100644--- a/crates/openhuman-core/src/mcp/audit/mod.rs+++ b/crates/openhuman-core/src/mcp/audit/mod.rs@@ -42,13 +42,19 @@ pub use schemas::{/// Returns an error when the log cannot be opened or the row cannot be/// written.#[cfg(feature = "mcp")]-pub fn record_write(+pub async fn record_write(config: &crate::config::Config,record: NewMcpWriteRecord,) -> anyhow::Result<i64> {- crate::mcp::host::for_config(config)?- .audit()- .record(&record)+ let client = crate::mcp::module_client::McpConfiguredClient::for_config(config)+ .map_err(|error| anyhow::anyhow!("MCP module unavailable: {error}"))?;+ client+ .call(+ &crate::mcp::host::client_config(config),+ tinymcp_bus::names::methods::AUDIT_RECORD_WRITE,+ (record,),+ )+ .await.map_err(|error| anyhow::anyhow!("failed to record an mcp write: {error}"))}@@ -58,13 +64,19 @@ pub fn record_write(////// Returns an error when the log cannot be opened or the query fails.#[cfg(feature = "mcp")]-pub fn list_writes(+pub async fn list_writes(config: &crate::config::Config,query: &McpWriteListQuery,) -> anyhow::Result<Vec<McpWriteRecord>> {- crate::mcp::host::for_config(config)?- .audit()- .list(query)+ let client = crate::mcp::module_client::McpConfiguredClient::for_config(config)+ .map_err(|error| anyhow::anyhow!("MCP module unavailable: {error}"))?;+ client+ .call(+ &crate::mcp::host::client_config(config),+ tinymcp_bus::names::methods::AUDIT_LIST_WRITES,+ (query,),+ )+ .await.map_err(|error| anyhow::anyhow!("failed to list mcp writes: {error}"))}diff --git a/crates/openhuman-core/src/mcp/audit/schemas.rs b/crates/openhuman-core/src/mcp/audit/schemas.rsindex 815c684532..0b51e120db 100644--- a/crates/openhuman-core/src/mcp/audit/schemas.rs+++ b/crates/openhuman-core/src/mcp/audit/schemas.rs@@ -113,7 +113,7 @@ fn handle_list(params: Map<String, Value>) -> ControllerFuture {"[mcp_audit] handle_list querying store workspace={} query={query:?}",config.workspace_dir.display());- let records = match crate::mcp::audit::list_writes(&config, &query) {+ let records = match crate::mcp::audit::list_writes(&config, &query).await {Ok(records) => {log::trace!("[mcp_audit] handle_list store success records={}",diff --git a/crates/openhuman-core/src/mcp/registry/ops.rs b/crates/openhuman-core/src/mcp/registry/ops.rsindex d573446cc1..dc626ee4cc 100644--- a/crates/openhuman-core/src/mcp/registry/ops.rs+++ b/crates/openhuman-core/src/mcp/registry/ops.rs@@ -504,7 +504,7 @@ pub(crate) enum NotConnected {/// string and false of the server, so read it against the installs.pub(crate) fn explain_not_connected(requested: &str,- installs: &[tinymcp::ConnStatus],+ installs: &[tinymcp_bus::ConnStatus],caller: Caller,) -> NotConnected {if let Some(install) = installs.iter().find(|s| s.server_id == requested) {@@ -530,7 +530,7 @@ pub(crate) fn explain_not_connected(}/// An installed server with no live connection: say where it stands and how to connect it.-fn not_connected_message(install: &tinymcp::ConnStatus, caller: Caller) -> String {+fn not_connected_message(install: &tinymcp_bus::ConnStatus, caller: Caller) -> String {let remedy = caller.connect().map_or_else(|| "it has to be connected before its tools can be listed".to_string(),|connect| format!("connect it first via {connect}"),diff --git a/crates/openhuman-core/src/mcp/registry/supervisor_events.rs b/crates/openhuman-core/src/mcp/registry/supervisor_events.rsindex 186d156bae..e0113e97f8 100644--- a/crates/openhuman-core/src/mcp/registry/supervisor_events.rs+++ b/crates/openhuman-core/src/mcp/registry/supervisor_events.rs@@ -1,7 +1,7 @@//! Turning what the reconnect supervisor observed into this application's//! events.//!-//! `tinymcp::Supervisor::tick` hands back a [`TickReport`] and publishes+//! TinyMCP's module-owned supervisor reports [`TickReport`] observations and publishes//! nothing itself: which of its observations a user should hear about is the//! host's call. This module makes that call once. Every non-nominal//! observation becomes a [`DomainEvent`] in the `mcp_client` domain, which is@@ -23,7 +23,7 @@use std::path::Path;-use tinymcp::{ProbeOutcome, SupervisorEvent, TickReport};+use tinymcp_bus::{ProbeOutcome, SupervisorEvent, TickReport};use crate::core::bus::BUS;use crate::core::events::DomainEvent;diff --git a/crates/openhuman-core/src/mcp/registry/supervisor_events_tests.rs b/crates/openhuman-core/src/mcp/registry/supervisor_events_tests.rsindex a56da36e02..09241f5690 100644--- a/crates/openhuman-core/src/mcp/registry/supervisor_events_tests.rs+++ b/crates/openhuman-core/src/mcp/registry/supervisor_events_tests.rs@@ -1,7 +1,7 @@use std::path::{Path, PathBuf};use std::time::Duration;-use tinymcp::{ProbeOutcome, ServerRef, SupervisorEvent, TickReport};+use tinymcp_bus::{ProbeOutcome, ServerRef, SupervisorEvent, TickReport};use super::*;use crate::core::events::DomainEvent;diff --git a/crates/openhuman-core/src/mcp/server/write_dispatch.rs b/crates/openhuman-core/src/mcp/server/write_dispatch.rsindex 837d8a92ea..efb3e9bc08 100644--- a/crates/openhuman-core/src/mcp/server/write_dispatch.rs+++ b/crates/openhuman-core/src/mcp/server/write_dispatch.rs@@ -141,14 +141,20 @@ pub(super) async fn dispatch_write_tool(fn audit_write(config: &Config, record: NewMcpWriteRecord) {let config = config.clone();if let Ok(handle) = tokio::runtime::Handle::try_current() {- std::mem::drop(handle.spawn_blocking(move || {- if let Err(err) = audit::record_write(&config, record) {+ std::mem::drop(handle.spawn(async move {+ if let Err(err) = audit::record_write(&config, record).await {log::warn!("[mcp_server] mcp write audit insert failed: {err}");}}));} else {let _ = std::thread::spawn(move || {- if let Err(err) = audit::record_write(&config, record) {+ let runtime = tokio::runtime::Builder::new_current_thread()+ .enable_all()+ .build();+ let result = runtime+ .map_err(|error| anyhow::anyhow!("could not start audit runtime: {error}"))+ .and_then(|runtime| runtime.block_on(audit::record_write(&config, record)));+ if let Err(err) = result {log::warn!("[mcp_server] mcp write audit insert failed: {err}");}});diff --git a/crates/openhuman-core/src/tools/registry/ops.rs b/crates/openhuman-core/src/tools/registry/ops.rsindex c138d68a39..2068090f8f 100644--- a/crates/openhuman-core/src/tools/registry/ops.rs+++ b/crates/openhuman-core/src/tools/registry/ops.rs@@ -44,11 +44,11 @@ pub async fn diagnostics() -> Result<Outcome<ToolPolicyDiagnostics>, String> {log::warn!("[tool_registry] diagnostics config_load_failed error={err}");format!("failed to load config for tool registry diagnostics: {err}")})?;- Ok(diagnostics_for_config(&config))+ Ok(diagnostics_for_config(&config).await)}/// Return redacted diagnostics using a specific config snapshot.-pub fn diagnostics_for_config(config: &Config) -> Outcome<ToolPolicyDiagnostics> {+pub async fn diagnostics_for_config(config: &Config) -> Outcome<ToolPolicyDiagnostics> {log::debug!("[tool_registry] diagnostics_for_config start");let tools = registry_entries_for_config(config);@@ -70,7 +70,7 @@ pub fn diagnostics_for_config(config: &Config) -> Outcome<ToolPolicyDiagnostics>let policy_surfaces = policy_surface_ids();let posture = posture_from_config(config);let mcp_allowlists = mcp_allowlists_from_config(config);- let mcp_write_audit = mcp_write_audit_health(config);+ let mcp_write_audit = mcp_write_audit_health(config).await;let recent_denials = super::denials::list(25);let capability_providers = capability_provider_diagnostics(config);@@ -167,7 +167,7 @@ const RECENT_WRITE_SAMPLE: u64 = tinymcp_bus::MAX_LIST_LIMIT;/// writes in the last 24 hours on every install, indefinitely, while the log/// underneath it was healthy. A diagnostic that cannot fail loudly must at/// least read the same place the writer wrote.-fn mcp_write_audit_health(config: &Config) -> McpWriteAuditHealth {+async fn mcp_write_audit_health(config: &Config) -> McpWriteAuditHealth {let since_ms = chrono::Utc::now().timestamp_millis().saturating_sub(24 * 60 * 60 * 1000);@@ -177,7 +177,9 @@ fn mcp_write_audit_health(config: &Config) -> McpWriteAuditHealth {since_ms: u64::try_from(since_ms).ok(),..Default::default()};- let result = crate::mcp::audit::list_writes(config, &query).map(|writes| writes.len() as u64);+ let result = crate::mcp::audit::list_writes(config, &query)+ .await+ .map(|writes| writes.len() as u64);match result {Ok(count) => McpWriteAuditHealth {