UniFi MCP
Allows interaction with a Ubiquiti UniFi gateway's Network application through its local Network API, providing curated and arbitrary documented reads plus preview/approve/apply workflows for writes and batches.
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., "@UniFi MCP show me the clients on my UniFi 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.
UniFi MCP
A local stdio MCP server for a UniFi gateway's Network application. It covers every operation in the documented local Network API (11.0.104): curated tools for common reads, one tool for any documented read, and a preview, approve, apply workflow for every documented write. It also covers a named set of reads and writes on the Network application's internal API. See docs/coverage.md for each operation's status and evidence.
The point of this server is its boundary: the agent never holds the API key, never sees credentials, and cannot change your network without a one-time code that only you can read.
Not affiliated with or endorsed by Ubiquiti. The internal API is unofficial and can change with any UniFi update.
Requirements
macOS, with FileVault on. The key broker is a LaunchDaemon; see docs/persistent-broker.md.
Agents that cannot
sudo. Approvals rely on it:sudo -n truefrom an agent's shell should ask for a password./usr/bin/python3from Apple's Command Line Tools or Xcode (xcode-select --install).Node.js 22+ and pnpm.
A UniFi gateway with one site, running UniFi Network 11 (tested on 11.0.104), reachable on your local network, and a local API key created in its Network application (Settings, Control Plane, Integrations).
Related MCP server: unifi-mcp
Boundary
The MCP never holds the API key. The broker runs as a LaunchDaemon under the hidden
_unifibrokeruser, from root-owned code, with the key in a file only that user can read. It answers over a Unix socket only the owner'sunifibrokergroup can reach. The MCP refuses a socket that the broker's user does not own, or whose directory other users can enter.The gateway is pinned. The broker talks to the address you set, and only if the gateway presents the TLS public key you confirmed at setup.
Documented fields only, never credentials.
broker/unifi_api.pyderives each read's allowlist from the Network API spec inspec/, minus the credential fields inEXCLUDED_FIELDS(Wi-Fi passphrases, preshared keys, hotspot voucher codes). Undocumented fields are dropped. A test fails if the spec gains a credential-like field nobody has classified. The six curated reads keep their own hand-written allowlists (LIST_OPERATIONS), as does every internal read.Every write needs your approval code.
broker/unifi_changes.pyvalidates a write against the spec, reads the target, and gives the owner the exact target, diff, impact, and rollback with a one-time code throughsudo "$UNIFI_BROKER" pending. The code never crosses the agents' socket. No operation has standing authorization.Credentials cannot be written. Previews refuse changes to passphrases and preshared keys. Updates resend the current values, which the broker reads and never returns.
See SECURITY.md for what this does and does not protect against.
Setup
git clone https://github.com/edmprojects/unifi-mcp.git
cd unifi-mcp
pnpm install
pnpm buildBroker
UNIFI_BROKER="/Library/Application Support/UniFiBroker/bin/unifi-broker"Review the checkout (
git status,git log,broker/), then install from it once:sudo /usr/bin/python3 -I broker/unifi_service.py install. It lists each file it will install and asks you to typeyes.Pin your gateway, on your own network:
sudo "$UNIFI_BROKER" set-gateway 192.168.1.1(use your gateway's address). It shows the gateway's TLS key pin and asks you to typeyes.Create a new UniFi API key for the broker and store it:
sudo "$UNIFI_BROKER" set-key.Restart your MCP client so it picks up your new
unifibrokergroup membership.To approve a write, run
sudo "$UNIFI_BROKER" pendingand give the agent the code it shows.To update, pull or commit in the checkout, then run
sudo "$UNIFI_BROKER" update --repo <checkout>. The installed copy shows its own diff of every changed file before asking.
sudo "$UNIFI_BROKER" uninstall removes the daemon, files, gateway pin, user, and group, and asks before deleting the key. The broker logs to /Library/Logs/UniFiBroker/broker.log.
MCP client
{
"mcpServers": {
"unifi": {
"command": "node",
"args": ["/path/to/unifi-mcp/dist/server.js"]
}
}
}Writes
unifi_preview_changetakes a documented writeoperation, itsparams(path IDs and query parameters; the site is supplied), andchanges. For an update,changesholds only the fields to change; the broker merges them into the current record and sends the full body PUT requires, so every field you did not name is resent as read. For a create or action,changesis the request body.The preview returns the target, current state, exact body (credentials redacted), diff, impact (
routine,disruptive, ordestructive, with a network's references where relevant), and rollback. The owner sees the same plan and a one-time approval code withsudo "$UNIFI_BROKER" pending.If you approve, give the agent the code.
unifi_apply_changesends only the change ID and the code; the body is the one the broker stored at preview.The broker refuses the write if there is no pending preview, the change ID or code differs, after three mismatched attempts, after 10 minutes, if the code was already used, or if the target changed since the preview. Every approval is single use, including one refused as stale.
After writing, the broker reads the target back. Updates report every changed field and any unexpected or missing change; deletes confirm the target is gone; creates report the new ID; actions report that the gateway accepted them.
The read-back is the confirmation. Some changes take effect on the network a little later: after a live DNS record create and delete, the gateway's DNS server answered the new record a few seconds after the API did, and kept answering the deleted one for about 30 seconds.
To roll back, preview the returned rollback and approve it the same way.
Batches
unifi_preview_batch plans up to 25 routine changes, such as client renames or DNS record edits, for one approval code. Each change is planned exactly as it would be alone, and sudo "$UNIFI_BROKER" pending lists every one with its diff. A batch refuses disruptive and destructive changes and more than one change per target; those need their own approval. unifi_apply_change with the batch's code applies the changes in order, re-checks each for staleness, reads each back, and stops at the first that does not apply: status: "partial" lists what applied, what failed, and what was not attempted. Deletes recreate with a new ID, and voucher and device deletes are not reversible.
Tools
Tool | Returns |
| Connected clients with type, IP and MAC address, connection time, and uplink device. Filters: |
| Adopted devices with model, state, addresses, firmware version, and update availability. |
| Networks with VLAN ID, enabled state, management type, and firewall zone. |
| SSIDs with enabled state, security type, and assigned network name. No passphrases. |
| Policies in gateway order with action, source and destination zone names, network selectors resolved to network names (with |
| Any documented read by operation name (for example |
| A named read on the Network application's internal, unofficial API: active clients with live stats, known clients, health (including the latest speed test), devices with radios, ports, and firmware, neighboring APs, port forwards, static routes, port profiles, and the system log ( |
| One device's details and latest statistics together. |
| Plans any documented write: target, current state, exact body, diff, impact, rollback. Changes nothing; the owner gets an approval code from |
Internal writes go through unifi_preview_change and unifi_apply_change too, with the same approval and read-back: renameClient, setClientNote, setClientFixedIp, renameDevice, setDeviceLed, and setDeviceRadio edit a record by params.id; locateDevice, blockClient, unblockClient, reconnectClient, forgetClient, and upgradeDevice act on a client or device by params.mac. Block, reconnect, radio, and firmware changes are disruptive and forget is destructive, so none of them can be batched. See docs/gaps.md.
| unifi_preview_batch | Plans up to 25 routine changes for one approval code; refuses disruptive or destructive changes and repeated targets. |
| unifi_apply_change | Applies a previewed change with your code, then reads the target back and reports what changed. |
Field names and operations come from Ubiquiti's UniFi Network API spec, 11.0.104 (spec/), as a gateway serves it from its API docs page; see NOTICE. Its Filtering section documents the filter syntax that unifi_read passes through, such as name.eq('Guests') and and(enabled.eq(true), name.like('IoT*')). Other Network versions are untested.
Checks
pnpm format:check
pnpm lint
pnpm typecheck
pnpm test # vitest (including the coverage matrix), then the broker's Python tests
pnpm coverage # regenerate docs/coverage.md after changing coverage/status.json
pnpm build
pnpm smoke # live reads through a running broker; prints counts onlySee CONTRIBUTING.md for the rules every change keeps.
License
MIT, except the UniFi Network API spec in spec/; see NOTICE.
Available Tools
11 toolsunifi_apply_changeApply Approved UniFi ChangeADestructive
Applies the previewed change or batch with the owner's one-time approval code, then reads each target back and reports what changed. A batch applies in order and stops at the first change that does not apply; status partial lists results and what was not attempted. Refuses unapproved, mismatched, expired, reused, and stale approvals. Use the returned rollback to undo.
Inputs: changeId (required), approvalCode (required). Returns: kind, status, target, verified, +1 more
unifi_inspect_deviceInspect UniFi DeviceARead-only
Gets one adopted device's details (ports, radios, uplink, firmware) and its latest statistics (uptime, CPU, memory, traffic) in one call.
Inputs: deviceId (required). Returns: device, latestStatistics
unifi_internal_readRead UniFi Internal APIARead-only
Runs one named read on the Network application's internal, unofficial API, for what the documented API lacks. activeClients: Connected clients with IP, network, AP or switch port, signal, uptime, and traffic. knownClients: Every client the gateway remembers, with name, note, fixed IP, and first and last seen. health: Status of WAN, LAN, WLAN, and VPN: counts, WAN IP, ISP, latency, and throughput. devices: Devices with firmware and available upgrades, radio settings and stats, and port tables. rogueAps: Neighboring access points seen in the last 24 hours. portForwards: Port forwarding rules: what is reachable from the internet. routes: Static routes. portProfiles: Switch port profiles: which networks a port carries, PoE, isolation, and speed. systemLog: Recent system log events, admin (AUDIT) and client and device (CLIENT_DEVICES) alike: what happened to which client, device, network, or admin, and when. params: hours (1-168, default 24), limit (1-100, default 50). Returns only allowlisted fields; credentials are never included.
Inputs: operation (required), params. Returns: read, count, items
unifi_list_clientsList UniFi ClientsBRead-only
Lists clients connected to the gateway with type, IP and MAC address, connection time, and uplink device. Filters by type or a name, IP, or MAC substring.
Inputs: type, limit, search. Returns: clients, totalCount, matchedCount
unifi_list_devicesList UniFi DevicesBRead-only
Lists adopted UniFi devices with model, state, IP and MAC address, firmware version, and whether an update is available.
Inputs: no named parameters. Returns: count, devices
unifi_list_firewall_policiesList UniFi Firewall PoliciesARead-only
Lists firewall policies in gateway order with action, source and destination zones and network selectors (resolved to names), IP version, and logging. Optionally only user-defined policies.
Inputs: userDefinedOnly. Returns: count, policies
unifi_list_networksList UniFi Networks and VLANsARead-only
Lists networks with their VLAN IDs, enabled state, management type, and firewall zone.
Inputs: no named parameters. Returns: count, networks
unifi_list_wifi_broadcastsList UniFi Wi-Fi BroadcastsARead-only
Lists Wi-Fi SSIDs with enabled state, security type, and assigned network. Never returns passphrases.
Inputs: no named parameters. Returns: count, broadcasts
unifi_preview_batchPreview a Batch of UniFi ChangesARead-only
Plans up to 25 routine changes, such as client renames, notes, or DNS record edits, for one approval code. Each change takes the same operation, params, and changes as unifi_preview_change and is planned exactly as it would be alone. Refuses disruptive or destructive changes and more than one change per target; preview those singly. Returns every plan and its rollback; the owner gets one code through sudo … pending.
Inputs: changes (required). Returns: batch, count, items, approval, +3 more
unifi_preview_changePreview UniFi Configuration ChangeARead-only
Plans one documented Network API write without applying it. For updates, pass only the fields to change in changes; the broker merges them into the current record. Returns the target, current state, exact body, diff, impact, and rollback. The broker gives the owner a one-time approval code through sudo … pending; ask the owner for it. Credential fields cannot be set. Internal (unofficial) writes use the same flow: renameClient (params.id; changes { name }); setClientNote (params.id; changes { note } (empty clears it)); setClientFixedIp (params.id; changes { use_fixedip, fixed_ip, network_id } (fixed_ip and network_id when reserving)); renameDevice (params.id; changes { name }); setDeviceLed (params.id; changes { led_override: "default" | "on" | "off" }); setDeviceRadio (params.id; changes { radio (e.g. "ng" 2.4 GHz, "na" 5 GHz), and any of channel ("auto" or a number), ht (width: 20, 40, 80, 160, 320), tx_power_mode (auto, high, medium, low, custom), tx_power (dBm) }); locateDevice (params.mac; changes { enabled }); blockClient (params.mac; changes none); unblockClient (params.mac; changes none); reconnectClient (params.mac; changes none); forgetClient (params.mac; changes none); upgradeDevice (params.mac; changes none). Their IDs come from unifi_internal_read knownClients or devices.
Inputs: operation (required), params, changes. Returns: body, diff, kind, impact, +8 more
unifi_readRead Any UniFi Network API ResourceARead-only
Runs one documented Network API read (operation names follow the API, such as getDnsPolicyPage, getAclRule, getAdoptedDeviceLatestStatistics, getWans) and returns its documented fields. Pass path IDs and offset, limit (most lists allow at most 200), or filter in params; the site is supplied automatically. Wi-Fi passphrases and voucher codes are never returned.
Inputs: operation (required), params. Returns: result, operationId
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
The set has a clear split between specific list tools, generic read escapes (unifi_read / unifi_internal_read), an inspection tool, and a preview/apply write flow, so most selections are unambiguous. There is mild overlap: unifi_list_devices vs unifi_inspect_device vs unifi_internal_read(devices), and unifi_list_clients vs unifi_internal_read(activeClients/knownClients) all touch similar data, and the two generic read tools differ mainly on documented-vs-internal API. Descriptions do explain the distinction, keeping it at a solid 4.
All 11 names share a unifi_ prefix and snake_case, and most follow verb_noun (list_clients, preview_change, inspect_device, apply_change). The exceptions are unifi_read and unifi_internal_read, which are bare verbs without an object, a minor deviation from the pattern. Predictable overall with only that small inconsistency.
11 tools is well within the sweet spot, and each earns its place: five resource-specific listers, two generic read escapes, one inspection shortcut, and a three-tool preview/preview_batch/apply write pipeline. Nothing feels redundant or bolted on.
Read coverage is broad (clients, devices, networks, SSIDs, firewall policies, plus generic documented and internal reads) and writes are covered generically through the preview/apply broker, including batch and rollback. Gaps are minor: approval management is punted to `sudo … pending` outside the toolset (no list/cancel pending approvals), and some resources like DNS records, routes, and port forwards are only reachable indirectly via the generic read tools.
Maintenance
Related MCP Connectors
Supervised API-write gateway for AI agents with policy, human approval and execution receipts.
Approval-gated Cloudflare ops for agents: DNS, email auth, Pages, cache, Turnstile, tokens.
Security gateway for AI agents: policy, approval, and audited execution, no secrets shared.
Zero-trust gateway for AI agents: score tool calls, verify agent cards, enforce policy, audit.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI agents and applications to interact with UniFi network infrastructure through the UniFi Network Controller API, supporting device, client, network, firewall, QoS, backup, multi-site, and topology management.Apache 2.0
- AlicenseAqualityBmaintenanceEnables an LLM client to diagnose a UniFi network through 39 tools covering devices, clients, WAN and VPN state, events, metrics, traffic reports, threat summaries, and security posture audits. Guarded write tools allow blocking clients, restarting devices, and managing networks, WiFi broadcasts, and hotspot vouchers, with previews and confirmation required for changes that could cut off protected networks or the gateway.56MIT
- AlicenseNot gradedqualityBmaintenanceEnables an agent to make a small, fixed set of guard-railed changes to UniFi Network, such as toggling mDNS forwarding, adding SSIDs, setting fixed IPs, and managing selected firewall policies, while keeping write actions separate and logged.MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to manage UniFi Network, Protect, and Access through official local APIs with read-only-by-default permissions, per-client tokens, and independent human approval for high-impact changes.Apache 2.0