MCP Guard
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
ClaudeMCPGuard
Resilience middleware for FastMCP.
ClaudeMCPGuard improves MCP tool reliability with bounded retries, exponential backoff, per-tool timeouts, structured JSON logs, and an optional circuit breaker.
Installation · Usage · Configuration · Development
Overview
Capability | Description |
Bounded retries | Retry failed calls with configurable exponential backoff and a maximum attempt count. |
Per-tool timeouts | Set a default timeout and override it for individual tools. |
Structured logging | Emit one JSON record per completed tool call, including duration and attempt count. |
Circuit breaker | Temporarily block calls after repeated failures and allow a recovery probe. |
Typed package | Ship typing information and support Python 3.10 and newer. |
Privacy-conscious logs | Exclude tool arguments and result payloads from log records. |
Related MCP server: FastMCP Python Boilerplate
Installation
Install the published distribution from PyPI:
python -m pip install ClaudeMCPGuardThe distribution is named ClaudeMCPGuard. The Python import package remains mcp_guard.
For development:
git clone https://github.com/Nawfel1235/ClaudeMCPGuard.git
cd ClaudeMCPGuard
python -m pip install -e ".[dev]"Quick start
from fastmcp import FastMCP
from mcp_guard import MCPGuard
mcp = FastMCP("example")
mcp.add_middleware(MCPGuard())
@mcp.tool
async def lookup_user(user_id: str) -> dict[str, str]:
return {"user_id": user_id, "status": "active"}
if __name__ == "__main__":
mcp.run()Configuration
from fastmcp import FastMCP
from mcp_guard import MCPGuard, MCPGuardConfig
mcp = FastMCP("production-tools")
mcp.add_middleware(
MCPGuard(
MCPGuardConfig(
max_attempts=4,
initial_delay=0.2,
backoff_multiplier=2.0,
timeout_seconds=20.0,
tool_timeouts={"slow_report": 60.0, "no_timeout": None},
breaker_failure_threshold=5,
breaker_recovery_timeout=30.0,
)
)
)Options
Option | Default | Description |
|
| Total attempts, including the first call. |
|
| Initial retry delay, in seconds. |
|
| Multiplier applied after each failed attempt. |
|
| Default timeout. Set to |
|
| Per-tool timeout overrides. A value of |
|
| Consecutive failed calls required to open the circuit. Disabled when |
|
| Seconds before the circuit allows a recovery probe. |
Retries apply to exceptions raised by the downstream FastMCP pipeline. A timeout counts as a failed attempt. The circuit breaker counts one failed tool call after retries are exhausted. Cancellation is propagated and is never retried.
Important: Retries can repeat side effects. Enable them only for idempotent operations or tools protected by idempotency keys.
Structured logging
ClaudeMCPGuard uses Python's standard logging package and the logger named mcp_guard.
Example record:
{
"tool_name": "lookup_user",
"timestamp": "2026-11-29T20:00:00+00:00",
"duration_seconds": 0.0142,
"success": true,
"attempts": 2
}Failure records include an error field. Tool arguments and result payloads are intentionally excluded.
Claude Code skill
A ready-to-use skill is included at skills/SKILL.md. Copy it into your project at .claude/skills/mcp-guard/SKILL.md.
Compatibility
ClaudeMCPGuard targets FastMCP's public Middleware and MiddlewareContext APIs. The dependency range is fastmcp>=2.14,<4. Review FastMCP's middleware documentation when upgrading across major versions.
Development
python -m pip install -e ".[dev]"
pytest
ruff check .
mypyLicense
Released under the MIT License. See LICENSE.
Maintained by Nawfel.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
AgentGuard — 20-tool AI safety MCP: policy preflight, risk scoring, audit logging, rate limits.
One MCP endpoint for Claude, GPT & Gemini: 100+ tools + no-code connectors + agent workers.
MCP gateway: one connection for your AI apps, with tool policies, PII redaction and audit logs.
Free zero-auth MCP breakage shield for AI model deprecations, cloud quotas, runtime EOL & AI laws.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server that enables Claude to manage infrastructure across Kubernetes, Docker, Prometheus, and Terraform through natural language. It provides over 42 specialized tools with a safety-first design, including risk-based command classification and audit logging.43MIT
- AlicenseAqualityFmaintenanceProvides a production-ready FastMCP Python server boilerplate with structured logging, rate limiting, and config validation for building MCP servers compatible with Claude and other agents.21MIT
- AlicenseNot gradedqualityDmaintenanceA FastMCP server that enables AI engineers to run a production-ready MCP endpoint with in-memory token-bucket rate limiting and strict Pydantic v2 input validation. It connects to Claude Desktop, Cursor, and custom agent runners over stdio for safe tool execution.1MIT
- FlicenseNot gradedqualityBmaintenanceThis MCP server wraps agent tool calls with fault-tolerant retry logic, including adaptive exponential backoff, full jitter, 429 rate-limit backpressure handling, and circuit breaker patterns. It enables autonomous agents to execute tools reliably without frontier LLM round-trips, using a zero-dependency Python stdio JSON-RPC interface.7-