Skip to content

Commit 17d7ab9

Browse files
committed
fix(tower): add cancellation awareness and logging to JSON response path
1 parent 93634fc commit 17d7ab9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • crates/rmcp/src/transport/streamable_http_server

crates/rmcp/src/transport/streamable_http_server/tower.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,13 @@ where
602602
// JSON-direct mode: await the single response and return as
603603
// application/json, eliminating SSE framing overhead.
604604
// Allowed by MCP Streamable HTTP spec (2025-06-18).
605-
match receiver.recv().await {
605+
let cancel = self.config.cancellation_token.child_token();
606+
match tokio::select! {
607+
res = receiver.recv() => res,
608+
_ = cancel.cancelled() => None,
609+
} {
606610
Some(message) => {
611+
tracing::info!(?message);
607612
let body = serde_json::to_vec(&message).map_err(|e| {
608613
internal_error_response("serialize json response")(e)
609614
})?;

0 commit comments

Comments
 (0)