Skip to content

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

feat(mcp): dispatch stdio sessions under the process default context

Steven Enamakel11faebe7af51
diff --git a/crates/openhuman-core/src/mcp/server/module.rs b/crates/openhuman-core/src/mcp/server/module.rs
index 8728f22585..4e8843bf60 100644
--- a/crates/openhuman-core/src/mcp/server/module.rs
+++ b/crates/openhuman-core/src/mcp/server/module.rs
@@ -25,6 +25,17 @@ use tinybus::module::{ModuleCallError, ModuleClient};
use super::handler;
+/// The host callback for a session: dispatches under the process default
+/// context (the MCP server is a single-tenant host), held weakly so a
+/// long-lived session never pins it.
+fn host_dispatch() -> impl Fn(ServerHostCall) -> HostCallbackFuture + Send + Sync + 'static {
+ let weak = crate::core::runtime::DispatchCtx::process_default().downgrade();
+ move |call| {
+ let ctx = crate::core::runtime::DispatchCtx::from_weak(weak.as_ref());
+ Box::pin(handler::dispatch(ctx, call))
+ }
+}
+
const MODULE: &str = "tinymcp";
const POLL_INTERVAL: Duration = Duration::from_millis(5);
static NEXT_SESSION_ID: AtomicU64 = AtomicU64::new(1);
diff --git a/crates/openhuman-core/src/mcp/server/stdio.rs b/crates/openhuman-core/src/mcp/server/stdio.rs
index 5c5f96bd57..81b38c019a 100644
--- a/crates/openhuman-core/src/mcp/server/stdio.rs
+++ b/crates/openhuman-core/src/mcp/server/stdio.rs
@@ -118,7 +118,8 @@ pub fn run_stdio_from_cli(args: &[String]) -> Result<()> {
async fn run_stdio_module() -> Result<()> {
use tokio::io::{AsyncBufReadExt, AsyncWriteExt};
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = crate::core::runtime::DispatchCtx::process_default()
+ .load_config()
.await
.map_err(anyhow::Error::msg)?;
let session = ServerSession::open(&config).await?;