Skip to content

feat(mcp): add per-call response timeouts with protocol cancellation - #20

Merged
danielkov merged 2 commits into
mainfrom
fix/mcp-call-deadlines
Sep 5, 2026
Merged

feat(mcp): add per-call response timeouts with protocol cancellation#20
danielkov merged 2 commits into
mainfrom
fix/mcp-call-deadlines

Conversation

@danielkov

Copy link
Copy Markdown
Owner

Summary

Add McpConnection::call_tool_with_timeout(name, arguments, Duration) using RMCP's request handle lifecycle. Expiry attempts request-scoped protocol cancellation and returns the existing typed McpError::Timeout; call_tool remains unlimited.

Motivation

Preparatory AgentKit support for Kit #17, whose outer timeout cannot invoke RMCP cancellation. This PR does not complete the hard-deadline fix.

Impact

The new API provides a fixed response-wait timeout, not a total wall-clock deadline. Cancellation is best effort: remote effects can still complete and are not rolled back. Callers must inspect remote state before retrying side effects.

Technical details

RMCP PeerRequestOptions and RequestHandle::await_response retain request ownership through expiry, attempt notifications/cancelled, and remove pending state when cancellation transport send completes, including on send error. Typed results, argument validation, tracing, and non-timeout auth/error handling share the existing call path.

With RMCP 3.1.2, admission happens before the timer starts, and cancellation transport I/O can stall timeout return and local cleanup indefinitely. Dropping the future is not cancel-safe. Full Kit hard-deadline delegation remains blocked until RMCP separates local abandonment from transport completion and bounds admission, followed by compatible published releases.

@danielkov
danielkov merged commit 08b404d into main Sep 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant