LyxdyHD/mcp-circuit-breaker
A lightweight Node.js/TypeScript proxy that sits between your AI Agent and the Anthropic API to prevent infinite reasoning loops and token exhaustion.
Platform-specific configuration:
{
"mcpServers": {
"mcp-circuit-breaker": {
"command": "npx",
"args": [
"-y",
"mcp-circuit-breaker"
]
}
}
}Add the config above to .claude/settings.json under the mcpServers key.
<div align="center">
A lightweight, zero-dependency-style protective proxy for AI Agents using Anthropic's API. *Stop infinite reasoning loops. Prevent token exhaustion. Save your API budget.*
[](https://www.typescriptlang.org/) [](https://nodejs.org/) [](https://anthropic.com/) [](https://opensource.org/licenses/MIT)
</div>
---
When building autonomous AI Agents (like Paperclip, AutoGPT, etc.) with tool-use (Function Calling), they sometimes encounter errors and hallucinate. Instead of recovering, they get stuck executing the exact same tool with the exact same arguments... forever.
Because Anthropic's API charges per token (including the context history), these repeating loops exponentially blow up your token usage and burn through your API budget in minutes.
---
mcp-circuit-breakermcp-circuit-breaker is a local Node.js proxy that sits between your Agent and the Anthropic API.
It intercepts every /v1/messages request, hashes the payload the AI is trying to send, and monitors repetitions. If it detects the exact same payload 3 times within a 2-minute window, it blocks the request and sends a synthetic error message back to the agent:
> *"ERROR: You are stuck in a repetitive loop. Please halt execution immediately, summarize your failure clearly, and wait for human intervention before continuing."*
---
sequenceDiagram
participant Agent as 🤖 AI Agent
participant Proxy as 🛑 CLoading reviews...