speakeasy-api / speakeasy-api/kit
MCP tool deadlines do not send protocol cancellation
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 40
- Forks
- 4
- Avg merge
- 4h 18m
- Merged PRs (30d)
- 148
Description
Kit's MCP wrapper can stop its local wait at the configured tool deadline, but the AgentKit MCP adapter exposes only an awaited call_tool future, not RMCP's RequestHandle. Dropping that future does not invoke RequestHandle::cancel, so Kit cannot send notifications/cancelled for the timed-out request. A server that never answers can retain the corresponding local RMCP pending request until the connection closes, and a remote side effect may still complete. Kit therefore warns callers to inspect remote state before retrying side effects.
A complete fix belongs at the AgentKit MCP boundary: expose a per-call deadline or cancellation-aware call API that uses RMCP PeerRequestOptions/RequestHandle, sends protocol cancellation on expiry, unregisters pending request state, and returns a typed timeout error. Kit can then delegate its timeout_seconds policy to that API instead of enforcing only the outer local deadline.
Relevant implementation: Kit src/tools/mcp.rs (McpTool::dispatch), AgentKit agentkit-mcp (McpConnection::call_tool), and RMCP RequestHandle.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace Kit’s src/tools/mcp.rs at McpTool::dispatch, then read agentkit-mcp’s McpConnection::call_tool and RMCP’s RequestHandle/PeerRequestOptions. Verify how the awaited future currently handles deadlines, and consider the boundary behavior needed for protocol cancellation, pending-state cleanup, and a typed timeout error before Kit delegates its timeout policy there.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100