Mihomo AI Provider failover
Use the local mihomo-ai-failover MCP tools. The CLI and daemon are
authoritative for live state and operations; this skill is the canonical
machine-facing workflow and safety contract.
OpenAI is enabled by default. Every other public Provider template is disabled
until local evidence has been reviewed and the user authorizes a private
overlay and persistent profile update.
When to use this skill
Use it for:
- diagnosing ChatGPT page, login, API, streaming, or Codex network failures;
- diagnosing WorkBuddy (China), Kimi, MiniMax, or Mavis network paths;
- discovering sanitized Provider hostnames on the user's Mac and previewing a
narrow, private adaptation;
- inspecting the active, warm, and cold failover pools;
- checking whether the monitor switched correctly or entered backoff;
- previewing, installing, starting, stopping, rolling back, or uninstalling
the local monitor.
Do not use it for general VPN tuning, fastest-node selection, global proxy
changes, unrelated GitHub/npm/Docker failures, arbitrary website monitoring,
non-Mihomo clients, or a remote Mac that the agent cannot reach through a
trusted local MCP client.
Check runtime access before tools
This Skill is an operating contract, not the failover runtime itself. Before
following a tool workflow, check whether the trusted local
mihomo-ai-failover stdio MCP server and its tools are actually available.
- If the MCP tools are available, start with the read-only workflow below.
- If the tools are unavailable, do not claim that this Mac was diagnosed and
do not silently install anything. Report the missing local dependency and
direct the user to the repository root README for the pinned runtime or
plugin installation.
- A cloud-only model cannot reach the user's Mihomo controller. It may explain
the workflow, but it must stop before claiming live state or making changes.
Authority and trust
Use evidence in this order:
- live MCP results for current state;
- live tool descriptions and annotations for exact action semantics;
- this skill for workflow, boundaries, and stop conditions;
- human-facing repository documentation for background.
If live state and documentation disagree, stop and report the mismatch. Never
invent a path, confirmation value, health result, node identity, or successful
operation.
Non-negotiable boundaries
- Diagnose before changing anything.
- Never treat a silent or spinning Codex UI as independent proof that a proxy
node failed.
- Never switch because another node is a few milliseconds faster.
- Never modify Mihomo's generated runtime YAML.
- Never enable TUN, disable the macOS system proxy, restart Codex, or change a
global proxy group.
- Keep Provider state isolated. A WorkBuddy, Kimi, MiniMax, or Mavis failure
must not move the OpenAI group or increment OpenAI failure counters, and vice
versa.
- Keep GitHub, Git, npm, Docker, shared infrastructure, and ordinary websites
out of every Provider failover trigger.
- Never guess a login, API, WebSocket, CDN, storage, or authentication domain.
Public roots are bootstrap hints, not a complete domain claim.
- Do not expose controller secrets, subscription URLs, proxy credentials,
server addresses, exit IPs, or a full node inventory.
- Leave
include_node_names false unless the user explicitly needs node names.
- MCP mutations are disabled by default. Do not ask the user to enable them
until a read-only diagnosis and preview show that a mutation is necessary.
Choose the narrowest tool
| Need |
Tools |
| Inspect available Providers |
list_provider_profiles |
| Compare a Provider's direct and system-proxy paths |
check_provider_paths |
| Observe sanitized local Provider hostnames |
discover_provider_domains |
| Preview a private Provider adaptation |
preview_provider_overlay |
| Write one authorized private adaptation |
apply_provider_overlay |
| Diagnose the current problem |
diagnose_environment, get_status, run_health_check |
| Explain recent behavior |
get_recent_events, get_service_status |
| Inspect pool coverage |
list_pools |
| Test failover invariants without live changes |
simulate_failover |
| Preview installation |
preview_install |
| Record a user-verified real-browser result |
stop_monitor, then record_web_feedback, then start_monitor |
| Perform one authorized local action |
initialize_config, install_failover, start_monitor, stop_monitor, record_web_feedback, rollback_profile, or uninstall_monitor |
Read-only tools are the default. run_health_check performs network requests
but never switches nodes. simulate_failover is isolated and never touches the
live proxy.
For Provider-specific tools, always pass the explicit provider_id. Read
references/provider-adaptation.md before
discovering or enabling a non-OpenAI Provider. Read
references/public-profiles.md when selecting
a built-in profile or interpreting its bootstrap probe.
Diagnose a current failure
- Call
diagnose_environment.
- Call
list_provider_profiles and identify the exact Provider.
- Call
get_status and run_health_check with that provider_id.
- If the failure appears intermittent, compare up to 20 sanitized records with
get_recent_events.
- Explain which layer failed:
- local network or DNS;
- Mihomo controller or dedicated Provider group;
- that Provider's required probes and dedicated proxy group;
- browser or app symptom without a verified network failure.
Do not call an installation or service mutation during diagnosis.
Classify evidence correctly
Hard-failure evidence includes a health-check-classified TCP/TLS failure,
timeout, reset, or verified unavailable/region response. The daemon applies
local-network and controller guards before evaluating a switch. Two guarded
rounds open the fast gate only when at least two distinct critical targets fail
across them. A single repeatedly failing target requires at least three rounds
and 30 seconds of observation. The first hard-failure round confirms only the
selected route; it does not start candidate deep scans or switch the live group.
Within each round, a hard-failing target is retried once; a successful retry
means that round does not count as hard for that target.
Treat these as soft or auxiliary evidence:
- one failed probe;
- a small latency change or one slow response;
- Codex spinning or temporarily producing no output;
- a Cloudflare browser challenge;
- failure of GitHub, Git, npm, Docker, or an ordinary website.
An explicit user report that a Provider login succeeded or failed in the real
browser/app may be recorded with record_web_feedback, but never infer that result
from an automated Cloudflare challenge, a timeout in a browser-control tool, or
Codex behavior. Browser feedback is time-limited, bound to the observed exit
IP + ASN + country fingerprint, and never triggers a switch by itself. Stop the
monitor before recording it, then restart the monitor and return to read-only
verification.
Do not claim that a node should switch from one run_health_check snapshot.
Inspect failover behavior
- Use
list_pools for active, warm, and cold pool counts and independent-exit
coverage.
- Use
simulate_failover to verify the adaptive failure gates, prepared-route
timing, connection-preservation mode, and different-exit preference without
touching the live proxy.
- Use
get_recent_events to distinguish a hard failure, a soft anomaly, a
successful switch, cooldown, and an all-unavailable backoff episode.
- Treat a light delay result as preflight only. A switch candidate needs two
fresh full Provider-path samples, a just-in-time live-core preflight,
live-route verification before commit, and a post-switch probation period.
The deep evidence needs two usable samples with at least one retry-free result.
A retry-assisted live acceptance must pass a mandatory retry-free follow-up
after three seconds before a newly selected route can commit.
- Default connection draining is
preserve: never interpret an old-chain
Codex/ChatGPT WebSocket as stale merely because the group changed. Optional
cleanup requires a newer same-process replacement on the new route.
Adapt a Provider to this Mac
Use the detailed workflow in
references/provider-adaptation.md. The
required order is:
- Diagnose and list profiles; do not mutate.
- Call
check_provider_paths for the target Provider.
If direct is healthy and proxying is unnecessary or worse, do not force the
Provider into this system.
- Ask the user to actively exercise only that Provider during a bounded
discover_provider_domains window.
- Treat known roots as confirmation, process-correlated hosts as candidates,
and temporal-only browser hosts as unproven. Shared infrastructure is never
a failover trigger.
- Corroborate every new exact domain. Mark a domain critical only when a
failed TCP/TLS/HTTP transport path is an objective hard signal for that
Provider. A transport probe does not prove login, account, or model-output
success.
- Call
preview_provider_overlay, explain exact domains, critical probes,
group, files, restart, and resource impact, then obtain authorization.
- Only then call
apply_provider_overlay with local mutation opt-in and the
exact confirmation shown by the tool.
- Preview/apply persistent profile integration, restart Clash Verge if
required, run Provider-specific health/inventory checks, and only then start
or restart the monitor.
The private overlay is local machine state. Never paste its observed domains
into source templates, tests, commits, issues, or model prompts for other
machines.
Install or change the local monitor
- Call
preview_install.
- State the exact local files and services that would change, including
whether Clash Verge must be restarted.
- Ask the user to explicitly authorize the change.
- Only after authorization, tell the user that local mutation opt-in is
required (
MIHOMO_AI_FAILOVER_MCP_MUTATIONS=1 or
mcp_allow_mutations: true).
- Call the relevant mutation with its exact confirmation token. Never invent
or normalize confirmation text.
- Re-run
diagnose_environment and get_service_status.
Use these tools only for the action the user approved:
initialize_config
apply_provider_overlay
install_failover
start_monitor
stop_monitor
record_web_feedback
rollback_profile
uninstall_monitor
The confirmation value is an action guard, not the user's permission. Read the
exact value from the current tool description. Never guess, normalize, or reuse
it for another action. Perform only the one mutation the user authorized, then
return to read-only verification.
Stop and ask the user
Stop before changing state when:
- the user has not authorized the exact action;
preview_install fails or reports an ambiguous target;
- controller ownership, profile source, or persistent enhancement path is
unclear;
- the action would require TUN, a global proxy change, disabling the macOS
system proxy, restarting Codex, or altering unrelated traffic;
- the agent is cloud-only or cannot reach the trusted local stdio MCP server;
- the requested behavior falls outside this skill's supported environment.
- a non-OpenAI Provider has only a public bootstrap root but no local evidence
for the user's real API/auth/streaming path;
- enabling a Provider would require reusing another Provider's group or using
a shared CDN/identity platform as a hard-failure trigger.
Do not turn a diagnosis request into an installation, rollback, or service
change.
Report results
Lead with the verified outcome. Separate observed evidence from inference.
Mention the Provider, whether the operation was read-only, whether a node
switch occurred, which files or services changed, and whether a Clash Verge
restart is still required. Give the smallest safe next action.
Never include controller secrets, subscriptions, proxy credentials, server
addresses, exit IPs, or a full node inventory in the response.
1---2name: dbear-mihomo-ai-failover3description: Diagnose and safely operate automatic proxy failover for ChatGPT, Codex, WorkBuddy (China), Kimi, MiniMax, and Mavis on macOS with Clash Verge Rev and Mihomo. Use when AI login fails, ChatGPT will not load, Codex spins or reports network errors, streaming stalls, or the user needs verified hard-failure detection, stable node switching, Provider-specific routing, local domain discovery, installation, rollback, or recovery.4---56# Mihomo AI Provider failover78Use the local `mihomo-ai-failover` MCP tools. The CLI and daemon are9authoritative for live state and operations; this skill is the canonical10machine-facing workflow and safety contract.1112OpenAI is enabled by default. Every other public Provider template is disabled13until local evidence has been reviewed and the user authorizes a private14overlay and persistent profile update.1516## When to use this skill1718Use it for:1920- diagnosing ChatGPT page, login, API, streaming, or Codex network failures;21- diagnosing WorkBuddy (China), Kimi, MiniMax, or Mavis network paths;22- discovering sanitized Provider hostnames on the user's Mac and previewing a23 narrow, private adaptation;24- inspecting the active, warm, and cold failover pools;25- checking whether the monitor switched correctly or entered backoff;26- previewing, installing, starting, stopping, rolling back, or uninstalling27 the local monitor.2829Do not use it for general VPN tuning, fastest-node selection, global proxy30changes, unrelated GitHub/npm/Docker failures, arbitrary website monitoring,31non-Mihomo clients, or a remote Mac that the agent cannot reach through a32trusted local MCP client.3334## Check runtime access before tools3536This Skill is an operating contract, not the failover runtime itself. Before37following a tool workflow, check whether the trusted local38`mihomo-ai-failover` stdio MCP server and its tools are actually available.3940- If the MCP tools are available, start with the read-only workflow below.41- If the tools are unavailable, do not claim that this Mac was diagnosed and42 do not silently install anything. Report the missing local dependency and43 direct the user to the repository root README for the pinned runtime or44 plugin installation.45- A cloud-only model cannot reach the user's Mihomo controller. It may explain46 the workflow, but it must stop before claiming live state or making changes.4748## Authority and trust4950Use evidence in this order:51521. live MCP results for current state;532. live tool descriptions and annotations for exact action semantics;543. this skill for workflow, boundaries, and stop conditions;554. human-facing repository documentation for background.5657If live state and documentation disagree, stop and report the mismatch. Never58invent a path, confirmation value, health result, node identity, or successful59operation.6061## Non-negotiable boundaries6263- Diagnose before changing anything.64- Never treat a silent or spinning Codex UI as independent proof that a proxy65 node failed.66- Never switch because another node is a few milliseconds faster.67- Never modify Mihomo's generated runtime YAML.68- Never enable TUN, disable the macOS system proxy, restart Codex, or change a69 global proxy group.70- Keep Provider state isolated. A WorkBuddy, Kimi, MiniMax, or Mavis failure71 must not move the OpenAI group or increment OpenAI failure counters, and vice72 versa.73- Keep GitHub, Git, npm, Docker, shared infrastructure, and ordinary websites74 out of every Provider failover trigger.75- Never guess a login, API, WebSocket, CDN, storage, or authentication domain.76 Public roots are bootstrap hints, not a complete domain claim.77- Do not expose controller secrets, subscription URLs, proxy credentials,78 server addresses, exit IPs, or a full node inventory.79- Leave `include_node_names` false unless the user explicitly needs node names.80- MCP mutations are disabled by default. Do not ask the user to enable them81 until a read-only diagnosis and preview show that a mutation is necessary.8283## Choose the narrowest tool8485| Need | Tools |86| --- | --- |87| Inspect available Providers | `list_provider_profiles` |88| Compare a Provider's direct and system-proxy paths | `check_provider_paths` |89| Observe sanitized local Provider hostnames | `discover_provider_domains` |90| Preview a private Provider adaptation | `preview_provider_overlay` |91| Write one authorized private adaptation | `apply_provider_overlay` |92| Diagnose the current problem | `diagnose_environment`, `get_status`, `run_health_check` |93| Explain recent behavior | `get_recent_events`, `get_service_status` |94| Inspect pool coverage | `list_pools` |95| Test failover invariants without live changes | `simulate_failover` |96| Preview installation | `preview_install` |97| Record a user-verified real-browser result | `stop_monitor`, then `record_web_feedback`, then `start_monitor` |98| Perform one authorized local action | `initialize_config`, `install_failover`, `start_monitor`, `stop_monitor`, `record_web_feedback`, `rollback_profile`, or `uninstall_monitor` |99100Read-only tools are the default. `run_health_check` performs network requests101but never switches nodes. `simulate_failover` is isolated and never touches the102live proxy.103104For Provider-specific tools, always pass the explicit `provider_id`. Read105[`references/provider-adaptation.md`](references/provider-adaptation.md) before106discovering or enabling a non-OpenAI Provider. Read107[`references/public-profiles.md`](references/public-profiles.md) when selecting108a built-in profile or interpreting its bootstrap probe.109110## Diagnose a current failure1111121. Call `diagnose_environment`.1132. Call `list_provider_profiles` and identify the exact Provider.1143. Call `get_status` and `run_health_check` with that `provider_id`.1154. If the failure appears intermittent, compare up to 20 sanitized records with116 `get_recent_events`.1175. Explain which layer failed:118 - local network or DNS;119 - Mihomo controller or dedicated Provider group;120 - that Provider's required probes and dedicated proxy group;121 - browser or app symptom without a verified network failure.122123Do not call an installation or service mutation during diagnosis.124125## Classify evidence correctly126127Hard-failure evidence includes a health-check-classified TCP/TLS failure,128timeout, reset, or verified unavailable/region response. The daemon applies129local-network and controller guards before evaluating a switch. Two guarded130rounds open the fast gate only when at least two distinct critical targets fail131across them. A single repeatedly failing target requires at least three rounds132and 30 seconds of observation. The first hard-failure round confirms only the133selected route; it does not start candidate deep scans or switch the live group.134Within each round, a hard-failing target is retried once; a successful retry135means that round does not count as hard for that target.136137Treat these as soft or auxiliary evidence:138139- one failed probe;140- a small latency change or one slow response;141- Codex spinning or temporarily producing no output;142- a Cloudflare browser challenge;143- failure of GitHub, Git, npm, Docker, or an ordinary website.144145An explicit user report that a Provider login succeeded or failed in the real146browser/app may be recorded with `record_web_feedback`, but never infer that result147from an automated Cloudflare challenge, a timeout in a browser-control tool, or148Codex behavior. Browser feedback is time-limited, bound to the observed exit149IP + ASN + country fingerprint, and never triggers a switch by itself. Stop the150monitor before recording it, then restart the monitor and return to read-only151verification.152153Do not claim that a node should switch from one `run_health_check` snapshot.154155## Inspect failover behavior156157- Use `list_pools` for active, warm, and cold pool counts and independent-exit158 coverage.159- Use `simulate_failover` to verify the adaptive failure gates, prepared-route160 timing, connection-preservation mode, and different-exit preference without161 touching the live proxy.162- Use `get_recent_events` to distinguish a hard failure, a soft anomaly, a163 successful switch, cooldown, and an all-unavailable backoff episode.164- Treat a light delay result as preflight only. A switch candidate needs two165 fresh full Provider-path samples, a just-in-time live-core preflight,166 live-route verification before commit, and a post-switch probation period.167 The deep evidence needs two usable samples with at least one retry-free result.168 A retry-assisted live acceptance must pass a mandatory retry-free follow-up169 after three seconds before a newly selected route can commit.170- Default connection draining is `preserve`: never interpret an old-chain171 Codex/ChatGPT WebSocket as stale merely because the group changed. Optional172 cleanup requires a newer same-process replacement on the new route.173174## Adapt a Provider to this Mac175176Use the detailed workflow in177[`references/provider-adaptation.md`](references/provider-adaptation.md). The178required order is:1791801. Diagnose and list profiles; do not mutate.1812. Call `check_provider_paths` for the target Provider.182 If direct is healthy and proxying is unnecessary or worse, do not force the183 Provider into this system.1843. Ask the user to actively exercise only that Provider during a bounded185 `discover_provider_domains` window.1864. Treat known roots as confirmation, process-correlated hosts as candidates,187 and temporal-only browser hosts as unproven. Shared infrastructure is never188 a failover trigger.1895. Corroborate every new exact domain. Mark a domain critical only when a190 failed TCP/TLS/HTTP transport path is an objective hard signal for that191 Provider. A transport probe does not prove login, account, or model-output192 success.1936. Call `preview_provider_overlay`, explain exact domains, critical probes,194 group, files, restart, and resource impact, then obtain authorization.1957. Only then call `apply_provider_overlay` with local mutation opt-in and the196 exact confirmation shown by the tool.1978. Preview/apply persistent profile integration, restart Clash Verge if198 required, run Provider-specific health/inventory checks, and only then start199 or restart the monitor.200201The private overlay is local machine state. Never paste its observed domains202into source templates, tests, commits, issues, or model prompts for other203machines.204205## Install or change the local monitor2062071. Call `preview_install`.2082. State the exact local files and services that would change, including209 whether Clash Verge must be restarted.2103. Ask the user to explicitly authorize the change.2114. Only after authorization, tell the user that local mutation opt-in is212 required (`MIHOMO_AI_FAILOVER_MCP_MUTATIONS=1` or213 `mcp_allow_mutations: true`).2145. Call the relevant mutation with its exact confirmation token. Never invent215 or normalize confirmation text.2166. Re-run `diagnose_environment` and `get_service_status`.217218Use these tools only for the action the user approved:219220- `initialize_config`221- `apply_provider_overlay`222- `install_failover`223- `start_monitor`224- `stop_monitor`225- `record_web_feedback`226- `rollback_profile`227- `uninstall_monitor`228229The confirmation value is an action guard, not the user's permission. Read the230exact value from the current tool description. Never guess, normalize, or reuse231it for another action. Perform only the one mutation the user authorized, then232return to read-only verification.233234## Stop and ask the user235236Stop before changing state when:237238- the user has not authorized the exact action;239- `preview_install` fails or reports an ambiguous target;240- controller ownership, profile source, or persistent enhancement path is241 unclear;242- the action would require TUN, a global proxy change, disabling the macOS243 system proxy, restarting Codex, or altering unrelated traffic;244- the agent is cloud-only or cannot reach the trusted local stdio MCP server;245- the requested behavior falls outside this skill's supported environment.246- a non-OpenAI Provider has only a public bootstrap root but no local evidence247 for the user's real API/auth/streaming path;248- enabling a Provider would require reusing another Provider's group or using249 a shared CDN/identity platform as a hard-failure trigger.250251Do not turn a diagnosis request into an installation, rollback, or service252change.253254## Report results255256Lead with the verified outcome. Separate observed evidence from inference.257Mention the Provider, whether the operation was read-only, whether a node258switch occurred, which files or services changed, and whether a Clash Verge259restart is still required. Give the smallest safe next action.260261Never include controller secrets, subscriptions, proxy credentials, server262addresses, exit IPs, or a full node inventory in the response.