Skip to content

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

refactor(modules): return result from legacy mcp import

Steven Enamakelbb3c64b99dba
diff --git a/crates/openhuman-core/src/mcp/module_client.rs b/crates/openhuman-core/src/mcp/module_client.rs
index 0ed89824d0..5a8b9931ff 100644
--- a/crates/openhuman-core/src/mcp/module_client.rs
+++ b/crates/openhuman-core/src/mcp/module_client.rs
@@ -375,7 +375,7 @@ impl McpConfiguredClient {
// Servers and audit rows from before the storage contract
// move into the module's storage before it reads them.
// Best effort: a failure is retried at the next open.
- crate::modules::import_legacy_mcp(
+ let _ = crate::modules::import_legacy_mcp(
&crate::core::runtime::DispatchCtx::ambient(),
std::path::Path::new(&self.data_dir),
)
diff --git a/crates/openhuman-core/src/modules/mod.rs b/crates/openhuman-core/src/modules/mod.rs
index b941d95dbe..ab9750966d 100644
--- a/crates/openhuman-core/src/modules/mod.rs
+++ b/crates/openhuman-core/src/modules/mod.rs
@@ -173,20 +173,34 @@ pub use types::{LoadPolicy, ModuleRecord, ModuleSource, ModuleState, ModuleStatu
pub async fn import_legacy_mcp(
ctx: &crate::core::runtime::DispatchCtx,
data_dir: &std::path::Path,
-) {
+) -> Result<(), String> {
#[cfg(all(feature = "modules", feature = "legacy-import"))]
- match storage_import_tinymcp::import_legacy(ctx, data_dir).await {
- Ok(outcome) => {
+ {
+ match storage_import_tinymcp::import_legacy(ctx, data_dir).await {
+ Ok(outcome) => {
log::debug!("[mcp] legacy storage import: {outcome:?}");
storage_grant_schemas::migrate_imported(ctx, storage_grant_schemas::tinymcp::MODULE_ID)
.await;
+ Ok(())
+ }
+ Err(error) => {
+ log::warn!("[mcp] legacy storage import failed, will retry: {error:#}");
+ Err(format!("legacy TinyMCP storage import failed: {error:#}"))
+ }
}
- Err(error) => log::warn!("[mcp] legacy storage import failed, will retry: {error:#}"),
}
#[cfg(all(feature = "modules", not(feature = "legacy-import")))]
- log::error!("[mcp] legacy storage import is unavailable: enable the `legacy-import` feature");
+ {
+ let _ = (ctx, data_dir);
+ let error = "legacy storage import is unavailable: enable the `legacy-import` feature";
+ log::error!("[mcp] {error}");
+ Err(error.to_owned())
+ }
#[cfg(not(feature = "modules"))]
- let _ = (ctx, data_dir);
+ {
+ let _ = (ctx, data_dir);
+ Ok(())
+ }
}
/// What an importer's outcome says about whether it may be skipped next time.
diff --git a/tests/storage_desktop_upgrade_e2e.rs b/tests/storage_desktop_upgrade_e2e.rs
index 3890657688..ac710fb648 100644
--- a/tests/storage_desktop_upgrade_e2e.rs
+++ b/tests/storage_desktop_upgrade_e2e.rs
@@ -416,7 +416,9 @@ async fn host_documents(backend: &dyn StorageBackend) -> usize {
async fn import_modules(workspace: &Path) {
use openhuman_core::modules;
let ctx = openhuman_core::core::runtime::DispatchCtx::process_default();
- modules::import_legacy_mcp(&ctx, workspace).await;
+ modules::import_legacy_mcp(&ctx, workspace)
+ .await
+ .expect("import the legacy TinyMCP records");
modules::import_legacy_connectors(&ctx, workspace).await;
#[cfg(feature = "web3")]
assert!(modules::import_legacy_x402(&ctx, workspace).await);