Skip to main content

CLI for UniFi Network controller

Project description

unifi-cli

CLI for UniFi Network controller. Designed for both human operators and AI agents.

Installation

From source

cargo install unifi-cli

From GitHub releases

Pre-built binaries are available for Linux (x64, arm64), macOS (x64, arm64), and Windows (x64) on the releases page.

Configuration

Configuration can be provided via CLI flags, environment variables, or a config file.

CLI flags

unifi-cli --host https://unifi.example.com --api-key YOUR_KEY clients list

Environment variables

export UNIFI_HOST=https://unifi.example.com
export UNIFI_API_KEY=YOUR_KEY
unifi-cli clients list

Config file

Create ~/.config/unifi-cli/config.toml:

host = "https://unifi.example.com"
api_key = "YOUR_KEY"

Usage

Clients

unifi-cli clients list                          # List connected clients
unifi-cli clients show aa:bb:cc:dd:ee:ff        # Show client details
unifi-cli clients block aa:bb:cc:dd:ee:ff       # Block a client
unifi-cli clients unblock aa:bb:cc:dd:ee:ff     # Unblock a client
unifi-cli clients kick aa:bb:cc:dd:ee:ff        # Disconnect a client
unifi-cli clients set-fixed-ip MAC IP [--name]  # Set DHCP reservation

Devices

unifi-cli devices list                          # List network devices
unifi-cli devices restart aa:bb:cc:dd:ee:ff     # Restart a device
unifi-cli devices locate aa:bb:cc:dd:ee:ff      # Blink locate LED
unifi-cli devices locate aa:bb:cc:dd:ee:ff --off  # Stop blinking

Networks

unifi-cli networks                              # List all networks

System

unifi-cli system health                         # Show subsystem health
unifi-cli system info                           # Show controller info

Agent-friendly design

unifi-cli is designed to work well with AI agents and automation scripts. Instead of requiring an MCP server, agents can call the CLI directly with lower overhead and better composability.

Automatic JSON output

When stdout is not a terminal (piped or redirected), output switches to JSON automatically. No flags needed.

# Human at terminal: gets a formatted table
unifi-cli clients list

# Agent piping output: gets JSON automatically
data=$(unifi-cli clients list)

You can also force JSON mode explicitly:

unifi-cli --json clients list

Clean stdout/stderr separation

Data goes to stdout. Human messages (summaries, confirmations) go to stderr. This means piping and redirection always capture clean, parseable data.

# stdout has only the JSON data, stderr has "12 clients"
unifi-cli clients list > clients.json

Quiet mode

Suppress all non-data output with --quiet:

unifi-cli --quiet clients list    # No summary line on stderr

Structured mutation responses

Commands that change state (block, kick, restart, etc.) return structured JSON:

unifi-cli --json clients block aa:bb:cc:dd:ee:ff
# {"action": "block", "mac": "AA:BB:CC:DD:EE:FF", "status": "ok"}

Runtime schema introspection

The schema command dumps all commands, arguments, output fields, and exit codes as JSON. Agents can discover capabilities at runtime without parsing --help text.

unifi-cli schema

This outputs the full command tree including which commands are mutating, what arguments they accept, and what fields appear in the JSON output.

Distinct exit codes

Agents can branch on specific failure modes without parsing error messages:

Code Meaning
0 Success
1 General error
2 Configuration error (missing host or API key)
3 Authentication error (401/403)
4 Not found (404)
5 API error (server error)

Why CLI over MCP?

For AI agent integrations, a well-designed CLI has several advantages over an MCP server:

  • Token efficiency -- a CLI call uses ~35x fewer tokens than the MCP tool-call protocol
  • Composability -- pipe output to jq, grep, or other tools
  • No server process -- no sidecar to run, no port to manage
  • Universal -- works from any language, shell, or automation framework

Development

make check      # Lint and test
make test       # Run tests
make install    # Build and install to ~/.local/bin

License

MIT

Project details


Download files

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

Source Distribution

unifi_cli-0.1.3.tar.gz (72.0 kB view details)

Uploaded Source

Built Distributions

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

unifi_cli-0.1.3-py3-none-win_amd64.whl (5.6 MB view details)

Uploaded Python 3Windows x86-64

unifi_cli-0.1.3-py3-none-manylinux_2_28_x86_64.whl (5.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

unifi_cli-0.1.3-py3-none-manylinux_2_28_aarch64.whl (5.5 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

unifi_cli-0.1.3-py3-none-macosx_11_0_arm64.whl (5.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

unifi_cli-0.1.3-py3-none-macosx_10_12_x86_64.whl (5.7 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file unifi_cli-0.1.3.tar.gz.

File metadata

  • Download URL: unifi_cli-0.1.3.tar.gz
  • Upload date:
  • Size: 72.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for unifi_cli-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9f6ec02c8aa116250b76e7360b0d088ba00e13f40142a10a7feebfa8a8e836a7
MD5 4da93380828bd4c796ac66bf2457cbed
BLAKE2b-256 1369e4691b69370d7d39f71a7d29de800cfaeadefeadaa61f517a09572736c44

See more details on using hashes here.

File details

Details for the file unifi_cli-0.1.3-py3-none-win_amd64.whl.

File metadata

  • Download URL: unifi_cli-0.1.3-py3-none-win_amd64.whl
  • Upload date:
  • Size: 5.6 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for unifi_cli-0.1.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5e3771d688b3c7cf28b4f192b04f5580e67499e1674ad85325a27b710ca6d298
MD5 8da73d8552d7ee2d516350f993ef971e
BLAKE2b-256 29d650579edf23fb71e3a160d4f1d2ae3f4ccef93c73c63c2007b19175bbb055

See more details on using hashes here.

File details

Details for the file unifi_cli-0.1.3-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for unifi_cli-0.1.3-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ab30de5c5d7aa7fca95e0176fe8094ed174e88022517f9f6afba43e88176f62d
MD5 52e4826f9cd6cf04815667464f6876c6
BLAKE2b-256 acee8c82d489ccea09169e2018655abd1c2d5747e7801016efa20e61ea99d8ea

See more details on using hashes here.

File details

Details for the file unifi_cli-0.1.3-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for unifi_cli-0.1.3-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b7227c3dab7a1c7819ff48cffb71071c6c36ab196492d26cf4cbf44c730dc2c5
MD5 183fa56bbae1ddeff54e95c4a364bf4a
BLAKE2b-256 0ef629c1b7511f4b5c3a6522458b2cedac17dd07de79bf8e026d4de58d0475be

See more details on using hashes here.

File details

Details for the file unifi_cli-0.1.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for unifi_cli-0.1.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eee5a444523d909830b8781a44fa6b895e2ee1a68fa6ecba6dc7cf184cc78632
MD5 6bd95e5ea7ad25c2c475096a723c563e
BLAKE2b-256 f0b21a830829ff76ed7a3b925f21338c9e7f9537ea2d20436a706899e811fc92

See more details on using hashes here.

File details

Details for the file unifi_cli-0.1.3-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for unifi_cli-0.1.3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 77b4ebd800b1c6178b35f9ab2aa8549301916980042c8cc043faa0bff4493c6d
MD5 9b23265b53fa175f5a8f3e83b4ad7767
BLAKE2b-256 958df946b2fe62b0d34fd143205ef99c538e7f3b6099d5ea83cc84d203a53efd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page