mcpField
U
usm-cli

usm-cli

github.com/dl-alexandreCloud & DevOps140 installsUpdated 4w ago
Repository

About usm-cli

usm-cli is a command-line skill for the UniFi Site Manager API, intended for people managing cloud-based UniFi sites. It supports listing and filtering sites, retrieving individual site details, and producing table or JSON output.

Key features

  1. 01Set up CLI configuration
  2. 02List and filter sites with pagination
  3. 03Retrieve site details
  4. 04Verify account authentication
  5. 05Output tables or JSON

Use cases

  1. 01Browse or search cloud UniFi sites
  2. 02Export a site list as JSON
  3. 03Check API key authentication in CI/CD

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dl-alexandre/skills --skill usm-cli

After installing, type/usm-cliin Claude Code to confirm it loaded.

Details

From the project README

Skill: usm-cli

UniFi Site Manager CLI

This skill provides guidance for the usm CLI tool, a command-line interface for the UniFi Site Manager API.

Overview

usm provides cloud-based management of UniFi sites via the official Site Manager API at api.ui.com. For local controller APIs (Network, Protect), see the separate unifi CLI.

Installation

Homebrew
brew tap dl-alexandre/tap
brew install usm
Manual

Download from GitHub Releases:

# macOS (Apple Silicon)
curl -L https://github.com/dl-alexandre/UniFi-Site-Manager-CLI/releases/latest/download/usm-darwin-arm64 -o usm
chmod +x usm
sudo mv usm /usr/local/bin/

Quick Start

  1. Get API Key from unifi.ui.com → Settings → Control Plane → Integrations → API Keys

  2. Configure:

usm init
# Or: export USM_API_KEY="your-api-key"
  1. Verify:
usm whoami
  1. List sites:
usm sites list

Available Commands

usm init

Interactive configuration setup. Creates ~/.config/usm/config.yaml.

Use when:

  • First-time setup
  • Changing default settings (base URL, output format, color mode)

Flags:

  • --force - Overwrite existing config
usm sites list

List all sites with pagination and filtering.

Use when:

  • Getting an overview of all UniFi sites
  • Finding a specific site by name
  • Exporting site data

Flags:

  • --page-size=N - Number of sites per page (default: 50, 0 = fetch all)
  • --search=<term> - Filter by name/description
  • --output=json|table - Output format
  • --no-headers - Table without headers (for scripts)

Examples:

usm sites list                          # Default: 50 sites
usm sites list --page-size 0            # Fetch all sites
usm sites list --search "office"        # Filter by name
usm sites list --output json            # JSON output
usm sites list --no-headers             # For piping to other tools
usm sites get

Get detailed information about a specific site.

Use when:

  • You need details about one specific site
  • You have a site ID and want to verify it exists

Examples:

usm sites get 60abcdef1234567890abcdef
usm sites get 60abcdef1234567890abcdef --output json
usm whoami

Show authenticated user account information.

Use when:

  • Verifying API key is working
  • Checking which account you're authenticated as

Examples:

usm whoami
usm whoami --output json
usm version

Show version information.

Use when:

  • Checking installed version
  • Checking for updates (with --check)

Flags:

  • --check - Check GitHub for latest release

Configuration

Config file: ~/.config/usm/config.yaml

Note: API keys are NOT stored in config. Use environment variables or flags.

api:
  base_url: https://api.ui.com
  timeout: 30

output:
  format: table      # table, json
  color: auto        # auto, always, never
  no_headers: false

Environment Variables

VariableDescription
USM_API_KEYAPI key for authentication (required)
USM_BASE_URLAPI base URL (default: https://api.ui.com)
USM_TIMEOUTRequest timeout in seconds
USM_FORMATDefault output format
USM_COLORColor mode
USM_NO_HEADERSDisable table headers
USM_CONFIGPath to config file

Exit Codes

CodeMeaning
0Success
1General error
2Authentication failure
3Permission denied
4Validation error
5Rate limited
6Network error

API Reference

Related Tools

  • unifi CLI - For local UniFi Network and Protect APIs

Common Workflows

List all sites and export to JSON
usm sites list --page-size 0 --output json > sites.json
Find a site by name and get its details
SITE_ID=$(usm sites list --search "Office" --output json | jq -r '.[0]._id')
usm sites get "$SITE_ID"
Check authentication in CI/CD
usm whoami || exit 1
Table output for reports
usm sites list --no-headers | column -t

Comments

Markdown supported