Ubiquiti UniFi MCP Server — device monitoring, client visibility, firewall state, and network security
Project description
ubiquiti-unifi-blade-mcp
An MCP server that gives AI agents structured access to Ubiquiti UniFi network controllers. Built for the Model Context Protocol with security visibility and token efficiency as first-class design goals.
Why this exists
UniFi controllers expose a rich but undocumented REST API behind cookie-based auth with CSRF tokens and optional 2FA. The aiounifi library (MIT, powers the Home Assistant integration) handles the protocol complexity — UniFi OS vs classic controller detection, TOTP 2FA, websocket events. This MCP wraps it with the guardrails that automated agents need:
- Security-first tool set — 18 tools focused on what network security agents actually need: device health, client visibility, firewall state, traffic rules, DPI restrictions, port forwards. Not 161 tools for every possible configuration change.
- Token-efficient output — compact pipe-delimited format. A 30-device network in ~50 tokens per device. Client listings with signal strength, experience score, and blocked status at a glance.
- Write-gated mutations — client blocking, WLAN toggling, device restart, and traffic route changes require explicit opt-in via
UNIFI_WRITE_ENABLED=true. Destructive operations (block, restart) additionally require per-callconfirm=true. - Multi-controller — manage home and office networks from a single MCP instance. Each controller authenticates independently with separate sessions.
How this differs from other UniFi MCPs
| ubiquiti-unifi-blade-mcp | sirkirby/unifi-mcp | enuno/unifi-mcp-server | |
|---|---|---|---|
| Focus | Monitoring + security (18 tools) | Full management (161 tools) | Full management (74 tools) |
| Design for | LLM agents (token-efficient) | Claude Code (lazy loading) | General MCP clients |
| Multi-controller | Native (env var config) | Single controller | Multi-mode (local/cloud) |
| Write safety | Dual-gated (env + confirm) | Preview-then-confirm | Permission model |
| 2FA support | TOTP via aiounifi | TOTP support | API key option |
| Output | Pipe-delimited, compact | Full JSON | Full JSON |
| Marketplace | Sidereal certified | Claude Code plugin | Standalone |
Use this blade-MCP for agent-driven monitoring and security. Use sirkirby/unifi-mcp (available as a community listing in the Sidereal marketplace) when you need full network configuration management.
Quick start
# Install
uv pip install -e .
# Configure
export UNIFI_HOST="192.168.1.1"
export UNIFI_USERNAME="admin"
export UNIFI_PASSWORD="your-password"
export UNIFI_VERIFY_SSL="false" # Common for self-signed certs
# Run
ubiquiti-unifi-blade-mcp
18 tools, 5 categories
Info & Sites (2 tools)
| Tool | Purpose | Token cost |
|---|---|---|
unifi_info |
Health check — controller version, hostname, device/client counts, write gate | ~60 |
unifi_sites |
List sites on the controller | ~20/site |
Devices (2 tools)
| Tool | Purpose | Token cost |
|---|---|---|
unifi_devices |
List APs, switches, gateways — model, state, clients, uptime, firmware | ~50/device |
unifi_device |
Full detail — port table with PoE, firmware, upgrade status | ~150 |
Clients (2 tools)
| Tool | Purpose | Token cost |
|---|---|---|
unifi_clients |
Connected clients — name, IP, SSID, signal, experience, blocked | ~40/client |
unifi_client |
Full detail — TX/RX, vendor (OUI), AP association | ~120 |
Firewall & Security (5 tools)
| Tool | Purpose | Token cost |
|---|---|---|
unifi_firewall |
Firewall policies — name, action, enabled/disabled | ~30/policy |
unifi_traffic_routes |
Traffic routes — description, enabled/disabled, target | ~25/route |
unifi_traffic_rules |
Traffic rules — description, action, enabled/disabled | ~25/rule |
unifi_port_forwards |
Port forwards — name, protocol, external → internal | ~30/fwd |
unifi_dpi |
DPI restriction groups and apps | ~20/item |
Write Operations (7 tools, gated)
| Tool | Gate | Purpose |
|---|---|---|
unifi_block_client |
write + confirm | Block a client from the network |
unifi_unblock_client |
write | Unblock a previously blocked client |
unifi_reconnect_client |
write | Force a wireless client to reconnect |
unifi_toggle_wlan |
write | Enable or disable an SSID |
unifi_toggle_traffic_route |
write | Enable or disable a traffic route |
unifi_restart_device |
write + confirm | Restart an AP, switch, or gateway |
Output format
Office AP | uap | model=U6-Pro | ip=192.168.1.10 | connected | clients=12 | up=10d0h | mac=aa:bb:cc:dd:ee:01
Core Switch | usw | model=USW-Pro-48-PoE | ip=192.168.1.2 | connected | up=30d0h | UPGRADE_AVAILABLE | mac=aa:bb:cc:dd:ee:02
Gateway | ugw | model=UDM-Pro | ip=192.168.1.1 | connected | up=60d0h | mac=aa:bb:cc:dd:ee:03
MacBook Pro | ip=192.168.1.100 | ssid=HomeNet | rssi=-55 | exp=98% | up=12h0m | mac=11:22:33:44:55:01
NAS | ip=192.168.1.50 | wired | exp=100% | up=30d0h | mac=11:22:33:44:55:02
Unknown Device | ip=192.168.1.200 | ssid=IoT-Net | rssi=-72 | exp=65% | BLOCKED | mac=11:22:33:44:55:03
Multi-controller support
export UNIFI_CONTROLLERS="home,office"
export UNIFI_HOME_HOST="192.168.1.1"
export UNIFI_HOME_USERNAME="admin"
export UNIFI_HOME_PASSWORD="home-password"
export UNIFI_OFFICE_HOST="10.0.0.1"
export UNIFI_OFFICE_USERNAME="admin"
export UNIFI_OFFICE_PASSWORD="office-password"
Pass controller="office" to any tool. Omit for the first configured controller.
Security model
| Layer | Mechanism |
|---|---|
| Write gate | UNIFI_WRITE_ENABLED=true required for any mutation |
| Destructive confirm | unifi_block_client and unifi_restart_device require confirm=true |
| Credential scrubbing | Passwords, cookies, CSRF tokens, session IDs stripped from errors |
| Bearer auth | Optional UNIFI_MCP_API_TOKEN for HTTP transport |
| Session isolation | Each controller authenticates independently |
| SSL configurable | UNIFI_VERIFY_SSL=true for environments with proper certs |
| 2FA support | TOTP via UNIFI_TOTP_SECRET (base32 encoded) |
Sidereal integration
{
"mcpServers": {
"unifi": {
"type": "stdio",
"command": "uv",
"args": ["--directory", "~/src/ubiquiti-unifi-blade-mcp", "run", "ubiquiti-unifi-blade-mcp"],
"env": {
"UNIFI_HOST": "192.168.1.1",
"UNIFI_USERNAME": "admin",
"UNIFI_PASSWORD": "...",
"UNIFI_VERIFY_SSL": "false",
"UNIFI_WRITE_ENABLED": "false"
}
}
}
}
Webhook trigger patterns
- Device state changes —
unifi_devicesreturns state (connected/disconnected/upgrading), enabling alerts on AP/switch failures - New/unknown clients —
unifi_clientswith blocked status for intrusion detection workflows - Firmware availability —
unifi_devicesflagsUPGRADE_AVAILABLEfor maintenance scheduling - Firewall audit —
unifi_firewall+unifi_port_forwardsfor periodic security posture checks
Development
make install-dev # Install with dev + test dependencies
make test # Unit tests (mocked, no controller needed)
make check # Lint + format + type-check
make run # Start MCP server (stdio)
Architecture
src/ubiquiti_unifi_blade_mcp/
├── server.py — FastMCP 2.0 server, 18 @mcp.tool decorators
├── client.py — UniFiClient with multi-controller, credential scrubbing, session management
├── formatters.py — Token-efficient output (pipe-delimited, null omission, human units)
├── models.py — Controller config, write gate, constants
└── auth.py — Bearer token middleware for HTTP transport
Built with FastMCP 2.0 and aiounifi.
Acknowledgements
- Kane610/aiounifi — the async UniFi library that powers this and the Home Assistant integration
- sirkirby/unifi-mcp — comprehensive UniFi MCP for full network management (available as community listing)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ubiquiti_unifi_blade_mcp-0.2.0.tar.gz.
File metadata
- Download URL: ubiquiti_unifi_blade_mcp-0.2.0.tar.gz
- Upload date:
- Size: 123.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a96340e7b8d45210c3eeac80e2915feda10283e6452d8f77ac041c02f14f879
|
|
| MD5 |
eb6cb036c88cdd51ed54cffed224286f
|
|
| BLAKE2b-256 |
d9f11380b29dbfb88e7736f32cd0d4661a6094962b42718c982be12aede0e3a9
|
Provenance
The following attestation bundles were made for ubiquiti_unifi_blade_mcp-0.2.0.tar.gz:
Publisher:
publish.yml on Groupthink-dev/ubiquiti-unifi-blade-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ubiquiti_unifi_blade_mcp-0.2.0.tar.gz -
Subject digest:
4a96340e7b8d45210c3eeac80e2915feda10283e6452d8f77ac041c02f14f879 - Sigstore transparency entry: 1396166325
- Sigstore integration time:
-
Permalink:
Groupthink-dev/ubiquiti-unifi-blade-mcp@2a82921fd34d450f498de2581497927885163355 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Groupthink-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a82921fd34d450f498de2581497927885163355 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ubiquiti_unifi_blade_mcp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ubiquiti_unifi_blade_mcp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e1b3fde1b8b6ee5d03505cdc3991c4e038b548963a7cc429651b9f18b13e37d
|
|
| MD5 |
d7cd035966ef2438406e5f2b329ef367
|
|
| BLAKE2b-256 |
07c3d0f218b4d2a12acb816a763e38a941daab5691a754d93fc0d0be6188aa0a
|
Provenance
The following attestation bundles were made for ubiquiti_unifi_blade_mcp-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Groupthink-dev/ubiquiti-unifi-blade-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ubiquiti_unifi_blade_mcp-0.2.0-py3-none-any.whl -
Subject digest:
9e1b3fde1b8b6ee5d03505cdc3991c4e038b548963a7cc429651b9f18b13e37d - Sigstore transparency entry: 1396166333
- Sigstore integration time:
-
Permalink:
Groupthink-dev/ubiquiti-unifi-blade-mcp@2a82921fd34d450f498de2581497927885163355 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Groupthink-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a82921fd34d450f498de2581497927885163355 -
Trigger Event:
push
-
Statement type: