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.2.tar.gz (67.8 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.2-py3-none-win_amd64.whl (5.8 MB view details)

Uploaded Python 3Windows x86-64

unifi_cli-0.1.2-py3-none-manylinux_2_28_x86_64.whl (6.1 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

unifi_cli-0.1.2-py3-none-manylinux_2_28_aarch64.whl (5.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

unifi_cli-0.1.2-py3-none-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

unifi_cli-0.1.2-py3-none-macosx_10_12_x86_64.whl (5.9 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: unifi_cli-0.1.2.tar.gz
  • Upload date:
  • Size: 67.8 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.2.tar.gz
Algorithm Hash digest
SHA256 e50772b55d68caadb88607a1726c120b99007ca9f4ca1151d5ae73ca97a84b29
MD5 c1c32cb996333398e1cf2076446510ad
BLAKE2b-256 deb0100570a1960fa5d8c9f112d469cd6625dfa2f9081c8e6c3a62439116a80c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: unifi_cli-0.1.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 5.8 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.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 f31e5fefe13d6290fbceb9e6e3aacd2ae58fac7095815ca99f260820e734a75b
MD5 8358d3002cc518432b6ed613f1d1e4e7
BLAKE2b-256 03e9afb5c339499ff58c5760ddb0ff506c9470a6dcdfa3870d0aa7e0ae726be3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.2-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bdfd131ead2153836e32ca94ac2a153b84d0746ca7293de3a34ff7e942fc64e8
MD5 3f6706310580f886b59226a665b93b70
BLAKE2b-256 17b58a70f882ede818ef47448799a41f0968105d647b6a05cb7369587150c1c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.2-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 abbc70a579ac502dc3c02c219958d9dfbd38147d1f3a2e52d6b7114117021680
MD5 1c191e6589ff93020ce96937a8c73b1d
BLAKE2b-256 934bd29b5a2ac8bab305d213cde6414d50fca99c7ac7afd8b592518e12f40f95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1f55533899d135bed0bf16e1c9ac602f766e7606d3ebeb779b8336a45fe23be1
MD5 4913b44a39a007f8730b60abb09efee0
BLAKE2b-256 cbbdb888243efb4a1196796ce845bcd0abf8bc06535e9665b6fd18cb6af323fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f86a530d25b13a32751cd534deb71e209c16190f597413f965c2c5246177fdb6
MD5 c0959b39ff31f0abf78df94ff9858d08
BLAKE2b-256 cc9c64605dde3c9b0ae2396e056ba20f76d79ba0370bff8bf5f942e833eb3851

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