/fh-commons:mcp-circuit-breakerfrom fh-commons
Detects MCP tool failure patterns and trips a circuit breaker to stop cascading retries. Proposes fallback alternatives and resets when the tool recovers.
Ships in fh-commons. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
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
/mcp-circuit-breakerCLOSED → 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:
TIMEOUT, RATE_LIMIT, and MALFORMED / UNKNOWN until known); 1 for the non-transient types (ADMIN_GATED, AUTH, NOT_FOUND, WRONG_SHAPE) — see Step 2Identify the failing tool and failure mode:
# 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:
| Type | Symptom | Likely Cause |
|---|---|---|
TIMEOUT | Tool call hangs >30s | Server overload / network |
AUTH | 401 / 403 response | Credentials expired or missing |
NOT_FOUND | 404 / tool not available | Server down / tool removed |
MALFORMED | Parse error on response | Schema mismatch / API change |
WRONG_SHAPE | No error and a success status (e.g. HTTP 200), but the answer is not the expected shape — an HTML page where JSON was expected, or an expected field missing | Wrong host or path (a field run: a webhook path called on the API host returned 200 with a generic HTML page, so the call «succeeded» and did nothing) — retrying the same endpoint will not fix it |
RATE_LIMIT | 429 / quota exceeded | Too many calls |
ADMIN_GATED | "instance admin approval required" / server pending org enablement / tool unavailable until approved | Capability 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.
MALFORMED vs WRONG_SHAPE: the answer could not be parsed at all → MALFORMED; it parsed (or arrived as a page) but is not what the caller needs → WRONG_SHAPE.
ADMIN_GATEDis 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).
Count consecutive failures of the identified tool in the current session context.
| Count | Action |
|---|---|
| 1 | Transient type: log warning and continue — "MCP tool {name} failed once. Monitoring." Non-transient type (see below): TRIP CIRCUIT now |
| 2 | Transient type: escalate 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,NOT_FOUNDandWRONG_SHAPEdo not recover on retry (an admin must act / credentials must change / the tool is gone / the host or path is wrong, so the same call keeps getting the same wrong answer), 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.)
Write state to session-local file (in-memory is insufficient — logs survive /clear):
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}
expected_shape: {content type + the field the caller needs — WRONG_SHAPE only; the Step 5 probe checks against it}
tripped_at: {ISO-8601}
reset_at: null
EOF
Present the relevant fallback options ranked by effort (at least 3):
| Priority | Alternative | When to Use |
|---|---|---|
| 1 — Substitute tool | Use a different MCP tool or built-in tool that covers the same task | Tool-specific failure (NOT_FOUND, AUTH) |
| 1a — Fix the endpoint | Check the configured host and path against the service's documentation (an API host and a webhook host are often different), correct it, then let the Step 5 probe confirm the expected shape | WRONG_SHAPE |
| 1b — Lower-permission API / workflow substitute | The 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 gracefully | Skip the MCP step, note the gap, continue with available information | TIMEOUT / RATE_LIMIT |
| 3 — Pause and retry | Wait 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 areallow (untrusted-read)only after behavior confirmation; any write / send / delete / permission-change staysask. 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}
When user requests reset or after cooldown:
Sending HALF-OPEN probe to {tool-name}...
WRONG_SHAPE, and the circuit stays OPENReset log entry — append as a NEW list item (- tool:), never as bare indented keys:
- 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 — sostate: OPENis overwritten byCLOSEDand the trip record disappears. Measured 2026-08-11: trip entry + bare-key reset entry parses to 1 item withstate: 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.
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
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).claude/mcp_circuit/circuit_log.yaml (OPEN / HALF-OPEN / CLOSED) —
mandatory-passUpstream (can trigger this skill):
Downstream (after circuit open):
context-doctor if MCP failure is due to large context degrading tool callsWhat SKILL.md sets; muted values are Claude Code's defaults
sonnetThree short reads, in order
8 skills in this plugin
/convergence-loopA universal gate-reinforcement meta-skill that replaces the "single-pass = done" pattern with a converging loop of up to N rounds. Can be applied to any gate, checkpoint, or verification step. Only declares "truly passed" after FAIL→FIX→re-verify repeats until convergence (all items pass). Escalates to structural redesign if not converged within N rounds. Triggers on: "convergence-loop", "how many rounds do we need", "suspicious of single-pass", "not sure if it really passed", or equivalent phrasing./deliberationMulti-perspective synthesis structure — Innovator (propose) → Devil-Advocate (challenge) → Mediator (synthesize) 3-layer execution. Outputs conditional verdicts without binary win/loss. Activates on "deliberation", "battle this out", "weigh the pros and cons", "review from multiple angles", "which side is right?". Optional deep-insight persona jurors for domain-specific views. Designed for design decisions, skill proposals, and architectural choices./essay-writerDrafts, revises and audits reflective non-fiction essays and essay serials (philosophy, humanities, science-meets-life pieces, platform serials, book chapters) — Korean first, other languages by the same steps. Pins the author's voice decisions before any edit (narrator person including the inclusive "we", register, length band, where each signature image lives), runs a claim gate that separates sourced fact, contested fact and interpretation, maps repeated images and verbatim sentences across episodes, calibrates hedging so conviction survives, and checks mobile rhythm and episode-to-episode bridges. The essay writer is the only one who edits prose; a technical reviewer critiques read-only. Technical docs, tech-blog posts and talk scripts go to ko-tech-writer instead. Triggers: "에세이 다듬어줘", "연재 원고 검토해줘", "브런치 연재 회차 점검해줘", "이 글 단정적인 데 없나 봐줘", "에세이에서 1인칭 빼줘", "회차마다 같은 비유가 반복되나 봐줘", "review my essay serial", "audit this essay for overclaiming"./ko-tech-writerWrites or revises Korean technical prose across three registers — reader-facing documents (tech-blog posts, technical docs), spoken scripts, and derived compressed assets (teasers, summaries) — through a fixed pipeline: register detection, real-sample calibration of the target venue, a translationese-removal pass, honesty-level layering (reader information vs internal audit vocabulary), a number/claim gate, and a rendition + perceptual QA pass. Triggers: "기술문서 써줘", "테크블로그 초안 잡아줘", "이 문서 번역투 고쳐줘", "블로그체로 다듬어줘", "이 글 회사 기술블로그에 올릴 수 있게 다듬어줘", "발표 대본 다듬어줘", "낭독 대본 점검해줘", "이 스크립트 소리 내서 읽을 때 걸리는 데 있나"./persona-castUse to get a screen, page, form, flow or spec looked over the way its users and a review team would: does it look right, is the wording clear, where would someone get confused or stuck. Sends it to separate reviewer personas (designer, UX writer, front/back-end dev, QA, accessibility) and keeps what each one alone caught. Triggers: "이 화면 어때?", "이 페이지 괜찮아 보여?", "화면 문구 어색한 데 없어?", "사용자가 헷갈릴까?", "디자이너·QA 눈으로 봐줘", "does this page look okay?", "is the wording on this screen clear?", "persona-cast"./standpoint-reviewStandpoint review — check a change from the side that RECEIVES it: copy the receiving repo (or a clean install of the package) into an isolated folder, apply the change there, run that repo's OWN checks, have a reviewer judge the change against that repo's OWN rules with none of the author's explanation, then verify every finding against the source before acting on it. Use when asked whether a change breaks, or still works with, another repo, app, harness or package consumer that depends on it. Triggers: "입장 리뷰", "받는 쪽에서 돌려 봐", "하위 레포에서 돌려 봐", "그 레포 규칙으로 검증해 줘", "standpoint review", "run it from the target", "check it from the downstream repo", "make sure it won't break the repo that depends on it", "will this change break downstream users".npx claudepluginhub chrono-meta/forge-harness --plugin fh-commonsOther plugins' skills for the same job