py-unifi-mcp
An MCP server for read-only UniFi Network inspection and optional scoped device rename/locate operations.
List accessible UniFi sites and descriptions.
List device inventory with identity, model, version, address, and numeric state.
List currently connected clients and their connection identity.
Search clients by exact MAC/IP or name/hostname substring across current and retained clients.
Get client details by MAC with separate current and last-known connection info.
List networks with name, purpose, VLAN, and subnet.
Read subsystem health and device/client metrics.
Get one device's allow-listed telemetry: resources, uplink, firmware/update availability.
Preview or execute device rename with dry-run support.
Preview or execute LED locate start/stop with dry-run support.
Paginate results with offset/limit and site selection where applicable.
Support API-key or session-based authentication with explicit write safeguards.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@py-unifi-mcp list the devices on my network"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
py-unifi-mcp
A small Python MCP server for local UniFi Network inspection. Built with the same FastMCP, httpx, and Pydantic structure as py-ynab-mcp.
The initial feature uses a local API key or UniFi OS session authentication and exposes read-only inventory. See the charter and steel thread spec.
For expansion choices, see the preserved feature landscape, official API catalog, and sanitized live capability evidence linked there. Health/device detail and rename/locate are the selected expansion; other groups remain deferred.
Requires Python 3.12+ and a UniFi OS console with local Network access. This initial version uses fixed legacy Network endpoints. Standalone Network controllers, cloud accounts and MFA login are not supported. API-key access to these legacy endpoints depends on the controller version and key permissions; this is not an Integration API implementation.
Install and run
From this repository, using an external uv environment:
uv venv "$WORKSPACE_ROOT/scratch/.venvs/py-unifi-mcp" --python 3.12
uv pip install --python "$WORKSPACE_ROOT/scratch/.venvs/py-unifi-mcp/bin/python" -e . --group devSet UNIFI_URL to an HTTPS origin such as https://controller.example (no
trailing slash, path, query, or credentials). Supply either UNIFI_API_KEY or both
UNIFI_USERNAME and UNIFI_PASSWORD through your secret runner's environment
injection. Mixed credentials are rejected. The credential must have access to
the desired sites; prefer read-only privileges unless scoped writes are required.
Do not put passwords in source files or command arguments. Optional UNIFI_SITE
defaults to default. Optional UNIFI_CA_FILE is a PEM CA bundle for a private CA;
otherwise the normal system trust configuration is used. TLS verification is
mandatory. Redirects and environment HTTP proxies are disabled.
Configure your MCP client to execute the absolute path to
$WORKSPACE_ROOT/scratch/.venvs/py-unifi-mcp/bin/py-unifi-mcp with these environment
variables. The server uses stdio. API-key mode sends X-API-Key on requests, never
logs in, and never falls back to username/password. Session mode keeps cookies
only in memory, logs in lazily on the first inventory request, and can
reauthenticate once when a read encounters an expired session. Transport failures
and login are not retried.
Related MCP server: unifi-mcp
Tools
Tool | Inventory |
| Accessible sites and descriptions |
| Device identity, model, version, address and numeric state |
| Currently connected clients and connection identity |
| Exact MAC/IP or name/hostname substring across current and retained clients |
| Exact MAC with separate current and last-known connection details |
| Network name, purpose, VLAN and subnet |
| Subsystem health and available device/client metrics |
| Exact |
| Preview or execute an exact-device rename with |
| Preview or execute LED locate start/stop with |
List tools and health accept offset (default 0) and limit (default 50, maximum 100).
Device, client and network tools also accept a validated optional site identifier.
Results contain items, total, offset, limit, returned, truncated,
has_more, and next_offset. truncated means this page omits some items in the
snapshot, including earlier pages. has_more indicates a following page.
Pagination bounds MCP output; the controller still returns its full inventory
snapshot, and ordering may change between requests.
Client search requires a nonblank query; valid MAC/IP queries match that exact
address, otherwise matching is a case-insensitive name/hostname substring. All
matches are returned, sorted by normalized MAC and paginated. Set
include_offline=False to skip retained history. Detail lookup requires mac
(colon, hyphen or compact hex form). Both use fixed GET stat/sta; retained
history uses stat/alluser, and device names use stat/device. A failed required
source fails the tool rather than presenting an incomplete search as complete.
Client current fields come only from the connected snapshot; last_known
contains explicit historical metadata. not_connected means absent from the
successful current controller snapshot, not proof of sleep, offline state or
unreachability. Reads are sequential snapshots, not atomic. Retained history is
controller-limited, not a complete lifetime inventory. Last-known IPs are not
DHCP reservations or safe automatic SSH targets. Duplicate client MACs fail
clearly; ambiguous device names are not guessed. Missing telemetry stays null.
DHCP, firewall/port configuration, Wake-on-LAN, Windows and Ollama control remain
outside this feature. See client lookup spec.
Only explicitly modeled fields are returned. WLAN passwords, VPN material and arbitrary nested settings are discarded. Network addresses and client names are still private network data visible to the MCP consumer. Treat device names and other controller text as untrusted data. Unknown numeric device state codes are preserved without guessing their meanings. Missing telemetry remains null.
Rename and locate default to dry_run=True: resolve the exact adopted device ID
in the selected site and show the target and proposed change without mutating it.
Execution requires explicit dry_run=False, API-key authentication, and user intent
for that target/change. Session authentication supports reads/previews only.
Names must be nonblank, bounded, and free of control characters. No arbitrary
device settings, restart, or network changes are exposed.
Writes are never retried or replayed. Rename distinguishes controller acknowledgement
from name read-back verification; a failed read-back is unverified, not a reason to
repeat the mutation. Locate acknowledgement cannot verify the physical LED. Set
enabled=False to stop locating; a start is not automatically stopped. Transport
or invalid-response failures have an unknown outcome: inspect before acting again.
These legacy writes are based on community source contracts. Live rename read-back
and locate start/stop acknowledgement were tested on the development controller;
support still depends on controller version, key permissions and device model.
See the completed device operations spec.
Malformed responses, denied access, legacy API errors, and connection failures produce sanitized errors. Schema failures do not silently become empty inventory.
Development
"$WORKSPACE_ROOT/scratch/.venvs/py-unifi-mcp/bin/ruff" check .
"$WORKSPACE_ROOT/scratch/.venvs/py-unifi-mcp/bin/ruff" format --check .
"$WORKSPACE_ROOT/scratch/.venvs/py-unifi-mcp/bin/mypy" src/
"$WORKSPACE_ROOT/scratch/.venvs/py-unifi-mcp/bin/pytest"
uv build --wheelTests use synthetic HTTP transports, including an MCP stdio subprocess test; they do not contact a controller. Live verification uses an external local runner with in-memory secret injection; controller details and verification evidence remain outside this repository.
Available Tools
8 toolsunifi_get_deviceARead-onlyIdempotent
Get allow-listed telemetry for one exact device ID in the selected site.
Inputs: device_id (required), site. Returns: ip, _id, mac, name, +11 more
unifi_get_healthBRead-onlyIdempotent
Read subsystem health; missing metrics are unknown, not healthy.
Inputs: site, limit, offset. Returns: items, limit, total, offset, +4 more
unifi_list_clientsARead-onlyIdempotent
List currently connected clients; site defaults to UNIFI_SITE.
Offset/limit bound tool output, not the controller fetch.
Inputs: site, limit, offset. Returns: items, limit, total, offset, +4 more
unifi_list_devicesARead-onlyIdempotent
List device inventory and raw state codes; site defaults to UNIFI_SITE.
Offset/limit bound tool output, not the controller fetch.
Inputs: site, limit, offset. Returns: items, limit, total, offset, +4 more
unifi_list_networksARead-onlyIdempotent
List network summaries without keys or VPN configuration; defaults to UNIFI_SITE.
Offset/limit bound tool output, not the controller fetch.
Inputs: site, limit, offset. Returns: items, limit, total, offset, +4 more
unifi_list_sitesARead-onlyIdempotent
List accessible sites. Offset/limit bound tool output, not the controller fetch.
Inputs: limit, offset. Returns: items, limit, total, offset, +4 more
unifi_locate_deviceADestructive
Preview LED locate start/stop. Execution requires user intent and API key.
Start is not auto-stopped; use enabled=False to stop. LED state is not verified.
Inputs: enabled (required), device_id (required), site, dry_run. Returns: mac, name, site, dry_run, +6 more
unifi_rename_deviceADestructive
Preview a rename. Execute only with user intent and dry_run=False; requires API key.
Inputs: name (required), device_id (required), site, dry_run. Returns: mac, name, site, dry_run, +6 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct resource or action: networks, sites, devices, clients, health, device telemetry, device rename, and device locate. There is no meaningful overlap or confusion between tool purposes.
All tools use the unifi_ prefix followed by a clear verb_noun pattern such as list_networks, get_health, rename_device, and locate_device. The naming is uniform and predictable across the entire set.
Eight tools is well-scoped for a UniFi controller MCP server covering inventory lookup, status checks, and common device actions. Each tool serves a clear purpose without unnecessary bloat.
The tool set covers core UniFi operations well: listing sites, networks, devices, clients, checking health, and retrieving device details. Minor gaps exist, such as no network configuration or additional device management actions, but the main workflows are represented.
Maintenance
Related MCP Connectors
Tailscale device, route, DNS, key, user, and ACL management over MCP and CLI.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
Remote MCP access to user-authorized Linux, Windows and Intel Mac devices for AI assistants.
Private networking for AI agents: networks, nodes, commands, files, services via hosted MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables MCP-capable clients to interact with UniFi Site Manager and UniFi Dream Machine telemetry, providing tools for client details, ISP metrics, and more.4MIT
- AlicenseNot gradedqualityCmaintenanceA safety-first MCP server for managing UniFi networks, exposing 17 tools for telemetry, diagnostics, and guarded mutations with dry-run previews and confirm requirements.16MIT
- AlicenseAqualityDmaintenanceMCP server providing typed, safety-gated access to UniFi Network consoles via the official API, enabling management of devices, clients, networks, WiFi, firewall policies, and more.1629 npm2MIT
- AlicenseNot gradedqualityBmaintenanceProvides a curated, scoped, audited MCP surface for managing UniFi Network controllers, offering typed read primitives, stats queries, scoped operational and backup actions, and multi-controller inventories. Change control uses a two-person approval lifecycle with pre-image capture, local validation, and best-effort rollback, since the controller has no candidate configuration or commit step.1MIT