Logo: Mcp Circuit Breaker

Mcp Circuit Breaker

Communautéit
chrono-meta
mcp-circuit-breaker

Detects MCP tool failure patterns and trips a circuit breaker to stop cascading retries. Proposes fallback alternatives and resets when the tool recovers. Triggers on "MCP failing", "tool keeps erroring", "circuit-breaker", repeated tool call failures.

Iwwersiicht

Editeurchrono-meta
Repositoryforge-harness
Skill-Nummmcp-circuit-breaker
Stären
32
Forks
1
Matgeliwwert Dateien
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    chrono-meta huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Mcp Circuit Breaker an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/chrono-meta/forge-harness/tree/main/plugins/fh-commons/skills/mcp-circuit-breaker
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/chrono-meta/forge-harness.git /tmp/forge-harness
mkdir -p .claude/skills
cp -r /tmp/forge-harness/plugins/fh-commons/skills/mcp-circuit-breaker .claude/skills/mcp-circuit-breaker
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Mcp Circuit Breaker an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Mcp Circuit Breaker automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Mcp Circuit Breaker net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

mcp-circuit-breaker — MCP Tool Failure Guard

MCP tools can fail silently or return partial results, leading to cascading retry loops that waste tokens and degrade session quality. This skill detects failure patterns, trips a circuit breaker to halt retries, proposes alternatives, and resets when the tool recovers.

Scope distinction

  • Claude Code native retry: low-level transport retries (transparent, fast)
  • mcp-circuit-breaker: session-level guard — detects repeated semantic failures, intervenes before token waste compounds

Triggers

  • /mcp-circuit-breaker
  • "MCP failing", "MCP keeps erroring", "tool isn't working", "circuit-breaker"
  • "same error keeps happening", "tool call looping", "MCP timeout"
  • Automatic: when the same MCP tool name appears in 3+ consecutive failed calls within a session

Circuit States

CLOSED   → Normal operation (tool calls pass through)
OPEN     → Circuit tripped (calls blocked, alternatives proposed)
HALF-OPEN → Recovery probe (1 test call allowed, resets if success)

Default thresholds:

  • Trip threshold: 3 consecutive failures of the same tool
  • Half-open probe: after 60s cooldown (or explicit user command)
  • Reset: 1 successful call in HALF-OPEN state → back to CLOSED

Execution Steps

Step 1. Detect Failure Pattern

Identify the failing tool and failure mode:

bash
# MCP mounts live in SEVERAL scopes — check all that this shell can see. Project settings.json is
# usually NOT one of them (it commonly holds hooks only), so a single-file read renders "no config"
# on a session with live MCP servers — a wrong-location instrument, not a measurement.
for f in .mcp.json .claude/settings.json .claude/settings.local.json; do
  [ -e "$f" ] && { echo "== $f =="; grep -A5 '"mcpServers"' "$f" 2>/dev/null || echo "(present, no mcpServers key)"; }
done
[ -e ~/.claude.json ] && grep -c '"mcpServers"' ~/.claude.json | xargs echo "user-scope ~/.claude.json mcpServers blocks:"

An empty result above means "no project/user-scope config found" — never "no MCP mounted": plugin-provided and remotely-managed servers appear in no local file. The live mount evidence is the failing tool call itself (mcp__{server}__{tool} in this session); classify from that name even when every config read comes back empty.

Classify failure type:

TypeSymptomLikely Cause
TIMEOUTTool call hangs >30sServer overload / network
AUTH401 / 403 responseCredentials expired or missing
NOT_FOUND404 / tool not availableServer down / tool removed
MALFORMEDParse error on responseSchema mismatch / API change
RATE_LIMIT429 / quota exceededToo many calls
ADMIN_GATED"instance admin approval required" / server pending org enablement / tool unavailable until approvedCapability exists; the MCP mount is gated behind instance/admin permission — not a transport failure. Retrying never recovers it (an admin must act)

If failure type cannot be determined: classify as UNKNOWN.

ADMIN_GATED is not a retry case. Distinguish capability unavailable from MCP transport unavailable: when the block is an org/admin approval dependency, do not burn retries — route straight to the lower-permission substitute in Step 4 (Priority 1b).


Step 2. Trip Decision

Count consecutive failures of the identified tool in the current session context.

CountAction
1Log warning. Continue — "MCP tool {name} failed once. Monitoring."
2Escalate warning. Suggest checking server status.
3+TRIP CIRCUIT → output circuit open notice, block further calls to this tool

Non-transient types trip at count 1, not 3. ADMIN_GATED, AUTH, and NOT_FOUND do not recover on retry (an admin must act / credentials must change / the tool is gone), so counting to 3 only wastes calls. On the first failure of one of these types, trip immediately and go to Step 4. The 1→2→3 ramp is for transient types (TIMEOUT, RATE_LIMIT) where a later call may succeed.

Circuit open notice format:

⚡ CIRCUIT OPEN — {tool-name}
Failure type: {TYPE}  |  Consecutive failures: {N}
Further calls to this tool are blocked until circuit resets.

