Skip to content

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

fix(mcp): stop callback on cancelled server session

Steven Enamakeld3c18c8b16a1
diff --git a/Cargo.lock b/Cargo.lock
index c3532798c9..444901db10 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1542,15 +1542,6 @@ dependencies = [
"dirs-sys",
]
-[[package]]
-name = "dirs"
-version = "7.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f"
-dependencies = [
- "dirs-sys",
-]
-
[[package]]
name = "dirs-sys"
version = "0.5.0"
@@ -3902,7 +3893,7 @@ dependencies = [
"chrono",
"chrono-tz",
"directories",
- "dirs 6.0.0",
+ "dirs",
"dotenvy",
"env_logger",
"flate2",
@@ -4047,7 +4038,6 @@ dependencies = [
"tinyinference-llm",
"tinyinference-local",
"tinyinference-voice",
- "tinymcp",
"tinymcp-bus",
"tinysearch-bus",
"tinystoragedrivers-core",
@@ -4074,7 +4064,7 @@ dependencies = [
"anyhow",
"async-trait",
"chrono",
- "dirs 6.0.0",
+ "dirs",
"env_logger",
"futures-core",
"jsonschema",
@@ -6452,7 +6442,7 @@ dependencies = [
"base64 0.22.1",
"chrono",
"chrono-tz",
- "dirs 6.0.0",
+ "dirs",
"flate2",
"futures",
"regex",
@@ -7032,31 +7022,6 @@ dependencies = [
"url",
]
-[[package]]
-name = "tinymcp"
-version = "0.13.0"
-dependencies = [
- "base64 0.23.1",
- "dirs 7.0.0",
- "futures-util",
- "libc",
- "parking_lot",
- "reqwest 0.12.28",
- "rusqlite",
- "serde",
- "serde_json",
- "sha2 0.11.0",
- "thiserror 2.0.20",
- "tinymcp-bus",
- "tinytools",
- "tinytools-std",
- "tokio",
- "tracing",
- "url",
- "urlencoding",
- "uuid",
-]
-
[[package]]
name = "tinymcp-bus"
version = "0.13.0"
diff --git a/crates/openhuman-core/src/mcp/server/module.rs b/crates/openhuman-core/src/mcp/server/module.rs
index 89f6b2761a..9933392c1d 100644
--- a/crates/openhuman-core/src/mcp/server/module.rs
+++ b/crates/openhuman-core/src/mcp/server/module.rs
@@ -320,10 +320,12 @@ impl ServerSession {
tokio::select! {
_ = cancellation.cancelled() => {
self.cancel_input(&pending).await?;
+ self.stop_callback().await?;
return Err(ServerError::Cancelled);
}
_ = self.terminal.cancelled() => {
self.cancel_input(&pending).await?;
+ self.stop_callback().await?;
return Err(ServerError::Cancelled);
}
result = self.port.submit(&self.id, pending.headers.clone(), pending.input.clone()) => {
@@ -335,10 +337,12 @@ impl ServerSession {
let snapshot = tokio::select! {
_ = cancellation.cancelled() => {
self.cancel_input(&pending).await?;
+ self.stop_callback().await?;
return Err(ServerError::Cancelled);
}
_ = self.terminal.cancelled() => {
self.cancel_input(&pending).await?;
+ self.stop_callback().await?;
return Err(ServerError::Cancelled);
}
result = self.port.poll(&self.id) => result.map_err(ServerError::Module)?,
@@ -353,6 +357,7 @@ impl ServerSession {
Ok(reply) => reply,
Err(ServerError::Cancelled) => {
self.cancel_input(&pending).await?;
+ self.stop_callback().await?;
return Err(ServerError::Cancelled);
}
Err(error) => return Err(error),