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.1.tar.gz (64.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.1-py3-none-win_amd64.whl (2.8 MB view details)

Uploaded Python 3Windows x86-64

unifi_cli-0.1.1-py3-none-manylinux_2_28_x86_64.whl (3.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

unifi_cli-0.1.1-py3-none-manylinux_2_28_aarch64.whl (2.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

unifi_cli-0.1.1-py3-none-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

unifi_cli-0.1.1-py3-none-macosx_10_12_x86_64.whl (2.9 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: unifi_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 64.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.1.tar.gz
Algorithm Hash digest
SHA256 9582b71cf8f6b833b0626aefba38c939e9e1d17bce6b3a5491de509d46c1530d
MD5 8bbb789370cd010108a721e580f9738d
BLAKE2b-256 ae2c3755e36cde088ee8a2b3de16683db84b451a7bf5cf2d9769bffd51d5e0f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: unifi_cli-0.1.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.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.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9b2645c5e22ad26bc44869dda5977ddf130df19e8e67c780a26e4eb76acbf026
MD5 317f501c3b40ff3214731b8dbf2435c9
BLAKE2b-256 d53357b41386fd2c645d537274465e5f15a2f12cdacf22ea8e3d200741c6b14b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 77e101674d40d4d6204a0714d80ca11258f3b31c0caa1f8f0f0eeebe2d5c36bc
MD5 45b03e751a261ef189d693a2d20017b0
BLAKE2b-256 43659a61106e66004e3d701ab4d175c28e377117617438b43e4cc007443aff3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.1-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 51daab2072e4ba5246223fa9424615f4a02fab3aef195a03f3e89d02311b81f3
MD5 63fd158ba94b35ae5558e07f099d8e91
BLAKE2b-256 e042538812213d56998c71d12d3737597634c2c71ac658b715953c1ae490c1ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 424e154fe9bb31fef519939b9d417381bd620d0f159b29cd3fa299a9381684f5
MD5 994cabe6fcb2e1666f2710fa93d2717a
BLAKE2b-256 2467886b5f369923d5f51716a59c65fde7f56b8b5e9d86c8a3a21354c6d01577

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b2f68a925852490685ce9275d061828570c5062639608c358fb32b3df335c9fc
MD5 95756054f64b5220936001ee95e5e308
BLAKE2b-256 fea06b9d5c9402c129e6a1a1401f8291dfd946d8fb35eb13f490f50d2aa3fcf3

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