(Blocking is session-level discipline — this skill's protocol, not a mechanical hook; no PreToolUse gate enforces it. State it that way if asked — a protocol honestly labeled beats a phantom enforcement claim.)


Step 3. Log Circuit State

Write state to session-local file (in-memory is insufficient — logs survive /clear):

bash
mkdir -p .claude/mcp_circuit/
grep -qxF '.claude/mcp_circuit/' .gitignore 2>/dev/null \
  || echo "NOTE: add '.claude/mcp_circuit/' to .gitignore — session state must not become a tracked file (the ignored-but-committed class public-surface-audit Step 3c hunts)"
cat >> .claude/mcp_circuit/circuit_log.yaml << EOF
- tool: {tool-name}
  state: OPEN            # OPEN | HALF-OPEN | CLOSED — same enum as Done When
  failure_type: {TYPE}
  failure_count: {N}
  tripped_at: {ISO-8601}
  reset_at: null
EOF

Step 4. Propose Alternatives

Present the relevant fallback options ranked by effort (at least 3):

PriorityAlternativeWhen to Use
1 — Substitute toolUse a different MCP tool or built-in tool that covers the same taskTool-specific failure (NOT_FOUND, AUTH)
1b — Lower-permission API / workflow substituteThe MCP mount is gated, but the underlying capability is usually still reachable through a member-scoped path: a Personal-Access-Token REST API call, or a workflow-automation runner. Before relying on it, confirm credential scope (a member-level token suffices?), audit parity (logged where the MCP path would log?), and behavior gap (what the MCP path does that this does not — e.g. natural-language workflow creation vs hand-written JSON).ADMIN_GATED
2 — Degrade gracefullySkip the MCP step, note the gap, continue with available informationTIMEOUT / RATE_LIMIT
3 — Pause and retryWait for server recovery (HALF-OPEN probe after cooldown)Transient failure (TIMEOUT, RATE_LIMIT)

Gating carries over to the substitute (cross-ref the external-MCP tool-gating rule templates/.claude/rules/mcp_tool_gating.md — template path; if installed live, your repo's .claude/rules/ copy). A REST/API or workflow-automation tool adopted under Priority 1b is still an external-action surface: classify its calls under the same ask/allow tiers — reads are allow (untrusted-read) only after behavior confirmation; any write / send / delete / permission-change stays ask. Trading a gated MCP mount for an ungated REST token does not lower the action's risk — only its permission barrier.

Output format:

## Fallback Options for {tool-name}

Option 1 — Substitute: Use {alternative-tool} instead
  → Command: [specific invocation]
  → Gap: [what's different vs. original tool]

Option 2 — Degrade: Skip this step, continue without {capability}
  → Impact: [what is missing from the output]

Option 3 — Retry after cooldown (60s)
  → Run: /mcp-circuit-breaker reset {tool-name}

Step 5. Recovery Probe (HALF-OPEN)

When user requests reset or after cooldown:

Sending HALF-OPEN probe to {tool-name}...
  • 1 minimal test call is allowed through
  • If success: circuit → CLOSED, log updated
  • If fail: circuit remains OPEN, cooldown resets

Reset log entry — append as a NEW list item (- tool:), never as bare indented keys:

yaml
- tool: {tool-name}
  state: CLOSED
  reset_at: {ISO-8601}
  reset_method: probe_success | user_forced

Why the leading - tool: is load-bearing. The Step 3 log is a YAML list. Appending indented keys with no - merges them into the previous item instead of adding one, and PyYAML resolves duplicate keys silently by keeping the last value — so state: OPEN is overwritten by CLOSED and the trip record disappears. Measured 2026-08-11: trip entry + bare-key reset entry parses to 1 item with state: CLOSED (the OPEN row is gone); the same pair written as two list items parses to 2 items with the trip history intact. The state history is what Step 6 reports on, so a merged entry silently zeroes the failure record.


Step 6. Report

At session end or on demand:

## MCP Circuit Breaker Report

| Tool | State | Failures | Tripped | Reset |
|---|---|---|---|---|
| {tool} | OPEN | 4 | 14:23 | — |
| {tool} | CLOSED | 1 | 14:10 | 14:15 (probe) |

Recommendations:
- {tool}: AUTH failure → refresh credentials in .claude/settings.json

Done When

  • Failure pattern classified (type + count) — judged (adversarial pairing: an UNKNOWN classification must state which Step 1 config reads ran and came back empty — "couldn't determine" without the read evidence is not a classification)
  • Circuit state logged to .claude/mcp_circuit/circuit_log.yaml (OPEN / HALF-OPEN / CLOSED) — mandatory-pass
  • At least 3 fallback alternatives proposed when circuit is OPEN — measured (count ≥3)
  • Recovery probe offered with reset path — mandatory-pass

Chains

Upstream (can trigger this skill):

  • Automatically activates on 3+ consecutive MCP failures during any task

Downstream (after circuit open):

  • No mandatory chain — fallback options are presented, user decides
  • Optional: context-doctor if MCP failure is due to large context degrading tool calls

Heefeg gestallte Froen

Wat mécht de KI-Skill Mcp Circuit Breaker?

Detects MCP tool failure patterns and trips a circuit breaker to stop cascading retries. Proposes fallback alternatives and resets when the tool recovers. Triggers on "MCP failing", "tool keeps erroring", "circuit-breaker", repeated tool call failures.

Firwat Mcp Circuit Breaker op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Mcp Circuit Breaker besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Mcp Circuit Breaker an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/chrono-meta/forge-harness/tree/main/plugins/fh-commons/skills/mcp-circuit-breaker an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Mcp Circuit Breaker benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Mcp Circuit Breaker benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Mcp Circuit Breaker domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Mcp Circuit Breaker gratis?

Jo. chrono-meta huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