Drop-in reliability layer for MCP tool calls: adaptive retry, cost-aware circuit breaking, fallback chains, and observability.
Project description
mcp-resilient
Drop-in reliability layer for MCP tool calls. Adaptive retry, cost-aware circuit breaking, ordered fallback chains, and pluggable observability - as a decorator around any existing MCP client. No protocol changes, no rebuild.
from mcp_resilient import ReliabilityConfig, mcp_reliable
config = ReliabilityConfig(tool_name="threat_intel_lookup")
@mcp_reliable(config)
async def call_threat_intel(ioc: str):
return await mcp_client.call_tool("threat_intel_lookup", {"ioc": ioc})
Why this exists
How agents discover and call tools is defined by MCP. Does not indicate what Occurs when a tool is slow or flaky or rate-limited that's left to each. developer to reinvent. A number of projects interface abutting troubles security None of them provide retry+circuit breaking+output-size reduction + fallback
- cost tracking in a Python native drop in wrapper.
See docs/comparison.md for the full landscape check.
Install
pip install mcp-resilient # core
pip install mcp-resilient[redis] # + distributed state for multi-instance agents
pip install mcp-resilient[otel] # + OpenTelemetry metrics export
pip install mcp-resilient[prometheus] # + Prometheus metrics export
pip install mcp-resilient[cli] # + `mcp-resilient simulate` command
Features
- Adaptive retry: fixed, exponential, or decorrelated-jitter backoff (AWS-style, avoids thundering herd on shared upstreams).
- Cost-aware circuit breaker: trips on failure count or cumulative $ spend in a window, whichever fires first.
- Fallback chains: ordered list of fallback tools, tried in sequence.
- Observability: Prometheus / OpenTelemetry exporters.
- Pluggable state: in-memory by default, Redis for multi-instance agents.
mcp-resilient simulate: dry-run a policy against synthetic failures before it ever touches production.
Real-world Example (SecOps/SIEM)
For a practical example, see examples/siem_threat_intel_example.py. It demonstrates a real SecOps pattern:
- A primary threat intelligence enrichment API call (which might be flaky or rate-limited).
- A free backup API fallback.
- A cost-aware circuit breaker to prevent retries from exceeding your primary API budget.
Quickstart
See docs/quickstart.md and the runnable scripts in examples/.
Architecture
See docs/architecture.md for the HLD/LLD.
Development
git clone https://github.com/ck-rajput/mcp-resilient
cd mcp-resilient
pip install -e ".[dev,cli]"
pytest -q
Scope & Compliance Warning
[!WARNING]
mcp-resilientis a resilience and access-control routing layer, NOT a data encryption or cryptographic compliance vault. For highly regulated environments (like finance PCI-DSS, SOC2 or healthcare), data encryption (at rest and in transit), credential storage security, and compliance auditing need to be performed in your main hosting infrastructure.
License
MIT - see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_resilient-0.0.1.tar.gz.
File metadata
- Download URL: mcp_resilient-0.0.1.tar.gz
- Upload date:
- Size: 46.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72478f22c498d8e7cb8303efaf4eb33792d0359f6482a732175f63e589e9b45e
|
|
| MD5 |
4b9cbd4a34e7da9996712bb1b2c620c4
|
|
| BLAKE2b-256 |
4ffe8e444fc4dc9ebbb991e24ae241272537aa6032900ec047d056adc99fcf8f
|
File details
Details for the file mcp_resilient-0.0.1-py3-none-any.whl.
File metadata
- Download URL: mcp_resilient-0.0.1-py3-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
153b6106b7ce0da4affcf9223a05ae61684093b666b0f3beaf2c0cd13732808a
|
|
| MD5 |
5864d4427899d622cb48d8822c7052c6
|
|
| BLAKE2b-256 |
16c7f33b4f3d0b89e22cbfce75a9b7a35b37408280beab217d04dacf0dcd3e1f
|