Skip to main content

mihomo-cli

English | 简体中文

A command-line, Clash-style proxy client for Linux machines without a desktop, powered by the mihomo core. Use it through an interactive menu or plain commands.

  • Proxy services: an airport subscription, a local Clash/mihomo file, or hand-added node links (e.g. your own VPS)
  • Switch nodes without restarting; latency test and automatic fastest-node pick
  • Global / rule / direct modes, plus a switch for whether domestic (CN) sites go direct
  • Background systemd service, installed with a single sudo; no root needed day to day
  • Optional TUN mode for the whole machine, including programs that ignore proxy settings
  • Every change is validated, backed up, and rolled back automatically if it fails
  • doctor self-check with fixes, --json output, English / Chinese interface, shell completion

Supported: Linux (tested on Ubuntu 20.04 / 22.04 / 24.04), Python 3.8+. macOS and Windows are not supported yet.

Install

pipx install mihomo-cli
mihomo-cli install            # downloads the mihomo core and geo data, installs the service (asks for sudo once)

If GitHub is slow to reach, pass a mirror that proxies https://github.com:

mihomo-cli install --mirror https://your-mirror.example/https://github.com

Quick start

mihomo-cli profile add airport --url 'https://example.com/sub?token=...'
# or a single self-hosted node
mihomo-cli profile add vps --node 'vless://...#my-vps'

mihomo-cli node auto          # pick the fastest node
mihomo-cli status             # one-screen overview including exit IP
eval "$(mihomo-cli proxy-env on)"   # proxy the current shell (127.0.0.1:7897)

Run mihomo-cli with no arguments to open the menu. mihomo-cli help <command> shows help and examples.

Commands

Command What it does
status Service, core, proxy service, node, mode, CN switch, TUN, port, exit IP
install / uninstall Install or remove the core and the systemd service
core upgrade Replace the core; the old one is kept if verification fails
service start/stop/restart/status/logs Control the background service
profile list/show/add/rm/use/update/rename Manage proxy services
node list/use/add/rm/restore/test/auto Manage nodes of the active proxy service
mode [global/rule/direct] Show or set the mode
cn [direct/proxy] Domestic sites direct or via proxy (rule mode)
tun on/off/status Whole-machine TUN mode (on/off need sudo)
proxy-env [on/off] Print shell statements for proxy variables
conns / logs Active connections and core logs
backup list/restore Automatic backups (latest 10)
doctor [--fix] 15 checks with fix hints
completion bash/zsh [--install] Shell completion and the mproxy on/off helper

Global options: --json, --lang zh|en, --home DIR (or MIHOMO_CLI_HOME), --version.

Exit codes: 0 ok, 1 error, 2 usage, 3 core unreachable, 4 invalid config or rolled back, 5 needs sudo or run as root, 6 unsupported platform, 7 rollback incomplete (manual action needed).

Files

Everything lives in ~/.local/share/mihomo-cli (mode 0700): state.yaml (what you asked for — the source of truth), the generated config.yaml, the core in bin/, backups/, and mihomo-cli.log. The service unit is /etc/systemd/system/mihomo-cli.service.

Notes

  • The mihomo core (GPL-3.0) is not bundled; it is downloaded from the official releases and checked against the published SHA-256 digest when available.
  • mihomo-cli runs as its own instance and does not touch other mihomo / Clash services. Only one TUN can be active on a machine; tun on refuses if another one is running.
  • Do not run mihomo-cli with sudo; it calls sudo itself for the few steps that need it.

License

MIT

Metadata

Release files for mihomo-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mihomo-cli 0.1.0
File Size Uploaded Provenance
mihomo_cli-0.1.0.tar.gz 87.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mihomo-cli 0.1.0
File Interpreter ABI Platform
mihomo_cli-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 169.7 kB

Release files / mihomo_cli-0.1.0.tar.gz

Download URL mihomo_cli-0.1.0.tar.gz
Size 87.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7d630385fb0f20f50536ed2236b8edde8caef7dc38e2bb0da522045727593c20
BLAKE2b-256 checksum
How to use checksums
00bcbded4ad921784a925901c4b3deb1bde225f15948f024779ac4fdcf2c428b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / mihomo_cli-0.1.0-py3-none-any.whl

Download URL mihomo_cli-0.1.0-py3-none-any.whl
Size 82.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b8681779ff25a81204a04d3d2633416b5615c94d2b9d85e32623b3cee9665b0
BLAKE2b-256 checksum
How to use checksums
df2f770440bd69706b2f3539599d81fe2536102828429f89a62da14c64ac4805
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for mihomo-cli 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mihomo_cli-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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