Commit cdfed81
committed
fix: retry MCP callTool on connection/session errors, not just ErrSessionMissing
When an MCP server restarts, callTool may receive transport errors
(EOF, connection reset, broken pipe) instead of ErrSessionMissing
depending on timing. Add an isConnectionError helper that selectively
retries on known connection/session error types rather than retrying
on all errors indiscriminately.
The helper checks for:
- mcp.ErrSessionMissing (server lost our session)
- io.EOF (connection dropped)
- net.Error (timeout, connection reset, etc.)
- String-based fallback for transport errors the MCP SDK wraps
with %v (losing the original error chain)
This fixes flaky TestRemoteReconnectAfterServerRestart without
broadening retry to application-level errors.
Assisted-By: docker-agent1 parent ad4f99b commit cdfed81
1 file changed
Lines changed: 31 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
454 | 455 | | |
455 | 456 | | |
456 | 457 | | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
461 | 463 | | |
462 | | - | |
| 464 | + | |
463 | 465 | | |
464 | 466 | | |
465 | 467 | | |
| |||
690 | 692 | | |
691 | 693 | | |
692 | 694 | | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
0 commit comments