mcp-unifi
Provides tools for managing a fleet of UniFi consoles through the UniFi Site Manager Cloud Connector, including listing consoles, verifying console connectivity, reading normalized configuration, comparing configuration sections across consoles, and planning configuration changes.
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., "@mcp-unifiWhich of my sites disagree with the standard firewall policy set?"
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.
mcp-unifi
An MCP server for UniFi Site Manager, running on Cloudflare Workers. Manage a fleet of UniFi consoles from an AI assistant, across every site at once.
Connect UniFi to Claude, Claude Code, Cursor or any MCP client. No local install, no Node.js, no Python, no VPN. It runs as a remote Worker in your own Cloudflare account, reaching each console through UniFi's Cloud Connector proxy, so it works from mobile as well as desktop and keeps working when your laptop is closed.
"Is anything wrong across my sites?" "Which devices have firmware updates pending?" "Does the new site match how we build sites?" "Which clients are having a bad time on WiFi at the pub?"
Built for MSPs and anyone running more than one console. The UniFi interface shows you one site at a time; this shows you all of them in one answer.
Contents
Related MCP server: UniFi MCP Server
Before you start
You need:
A UniFi account with consoles adopted into it, visible at unifi.ui.com.
Console firmware 5.0.3 or later. Below that there is no Cloud Connector proxy and the console cannot be reached from the cloud at all.
A Site Manager API key. At unifi.ui.com, open your account settings and create an API key.
A Cloudflare account. The free plan is fine.
The key must come from unifi.ui.com, not from an individual console's settings. A
console-local key only works against that console's local API and will be rejected by
api.ui.com. This is the most common setup mistake.
You do not need Node.js or any local tooling. Everything below is done in a browser.
Setup
1. Deploy to Cloudflare
Fork this repository, then in the Cloudflare dashboard go to Compute (Workers) → Create → Import a repository. Connect GitHub, choose your fork, and set:
Setting | Value |
Branch |
|
Build command | leave empty |
Deploy command |
|
Check https://mcp-unifi.<your-subdomain>.workers.dev/health returns ok.
2. Generate an access token
PowerShell:
-join ((1..32) | ForEach-Object { '{0:x2}' -f (Get-Random -Max 256) })macOS or Linux:
openssl rand -hex 323. Add your secrets
Cloudflare dashboard → your Worker → Settings → Variables and Secrets. Add each as type Secret, not Text:
Name | Value |
| Your Site Manager API key |
| The token from step 2 |
| Optional. Comma separated console IDs to restrict this deployment |
Check the names carefully. They must match exactly. A secret named
UNIFI_API_TOKEN will not bind, and the server will tell you so rather than failing in
a confusing way.
Secret, not Text, matters. Plain-text variables declared in wrangler.toml replace
all dashboard variables on every deploy. Secrets survive.
4. Use a custom domain
Settings → Domains & Routes → Add → Custom domain.
Cloudflare's Cache API silently does nothing on workers.dev subdomains, so without a
custom domain no response caching happens at all and every call hits UniFi.
Connecting your AI assistant
Claude (web, desktop and mobile)
Settings → Connectors → Add custom connector.
Field | Value |
URL |
|
Authentication | None |
Then Add header: name x-api-key, value your MCP_TOKEN, Required ticked.
Authentication must be None. This server uses an API key, not OAuth. The
authorization header is greyed out because Claude reserves it for its own OAuth
token, hence x-api-key.
Claude Code
claude mcp add --transport http unifi https://your-worker-domain/mcp \
--header "x-api-key: YOUR_MCP_TOKEN"Clients that only speak stdio
{
"mcpServers": {
"unifi": {
"command": "npx",
"args": [
"-y", "mcp-remote",
"https://your-worker-domain/mcp",
"--header", "x-api-key:YOUR_MCP_TOKEN"
]
}
}
}Check it worked
Ask: "list my UniFi consoles", then "how is the fleet looking?"
Adding tools requires a reconnect. Tool lists are cached by the client at connection time, so after deploying a version with new tools, toggle the connector off and on before they appear.
Tools
Fleet state
Tool | What it does |
| Every console the key can reach, with model, firmware and connector capability |
| Health across every site in one call, with a |
| One site in detail: WAN availability and latency, ISP, clients, gateway CPU and memory |
| Devices on one console, with |
| Clients with signal, retry rate and experience score, filterable to problems only |
| Every device across every site as an asset register, grouped by model |
| Pending updates fleet-wide, plus models running mixed versions across sites |
Configuration
Tool | What it does |
| Whether a console is reachable and which config sections read cleanly |
| Networks, WiFi, firewall or DNS from one console, normalised for comparison |
| Compare a section across sites against a baseline, reporting exactly what differs |
Escape hatch
raw_request sends an arbitrary request through the Cloud Connector proxy for anything
the curated tools do not cover. Read-only unless ENABLE_WRITES is set. Paths are
validated to prevent escaping the console's /proxy prefix.
Writes
apply_config exists but deliberately refuses to write. Without name-to-UUID
reference resolution, a firewall policy ordering pass and per-console rollback, applying
config to a live client network is not safe. The dry run shows the plan. Enabling
ENABLE_WRITES allows non-GET raw_request calls, not config application.
Configuration reference
Name | Type | Purpose |
| Secret | Your Site Manager key. Omit to run in bring-your-own-key mode |
| Secret | Required when |
| Secret | Optional console ID allowlist |
| Variable |
|
| Variable | Upper bound on consoles per fan-out call. Default 6 |
| Variable | Per-call timeout. Default 15000 |
Rotating your token without downtime
Set MCP_TOKEN to old-token, new-token, update each client, then set it back to just
new-token.
Accepted credential headers
x-api-key is recommended, but api-key, apikey, x-apikey, x-api-token,
api-token, x-auth-token and Authorization: Bearer all work.
How it works
Config comes from the Network Integration API, the officially supported one. State comes from the classic controller API, which is still where health, devices and clients live. Both are reached through the Site Manager Cloud Connector proxy, so no VPN or open port is needed.
Everything reduces hard. The raw device payload for a four-device site, or the client list for a small office, is large enough to exhaust an LLM context window on its own. No tool passes raw UniFi payloads through; each has a size guard that fails with a clear message rather than dumping.
Identity is by name, never by ID. Every UUID in these APIs is minted by one console, so a config captured from one site cannot be matched to another by ID. Networks, zones and traffic lists are stored by name and resolved per console.
Subrequest budgeting. Workers caps subrequests per request (50 on the free plan) and
fan-out calls consume several per console. Batch sizes are computed from the cost of the
section being read, and anything not processed comes back in remaining to feed into
the next call rather than failing the whole request.
Failures are partial, not fatal. One unreachable console never loses the answer for
the rest. Consoles the cloud already reports as disconnected are listed separately under
offline, with the time they went down, rather than reported as errors.
Troubleshooting
401 from UniFi. The key is wrong, expired, or was generated on a console rather than at unifi.ui.com. Test it directly:
curl.exe -s -H "X-API-KEY: YOUR_KEY" https://api.ui.com/v1/hosts"UNIFI_API_KEY is not visible to the runtime." The secret name does not match. The error lists every binding the Worker can see, so compare that list against the expected name.
A console returns 404 on everything. Either it is offline, or the path does not
exist on that version. list_consoles shows connection state. Not every classic API
endpoint exists in every UniFi Network release: stat/alarm and stat/event are gone
in 10.x, while stat/health, stat/device and stat/sta remain.
firewall fails but networks works. That console has no zone-based firewalling
configured. Networks still reads, but zoneRef will be null and the result carries a
warning saying so.
A WiFi diff shows everything as added and removed. Identity is by name, so
site-specific SSIDs like Site_Priv will not match across consoles. That is correct
behaviour; diffs are most useful between sites built from a shared template.
New tools do not appear. The client caches the tool list. Reconnect the connector.
Development
npm install
npm run typecheck
npm run dev # needs a .dev.vars file, gitignored
npm run tail # live logs from the deployed workerLicence
Free and MIT licensed. Provided as-is, with no warranty of any kind and no liability accepted, as set out in LICENSE.
You deploy and run this in your own Cloudflare account, so your API key, your usage and
anything the tools do to your UniFi estate remain your responsibility. This reaches
production networks belonging to real clients: read the section on writes before
enabling ENABLE_WRITES.
Maintained in spare time, so issues and pull requests are very welcome but may not get a fast response.
This server cannot be deployed
Maintenance
Related MCP Connectors
Deploy and manage your apps, databases, storage, and scheduled jobs from your AI agent
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
Manage hosts, redirects, SSL, and traffic analytics from Claude and other AI assistants.
- mcpOAuthcom.vibgrate
Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.
Related MCP Servers
- AlicenseDqualityDmaintenanceEnables comprehensive management of UniFi network infrastructure through the UniFi Cloud API, including device control, client management, camera settings, and access door control through natural language.3918 npmApache 2.0
- AlicenseBqualityDmaintenanceEnables AI assistants to manage and monitor UniFi Network Controllers through natural language. Provides 25 read-only tools for discovering devices and clients, viewing security configurations, analyzing network statistics, and exporting configuration data.41MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to manage UniFi network infrastructure through 50+ tools covering devices, clients, networks, WiFi, firewall rules, and guest access using the official UniFi Network API.5243 npm5MIT
- AlicenseCqualityAmaintenanceEnables AI agents to manage UniFi network infrastructure via the Model Context Protocol, supporting device management, network configuration, security, and QoS through local or cloud APIs.4318 npm218 PyPI258Apache 2.0