Skip to main content

clash-verge-mcp-pro

全面接管 Clash Verge Rev / Mihomo 的 MCP 服务器(二开自 mcp-server-clash-verge)。

相比原版的改进

问题 原版 本项目
传输方式 仅 TCP HTTP(Clash Verge 默认不开,直接连不上) 自动适配 Unix Socket / Named Pipe / TCP
SDK 兼容 旧低阶 API,新版 mcp SDK 下无法启动 基于 mcp SDK 2.x MCPServer
规则修改 只读 增/删/屏蔽规则,持久化 + 热重载
配置生成 完整复刻 Clash Verge enhance 链(SeqMap 卡片 → 模板合并 → 内置守卫 → TUN → DNS → 全局/订阅级 Merge+Script → 权威字段恢复 → 无效引用清理)
JS 脚本 不支持 内置 quickjs 引擎执行 Script 卡片
工具数量 7 58

架构

┌─ 运行时层 mihomo_* ──→ Mihomo 外部控制器(unix socket / TCP 自动检测)
│   节点切换 / 模式 / 连接管理 / providers / DNS 查询 / 缓存清理 / 核心重启
│
└─ 文件层 verge_* ──→ ~/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/
    profiles.yaml 订阅切换 · rules/proxies/groups 卡片增删改 ·
    Merge.yaml 全局合并 · verge.yaml 应用设置 · dns_config.yaml ·
    enhance 链重新生成 → PUT /configs {path} 热重载核心

关键设计:生成的配置写入独立文件 clash-verge-mcp.yaml,不覆盖 Clash Verge 自己的 clash-verge.yaml,与 UI 双向兼容(UI 下次重新生成时读取的是同一份 profiles 源文件)。

安装

cd clash-verge-mcp-pro
uv sync   # 或 uv run 自动处理

MCP 配置(Claude Code ~/.claude.json / AionUi MCP 设置):

{
  "mcpServers": {
    "clash-verge-pro": {
      "command": "uv",
      "args": ["run", "--directory", "<项目绝对路径>", "clash-verge-mcp-pro"],
      "type": "stdio"
    }
  }
}

工具一览(58 个)

运行时层 — 基础

  • mihomo_status / mihomo_restart_core / mihomo_upgrade_core
  • mihomo_list_proxies / mihomo_switch_proxy / mihomo_test_delay / mihomo_test_group_delay / mihomo_unfix_proxy
  • mihomo_get_configs / mihomo_patch_configs / mihomo_reload_config
  • mihomo_list_rules
  • mihomo_list_connections / mihomo_close_connection / mihomo_close_all_connections
  • mihomo_list_providers / mihomo_update_provider / mihomo_healthcheck_provider
  • mihomo_dns_query / mihomo_flush_cache

运行时层 — 实时流与自动化

  • mihomo_recent_logs(WS 采集核心日志,排障利器)
  • mihomo_traffic_snapshot / mihomo_memory_snapshot
  • auto_select_fastest(测速 → 切最快节点 → 断旧连接,一句话完成)

文件层 — 规则与订阅

  • verge_add_rules / verge_remove_rules / verge_list_rule_overrides ← 规则增删改
  • verge_add_subscription / verge_update_subscription / verge_subscription_info(流量/到期监控)
  • verge_list_profiles / verge_switch_profile / verge_read_profile

文件层 — 节点/组/规则集

  • verge_add_proxies(任意协议自定义节点)
  • verge_add_group / verge_remove_group
  • verge_add_ruleset / verge_remove_ruleset(ACL4SSR 等第三方规则集)

文件层 — 配置与调试

  • verge_get_merge / verge_update_merge
  • verge_get_settings / verge_patch_settings
  • verge_get_dns_config / verge_save_dns_config
  • verge_preview_config / verge_apply_config
  • verge_trace_domain(模拟规则匹配,查"为什么这个域名没走代理")
  • verge_check_rules(重复规则/不可达规则体检)

安全网

  • verge_backup / verge_list_backups / verge_rollback(所有破坏性操作自动先备份)

场景与审计

  • verge_save_scene / verge_apply_scene / verge_list_scenes / verge_delete_scene(模式+各组节点选择+规则卡片的一键场景切换,如"游戏模式")
  • verge_audit_routing(批量域名分流审计:每个域名命中哪条规则、走哪个出口)
  • verge_diff(apply 前预览:将生成的配置 vs 运行中的配置)
  • mihomo_update_geo(在线更新 geoip/geosite/mmdb)

环境变量(可选)

  • MIHOMO_API_URL:覆盖控制器地址,支持 unix:///path/to.sockhttp://host:port
  • MIHOMO_API_SECRET:覆盖 API 密钥
  • CLASH_VERGE_HOME:覆盖数据目录(多客户端适配;缺省自动探测 Clash Verge Rev → 旧版 → ClashX 路径)

已知边界

  • 切换订阅/修改 verge.yaml 后,Clash Verge UI 状态不会实时同步(应用重启后一致);核心侧立即生效
  • 修改 verge.yaml 中系统代理/TUN 等应用级开关,建议随后调用 verge_apply_config,部分需重启应用
  • mihomo_upgrade_core 仅 alpha 内核支持
  • 规则追踪不评估逻辑规则(AND/OR/NOT)与 GEOIP/GEOSITE(需要 mmdb/geosite 数据)

发布 PyPI(待办)

uv build
uv publish --token <pypi-token>   # 需要你自己注册 PyPI 账号

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clash_verge_mcp_pro-0.1.0.tar.gz (117.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clash_verge_mcp_pro-0.1.0-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

Details for the file clash_verge_mcp_pro-0.1.0.tar.gz.

File metadata

  • Download URL: clash_verge_mcp_pro-0.1.0.tar.gz
  • Upload date:
  • Size: 117.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clash_verge_mcp_pro-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6eff585b222894ff8c23cff66fb2bc17433e198d9a81d5fba5f075f38994d4cf
MD5 2e577224b6876b469f866b5be798cf9f
BLAKE2b-256 63687db610d5b33ef9ca8fdd40522c28290f4c09a55b7d6e47a77b84265da895

See more details on using hashes here.

File details

Details for the file clash_verge_mcp_pro-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clash_verge_mcp_pro-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clash_verge_mcp_pro-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 244689057231a2438743c1e12720adae6d7edd66e00dcf1ea767e318e2cbb328
MD5 d006012e169499424545a9e68f2199b5
BLAKE2b-256 da16fea68fa39884515f70145543c7cc6a377c15e7f6a6851cbdf42723919bcd

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page