Repository navigation
feat(fetch): add retry/backoff for transient 429/5xx and network errors - #4456
chakshu-dhannawat wants to merge 1 commit into
Conversation
- Retry on HTTP 429, 500, 502, 503, 504 and httpx.TransportError - Respect Retry-After header on 429; fall back to full-jitter exponential backoff capped at 30 s - Default 3 retries; configurable via max_retries param and --max-retries CLI flag - Add 12 new tests covering retry path, exhaustion, 404 non-retry, and Retry-After parsing
|
Hi, I've refreshed this against main. Could a maintainer take a look when possible? Thanks. |
|
Thank you for this pull request, and apologies for the long wait for a response. These servers are reference implementations: they exist to show how each part of MCP is used, not to be general-purpose products, so new features are taken selectively, and this change isn't one the maintainers plan to take. This repository also now accepts issues, not pull requests, from anyone but its maintainers; the policy is in This is not a judgment on the idea or on you. A server in the MCP Registry may well offer it, and anyone is welcome to build on these servers to do so. If you think we've misread it, please open an issue describing the problem and the expected behavior. This is part of the backlog triage in #4875. |
Summary
Resolves #4449.
The Python fetch server currently raises
McpErrorimmediately on any HTTP error or non-2xx status. This means a single transient 429 (rate-limit), 503 (overloaded server), or momentary network timeout causes the fetch to fail completely, forcing the LLM to retry the whole tool call.Changes:
max_retries(default 3)httpx.TransportError(coversTimeoutException,ConnectError, etc.)Retry-Afterheader on 429; fall back to full-jitter exponential backoff capped at 30 s--max-retriesCLI flag so operators can tune or disable retries (--max-retries 0)_retry_waitunit testsNon-retryable errors (400, 401, 403, 404, etc.) still raise immediately — unchanged behavior.
Test plan
uv run pytest -vuv run ruff check .uv run pyright--max-retries 0to verify backwards-compatible opt-out