mcp-retry
Tiny, opinionated retry/backoff decorators for MCP servers and other API clients. A thin preset layer over tenacity: exponential backoff + jitter, retry on 429/5xx/network errors, log before each retry, re-raise on exhaustion.
Extracted from a fleet of production MCP servers (TikTok Shop, TikTok Ads, and others) so every server retries the same way instead of re-implementing tenacity incantations.
Install
pip install mcp-retry # core (tenacity only)
pip install "mcp-retry[httpx]" # + httpx preset
Usage
httpx-based MCP servers (async)
from mcp_retry import httpx_retry
@httpx_retry()
async def _do_request(self, url):
response = await client.get(url)
if response.status_code == 429 or response.status_code >= 500:
response.raise_for_status() # triggers retry
return response
Retries on httpx.RequestError (connection errors, timeouts, DNS failures) and httpx.HTTPStatusError. Only call raise_for_status() for status codes you want retried (429/5xx) — 4xx client errors should surface immediately.
requests-based projects (sync)
from mcp_retry import requests_retry
@requests_retry()
def fetch(url):
r = requests.get(url)
if r.status_code == 429 or r.status_code >= 500:
r.raise_for_status()
return r
Custom exceptions / tuning
from mcp_retry import api_retry
@api_retry(max_attempts=5, min_wait=2, retryable_exceptions=(MyTransientError,))
def fragile_call():
...
Defaults: 3 attempts, exponential wait 1–30 s plus 0–2 s random jitter, warning-level log before each sleep, reraise=True.
Why not just tenacity?
You should use tenacity — this is tenacity. mcp-retry just freezes one sane configuration (and the httpx/requests exception sets) behind a one-line decorator, so a dozen MCP servers stay consistent and a retry-policy change is a single-package bump instead of a dozen edits.
License
Metadata
Release files for mcp-retry 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcp_retry-0.1.0.tar.gz | 3.7 kB | Without provenance | Details for mcp_retry-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp_retry-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mcp_retry-0.1.0-py3-none-any.whl |
Total release size: 8.3 kB
Release files / mcp_retry-0.1.0.tar.gz
| Download URL | mcp_retry-0.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4dc30ba25b5fa55b8484361dd40cb5d5c09fb5414aa36223441e2e7f333753ea
|
|
BLAKE2b-256 checksum How to use checksums |
0279dc71319b8c8bb3fd49c8ef25774d25cd59b14134b45d317c0fcfa6ec4406
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.10
|
Release files / mcp_retry-0.1.0-py3-none-any.whl
| Download URL | mcp_retry-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e9f1ee83775c4a1d975ca945e4445b93509d8f9240280e1f079f1187dde56fc
|
|
BLAKE2b-256 checksum How to use checksums |
26ccf4a1b987b68e0a8b1800477c8f934bdcbd4602d32614b35e42bcebe6c0be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.10
|
Security for mcp-retry 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.