Skip to content

fix(llm): retry a read-only or idempotent MCP tool call once after a dropped connection - #207

Merged
akirilyuk merged 2 commits into
mainfrom
fix/llm-mcp-phase5
Nov 25, 2026
Merged

akirilyuk merged 2 commits into
mainfrom
fix/llm-mcp-phase5

Conversation

@akirilyuk

Copy link
Copy Markdown
Contributor

A tools/call that failed on a dropped connection (TypeError: fetch failed) returned tool <name> failed: unavailable, even though the request never reached the server and the source reconnected about 100 ms later. The model then told the caller it could not reach the tool.

  • McpToolSource.callTool: after a transport error, when the tool's annotations from tools/list has readOnlyHint === true or idempotentHint === true, wait for the reconnect within the call's remaining timeout and send the call once more on the new client. Unannotated tools keep one attempt and unavailable. A tool's own isError result and JSON-RPC errors are never retried.
  • McpToolInfo.annotations keeps the two hints from tools/list.
  • The mcp source connection lost log line adds cause (class) and causeCode of the fetch error. No arguments or results are logged.
  • Tests: test/llm/mcp/mcp-tool-source-retry.test.ts.

Verified locally and via CI; no extra manual steps.

…dropped connection

A tools/call that failed on a dead connection returned 'unavailable' although the request never reached the server and the source reconnected 100 ms later. Retry once on the new client when the tool's annotations mark it readOnlyHint or idempotentHint, within the remaining per-call timeout; log the error cause class and code.
@akirilyuk
akirilyuk merged commit 390054b into main Nov 25, 2026
6 checks passed
@akirilyuk
akirilyuk deleted the fix/llm-mcp-phase5 branch November 25, 2026 15:27
@akirilyuk akirilyuk mentioned this pull request Nov 25, 2026
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