UniFi Network
v0.13.0Diagnostics and owner-approved changes for one UniFi Network console, over its local API.
Ask Claude about your UniFi network and get a finished answer: who is on the guest network, which switch port the printer is on, whether the internet dropped last night, which access point is on a noisy channel. This MCP server runs on your network next to one UniFi Network console, and it only reads unless you turn writes on. It is built with .NET 10 and the official ModelContextProtocol SDK, from the UniFi Network API's OpenAPI document (v11.0.97, in openapi/).
Summary extracted from the README.
UniFi Network MCP
Ask Claude about your UniFi network and get a finished answer: who is on the guest network, which switch port the printer is on, whether the internet dropped last night, which access point is on a noisy channel. This MCP server runs on your network next to one UniFi Network console, and it only reads unless you turn writes on.
- Questions answered on the server. Ten tools built around everyday questions do the reads and write up the result. A step that fails is named in the answer, and an answer cut short says so and how to narrow the question (What you can ask).
- Read-only by default. With writes on, each change is shown to you whole on a form you accept or decline, and the model cannot approve it for you. A client that cannot show the form is refused writes unless you allow the confirm fallback.
- Credentials stay out of the chat. Wi-Fi passphrases, per-network keys and hotspot voucher codes the console sends
back become
[redacted]before Claude sees them, unless you choose to show voucher codes. The API key is never logged or returned (Safety). - Pinned to your console. TLS to the console is pinned to its certificate or public key, or checked against a trusted CA, and there is no way to turn the check off (Safety).
- Claude on the web and phone, with no open ports. Add it as a custom connector in claude.ai, Claude Desktop or the phone apps. A Cloudflare tunnel or Tailscale Funnel that dials out carries the traffic, and you sign in with a one-time code from the server's setup page or log, or a Google account you allow (Setup).
- Gentle on the console. Reads from its internal API go one at a time, at most 30 a minute after a burst of 20, and an identical read within 10 seconds comes from cache. One composite answer makes at most 100 requests and reads at most 32 MB (FAQ).
- A short tool list. All 73 operations of the official API are generated from its OpenAPI document. The 41 reads share one tool, so Claude sees 15 tools, or 47 with writes on (Tools).
It is built with .NET 10 and the official ModelContextProtocol SDK, from the UniFi Network API's OpenAPI document
(v11.0.97, in openapi/). Claude Code can also connect directly, on the same machine, over your tailnet or across your
LAN, and clients that send a fixed header can use an access token. Each release image must start healthy as a non-root
user on a read-only filesystem, on amd64 and arm64, before any tag points at it.
The setup page shows the sign-in code the moment Claude asks for one, and tests every setting against the real thing: here seven checks pass, and the tunnel check says what is wrong and which step fixes it.
Contents: What you can ask, Tools, Safety, Setup, Settings reference, FAQ, Develop
What you can ask
| Ask Claude | It uses |
|---|---|
| Who is on the guest network right now? | who_is_on_network_faq |
| Which switch port is the office printer plugged into? | client_path_faq |
| Is the NAS getting the fixed IP I reserved for it? | dhcp_reservation_faq |
| Did the internet drop out this week, and how bad was the packet loss? | internet_health_faq |
| Are any access points on a busy or noisy channel? | wifi_health_faq |
| Do any switch ports show errors, drops or a flapping link? | device_diagnostics_faq |
| Why does my laptop keep losing Wi-Fi? | client_diagnostics_faq, system_log |
| Who signed in to the console in the last day? | system_log |
| Which devices are offline or have firmware updates waiting? | network_health_faq |
| What ports are forwarded to the internet? | list_port_forwards |
With writes on: add a DNS record so nas.home points at 192.168.1.20 |
create_dns_policy, after you approve it |
Anything else the API offers, Claude finds with search_operations and runs with call_read_operation.
Tools
- All 73 API operations. The 41 reads run through one tool,
call_read_operation(itsoperationlists them), which keeps the tool list short: Claude picks tools less well past 30 to 50. The 32 writes are a destructive tool each, listed only when writes are on.search_operationsfinds an operation anddescribe_operationshows its schema. Read-only, the server lists 15 tools; with writes on, 47. - 4 task-oriented composites:
who_is_on_network_faq,client_path_faq,dhcp_reservation_faq,network_health_faq. - 6 read-only diagnostics the official API does not cover, from the console's internal API (the one its own UI uses):
system_log,internet_health_faq,wifi_health_faq,client_diagnostics_faq,device_diagnostics_faq,list_port_forwards. They also giveclient_path_faqthe switch port anddhcp_reservation_faqthe fixed IP. device_diagnostics_faqalso carries an interactive view for hosts that render MCP Apps, such as Claude's apps: a tile per device, and for one device a switch faceplate with each port's link, errors and what is connected to it. Other hosts, Claude Code among them, get the same answer as text. The view makes no writes and loads nothing from the network.- 4 guide tools:
getting_started,unifi_status,search_operations,describe_operation.
Safety
-
Read-only by default. Write tools exist only when
UNIFI_ALLOW_WRITESis exactlytrue; each is marked destructive and asks you to approve it. A client that can show a confirmation form (MCP 2026-07-28 elicitation, as Claude Code does) shows you the whole change with Accept or Decline, and the model cannot approve it for you. A change too big to show whole is refused. Any other client is refused every write, unless you turn on the confirm fallback (see Writes).UNIFI_WRITE_TOOLScan narrow the write tools to the few you name. -
TLS to the console is pinned to a SHA-256 fingerprint of its certificate or public key, or, with
UNIFI_CERT_TRUST=ca, checked against a trusted CA. There is no default pin and no way to turn verification off. -
The API key comes from the
UNIFI_API_KEYenvironment variable, falling back to/config/unifi-api-keyonly when the variable is unset or empty. It is never logged or returned, and is scrubbed from console errors. -
Credentials the console sends back (Wi-Fi passphrases, per-network keys, hotspot voucher codes) are replaced with
[redacted]in every answer and error before it reaches Claude, writes on or off. Names, ids and other settings stay. An answer that is not JSON can't be checked, so it isn't shown. Voucher codes are what the voucher tools are for: if you hand them out through Claude, setUNIFI_REVEAL_SECRETS=voucher-codes. Nothing shows a Wi-Fi passphrase or key; read those in the UniFi app. -
No published ports unless you add the LAN listener. The server listens on two Unix sockets, each in a folder of its own:
run-public/public.sock, the Claude connector, reached through a Cloudflare tunnel or Tailscale Funnel. It takes OAuth bearer tokens, issued only after the owner signs in (see guide 2 and guide 3), and, if you set one, the fixedMCP_ACCESS_TOKEN.run/mcp.sock, optional tailnet access: reached throughtailscale serve, which stampsTailscale-User-Login; the server checks it against an allow-list. The public socket ignores that header. The tunnel container mounts onlyrun-public, so it can't reach this socket and send a login of its choosing.
-
At startup the server removes only a stale socket at either path. A file, a link or a socket someone still listens on is left alone and the server stops with a message naming the path; so does a second server on the same folders.
-
The LAN listener (guide 4) is off unless
MCP_LAN_LISTENis set. It serves only/mcpand/healthz, accepts onlyMCP_LAN_ACCESS_TOKEN(never the public token, the sign-in or the Tailscale header), and the server won't start with it on and no token. It is plain HTTP; the startup log says so. -
The setup page (on unless you use Google sign-in) has a listener of its own,
127.0.0.1:5198on the host, which the tunnel never reaches. It opens only from the link in the server's startup log, whose key changes on every start, so it shows the sign-in code to nobody who couldn't already read it in the log. -
The internal API is reached only through a fixed set of named reads (the server has no way to send it anything else, writes on or off), and is throttled: one request at a time, identical reads within 10 s served from cache, and at most 30 calls a minute after a burst of 20. That API was not built for outside tools, and frequent polling of it can make a console drop packets. Its answers carry secrets (device keys, a maps API key), so these tools return chosen fields only, never the raw JSON.
Until the key and pin exist the server runs and reports "not configured" without contacting the console. Until the connector is fully configured the public socket answers 503; the startup log line names what is missing (names only).
Privacy and data
- What reaches the model provider. Every tool answer goes into the conversation, so it reaches whoever runs the model you use (Anthropic, for Claude) under that provider's terms. Answers name your clients and devices and carry their MAC and IP addresses, host names, networks and recent events: treat a conversation about your network as holding that data.
- What is redacted. Credentials the console sends back are replaced with
[redacted]before any answer or error leaves the server: Wi-Fi passphrases, per-network keys and hotspot voucher codes (unless you setUNIFI_REVEAL_SECRETS=voucher-codes). The diagnostics tools return chosen fields only, never the internal API's raw JSON, which carries device keys and a maps API key. The API key itself is never returned or logged. Names, addresses and settings are not redacted: they are what the answers are about. - What stays on your machine. The audit log (
UnifiMcp.Audit, one line per tool call, never its arguments) goes to the server's own log, which is the container's (docker compose logs unifi-mcp). The connector's OAuth state, its registered clients, consents, refresh tokens and signing keys, is in./data(oauth.dbandkeys, the keys wrapped withUNIFI_MCP_DATA_KEY). Nothing else is written to disk: console answers pass through memory only. - Nothing goes to UI.com. The server talks only to your console, over your network, with a local API key. It needs no UI.com account and sends nothing to Ubiquiti's cloud; it sends no telemetry anywhere.
- The console key is console-wide. A UniFi Network API key opens every site on the console and has no read-only
mode.
UNIFI_ALLOW_WRITES(off by default),UNIFI_WRITE_TOOLSand the approval form limit what this server does with it, not what the key allows: keep it as you would an admin password, and delete it in UniFi Network to revoke it.
Setup
There are four ways to run it. Pick the one that matches where you use Claude; each guide stands on its own.
| Guide 1: Quick local | Guide 2: claude.ai | Guide 3: Full | Guide 4: LAN | |
|---|---|---|---|---|
| Use it from | Claude Code on the same machine | claude.ai, Claude Desktop and the phone apps | Everything in guide 2, plus Claude Code anywhere on your tailnet | Claude Code on other machines on your network |
| You need | The .NET 10 SDK | Docker Compose, and a domain on Cloudflare (free plan is fine) or a Tailscale account | Guide 2, plus a Google Cloud project and, optionally, Tailscale | Docker Compose |
| You sign in with | A name you allow, sent as a header | A one-time code from the server's log | A Google account on an allow-list | A token you generate, sent as a header |
| Reachable from the internet | No | Only through the tunnel or Funnel | Only through the tunnel or Funnel | Not if your router or firewall keeps port 7420 to the LAN: it is published on every host address |
Placeholders used throughout: 192.168.1.1 is your console, 192.168.1.20 is the machine that runs the server,
unifi.example.com is the hostname you pick, and you@example.com is your address.
The setup page. Once the server runs, its startup log prints a link: Setup page: http://localhost:5198/setup?key=….
Open it in a browser on the same machine. It tests each setting against the real thing (the console, its certificate,
the API key, the tunnel, the sign-in) and says what to fix, shows the sign-in code as soon as Claude asks for one, and
carries these guides with your own values filled in. It is on in guides 1, 2 and 4; turn it off with MCP_SETUP_PAGE=off.
On a server without a browser, forward the port first: ssh -L 5198:localhost:5198 you@server.
Before you start: two values from your console
Every guide needs these.
The API key. In UniFi Network, open Settings, Control Plane, Integrations and create an API key (the menu may move between versions).
The console's key fingerprint. The console uses a self-signed certificate, so the server pins a SHA-256 fingerprint instead of trusting a CA. Pin the certificate's public key: if the console re-issues its certificate with the same key, the pin keeps working. You don't need to work it out beforehand:
- Start the server with
UNIFI_CERT_SHA256empty. Without a pin it never sends the API key to the console. - Open the setup page (above). Its certificate check shows the public key fingerprint the console presents to the server: copy it.
- Confirm it on the console itself, so you are not pinning something in the middle. SSH in and run
openssl x509 -in /data/unifi-core/config/unifi-core.crt -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256. The two must match. - Set
UNIFI_CERT_SHA256to it and restart the server.
openssl s_client -connect 192.168.1.1:443 </dev/null 2>/dev/null \
| openssl x509 -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256
Then confirm it on the console as in step 3, and set it as in step 4.
UNIFI_CERT_SHA256 also accepts the fingerprint of the whole certificate (openssl x509 -noout -fingerprint -sha256;
colons are fine), and several fingerprints separated by commas.
When the certificate changes. A console can generate a new certificate, and sometimes a new key, after a firmware
update or a restart. Tool calls then fail with "does not match the pin" and name both fingerprints the console presented.
Confirm one on the console and add it to UNIFI_CERT_SHA256 (the old and new can sit side by side, comma separated),
then restart the server. If the pin comes from the file /config/cert-sha256 instead (with the variable unset), edit
the file: it is read on every new connection, so no restart is needed.
Or: a certificate from a trusted CA. If you give the console a certificate from a public CA such as Let's Encrypt,
set UNIFI_CERT_TRUST=ca and leave UNIFI_CERT_SHA256 empty. The server then checks the certificate the usual way
(a valid chain, issued for the host name), so renewals need nothing from you. UNIFI_URL must use that host name
(https://unifi.example.com), and it must resolve to the console from where the server runs. UniFi OS 4.1 and later
can take your own certificate in its settings, under Control Plane, Console, Certificates (the menu may move between
versions). Tools such as unifi-os-cert-deployer automate issuing
and renewing one.
Guide 1: Quick local setup
For Claude Code on the machine that runs the server. No domain, no tunnel, no sign-in page, and nothing listens beyond
127.0.0.1. Needs the .NET 10 SDK.
-
Get the code and start the server, with the two values from Before you start:
git clone https://github.com/Graf3x/unifi-mcp && cd unifi-mcp export UNIFI_URL=https://192.168.1.1 read -rs -p 'API key: ' UNIFI_API_KEY && export UNIFI_API_KEY && echo # not shown, not kept in your history export UNIFI_CERT_SHA256='<the fingerprint>' export MCP_LISTEN=http://127.0.0.1:5199 MCP_ALLOW_LOOPBACK_TCP=true MCP_ALLOWED_LOGINS=me dotnet run --project src/UnifiMcpgit clone https://github.com/Graf3x/unifi-mcp; cd unifi-mcp $env:UNIFI_URL = 'https://192.168.1.1' $env:UNIFI_API_KEY = [Net.NetworkCredential]::new('', (Read-Host 'API key' -AsSecureString)).Password $env:UNIFI_CERT_SHA256 = '<the fingerprint>' $env:MCP_LISTEN = 'http://127.0.0.1:5199'; $env:MCP_ALLOW_LOOPBACK_TCP = 'true'; $env:MCP_ALLOWED_LOGINS = 'me' dotnet run --project src/UnifiMcp -
In a second terminal, add it to Claude Code. The header carries the name you allowed in
MCP_ALLOWED_LOGINS:claude mcp add --transport http unifi http://127.0.0.1:5199/mcp --header "Tailscale-User-Login: me" -
Ask Claude to call
getting_started. It should say the server is configured. If not, open theSetup page:link the server printed when it started; its checks say what is wrong.
The header's name comes from the tailnet setup, where Tailscale fills it in; here you send it yourself. Anything on this
machine that can reach 127.0.0.1:5199 and sends that name gets in, so use this mode on a machine only you use. The server
starts read-only; see Writes.
Guide 2: claude.ai with a sign-in code
Adds the server to Claude as a custom connector, so it works in claude.ai, Claude Desktop and the phone apps. Claude's servers reach it at a public address that dials out from your machine, so you open no ports: a Cloudflare tunnel on a domain you have on Cloudflare, or, with no domain, Tailscale Funnel. You sign in with a one-time code that the server shows on its setup page and writes to its log, which proves you run the server; there is nothing else to set up.
You need a machine on the same network as the console with Docker and Docker Compose, SSH access to the console, and either a domain on Cloudflare (the free plan is fine) or a Tailscale account.
It takes 7 steps, each one thing done in one place: a dashboard, a block of commands pasted at once, one edit of .env,
or a form in Claude. Counted the same way, this guide took 17 up to version 0.12.
Each value in .env comes from one place. The striped ones are only for guide 3:
Step 1: Get the files
git clone https://github.com/Graf3x/unifi-mcp && cd unifi-mcp
mkdir -p data run run-public
sed -e "s/^PUID=.*/PUID=$(id -u)/" -e "s/^PGID=.*/PGID=$(id -g)/" \
-e "s|^UNIFI_MCP_DATA_KEY=.*|UNIFI_MCP_DATA_KEY=$(openssl rand -base64 32)|" .env.example > .env
chmod 600 .env
This makes .env with your user and group (the containers run as them, and must be able to write to the three
folders) and a new UNIFI_MCP_DATA_KEY, which wraps the connector's signing keys in ./data. Copy that key into your
password manager: a backup of ./data opens nothing without it (Backup and rollback). Only
docker-compose.yml (or docker-compose.funnel.yml) and .env.example are needed at run time if you would rather
copy those files than clone.
Step 2: An API key
In UniFi Network, open Settings, Control Plane, Integrations and create an API key (the menu may move between versions). Keep it for step 5.
Step 3: The console's fingerprint
The server pins the console's public key instead of trusting a CA, since the console's certificate is self-signed. Read the fingerprint on the console itself, so nothing in between can hand you another one (SSH is under Control Plane, Console in UniFi OS):
ssh root@192.168.1.1 'openssl x509 -in /data/unifi-core/config/unifi-core.crt -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256'
Keep the 64 hex digits after = for step 5. Before you start has more:
what to do when the certificate changes, and a certificate from a trusted CA instead of a pin.
Step 4: A public address
Pick one.
A Cloudflare tunnel, on your domain. In Cloudflare Zero Trust, Networks, Tunnels: create a Cloudflared tunnel and
copy its token (the long value after --token in the Docker command shown). On the next page, add a published
application route (public hostname): unifi.example.com, Path empty, Service URL
unix:/run/unifi-mcp-public/public.sock, defaults otherwise. The wizard waits for a connection; you can leave it, the
tunnel connects in step 6. Make sure nothing on that hostname asks for a login or a challenge: no Access application
(watch for a wildcard such as *.example.com), no WAF, bot-fight or challenge rule. Claude's servers cannot pass one.
Or Tailscale Funnel, with no domain. On this machine, with Tailscale signed in:
sudo tailscale funnel --bg unix:$PWD/run-public/public.sock
It offers to turn on HTTPS and Funnel for your tailnet if they are off, and prints your address,
https://<machine>.<tailnet>.ts.net. Point Funnel at run-public/public.sock and nothing else. Never at
run/mcp.sock: that socket lets in whoever names an allowed Tailscale login, and from the internet anyone can name one.
For the same reason, never turn Funnel on for a port where tailscale serve already serves mcp.sock; the setup page
fails its tunnel check if the public address reaches that socket. Funnel has no edge in front of the server, and its
address names your machine and tailnet in public certificate logs; the
note on this route weighs it against the Cloudflare tunnel. To turn
it off: sudo tailscale funnel reset.
Step 5: Fill in .env
Open .env in an editor (nano .env; values typed into a file stay out of your shell history) and set:
UNIFI_URLto the console's address,https://192.168.1.1.UNIFI_API_KEYto the key from step 2, andUNIFI_CERT_SHA256to the fingerprint from step 3.MCP_PUBLIC_BASE_URLto the address from step 4, with no path:https://unifi.example.com, or thets.netone.TUNNEL_TOKENto the token from step 4, for the Cloudflare tunnel only.- With Funnel, add the line
COMPOSE_FILE=docker-compose.funnel.ymlinstead. Everydocker composecommand in this README then uses the Compose file without the tunnel container; the default one stops at an emptyTUNNEL_TOKEN.
Leave the rest as it is: MCP_SIGNIN=code signs you in with a code, and UNIFI_ALLOW_WRITES=false keeps the server
read-only (see Writes). Every variable is described in .env.example.
Step 6: Start it
docker compose up -d && docker compose logs unifi-mcp
With Funnel, the same command starts docker-compose.funnel.yml, through the COMPOSE_FILE line from step 5.
The startup line should read configured, writes off, ... connector ready, sign-in code, access token off. If it says
not configured (...) it lists what is still missing. The next line is the Setup page: link: open it in a browser on
this machine (on a server without one, forward the port first: ssh -L 5198:localhost:5198 you@server). Every check
should pass, including the tunnel. For a Cloudflare address that check runs from outside; for a ts.net address it may
go over the tailnet instead, so also open https://<machine>.<tailnet>.ts.net/healthz once from a phone off Wi-Fi and
off Tailscale.
UNIFI_MCP_DATA_KEY must stay the same from now on: a different value cannot open the keys in ./data (the connector
answers 503 and nothing is overwritten). To start over, stop the app and delete ./data; every client then has to
connect again.
Step 7: Add the connector in Claude
In Claude: Settings, Connectors, Add custom connector, URL https://unifi.example.com/mcp (or your ts.net address
with /mcp). Claude opens a sign-in page in your browser, and the server makes a one-time code as the page loads:
The code shows on the setup page the moment the sign-in page loads, so with that page open you don't need the log.
Otherwise run docker compose logs unifi-mcp and look for Sign-in code 01234-56789. Enter it and approve, then ask
Claude to call getting_started. A code works once, expires after 10 minutes, and is thrown away after 5 wrong tries; at most 10 new
codes are issued per hour.
Claude stays signed in (1-hour tokens refreshed in the background; a refresh token lasts 30 days from its last use).
https://unifi.example.com/connections lists connected clients, each with a Disconnect button, which is how you end
access.
Optional: a fixed access token
Some clients send a static header instead of signing in: Claude's connector dialog has a Request headers section (in beta
for some organisations), and Claude Code takes --header. Set MCP_ACCESS_TOKEN to a long random value
(openssl rand -hex 32, at least 32 characters) and send it as Authorization: Bearer <token> or X-Api-Key: <token>.
It works next to the sign-in, only on /mcp, and anyone holding it has the same access as you; to revoke it, change or
clear it and run docker compose up -d (with Funnel, the COMPOSE_FILE line in .env from step 5 makes it use the
Funnel file). For Claude Code, the unifi-token plugin
takes the address and the token on a form and keeps the token out of your shell history.
Guide 3: Full setup with Google sign-in
Everything in guide 2, but you sign in with a Google account on an allow-list instead of a code from the log, so nobody needs access to the server to connect, and you can add a second way in for Claude Code over Tailscale. Do guide 2 steps 1 to 6 first, then:
Step 1: A Google OAuth client
In the Google Cloud Console:
- Create a project.
- Set the OAuth consent screen (Google Auth Platform) to External and publish it ("In production"). The basic scopes
openid email profileneed no review. - Create an OAuth client of type Web application with the authorised redirect URI
https://unifi.example.com/signin-google.
Step 2: Switch the server to Google sign-in
In .env, set MCP_SIGNIN=google, put the client ID and secret in GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET, and
your address in MCP_ALLOWED_GOOGLE_EMAILS (comma separated for more than one). Then:
docker compose up -d
docker compose logs unifi-mcp # the startup line now ends: sign-in google, access token off
Changing MCP_SIGNIN later signs everyone out and ends the connections made under the other mode; connect again.
Step 3: Connect in Claude
As in guide 2 step 7, but the sign-in page sends you to Google. Removing an address from MCP_ALLOWED_GOOGLE_EMAILS
(and running docker compose up -d) ends its access; Disconnect on /connections still works too.
Step 4 (optional): Claude Code over Tailscale
./run/mcp.sock serves the same tools to your tailnet, with no sign-in page: tailscale serve tells the server who is
calling. Set MCP_ALLOWED_LOGINS in .env to the Tailscale logins allowed, run docker compose up -d, then on the
host:
sudo tailscale serve --bg --https=7420 unix:$PWD/run/mcp.sock
claude mcp add --transport http unifi https://<machine>.<tailnet>.ts.net:7420/mcp
See .mcp.json.example for the project form.
Guide 4: Claude Code across your LAN
For a server on your home network (a NAS, a mini PC) and Claude Code on other machines on the same network. No domain, no tunnel and no Tailscale: the server opens a listener on your network that accepts one token. Needs Docker and Docker Compose.
-
Get the files and make a token:
git clone https://github.com/Graf3x/unifi-mcp && cd unifi-mcp cp .env.example .env mkdir -p data run openssl rand -hex 32 # paste as MCP_LAN_ACCESS_TOKENIn
.env, setUNIFI_URL,UNIFI_API_KEYandUNIFI_CERT_SHA256from Before you start, andMCP_LAN_ACCESS_TOKENto the value you made. LeaveMCP_PUBLIC_BASE_URLandTUNNEL_TOKENempty. Onlydocker-compose.lan.ymland.env.exampleare needed at run time if you would rather copy those two files. -
Start it with the LAN compose file:
docker compose -f docker-compose.lan.yml up -d docker compose -f docker-compose.lan.yml logs unifi-mcpThe startup line ends in
LAN http://0.0.0.0:7420, followed by a reminder that the listener is plain HTTP. Open theSetup page:link: it checks the console values and shows the command for the next step. -
On each machine that runs Claude Code, add the
unifi-tokenplugin: it asks for the address,http://192.168.1.20:7420/mcp, and the token on a form, and keeps the token in Claude Code's credential store rather than your shell history. Then ask Claude to callgetting_started.This puts the token in your shell history, and in Claude Code's settings in plain text:
claude mcp add --transport http unifi http://192.168.1.20:7420/mcp --header "Authorization: Bearer <token>"Any client that speaks MCP over Streamable HTTP and can send a header works the same way;
X-Api-Key: <token>is accepted too.
The listener serves /mcp and /healthz and nothing else, and accepts only MCP_LAN_ACCESS_TOKEN; the server refuses to
start without one. It is plain HTTP, so anyone who can see your network's traffic can read the token, and anyone with the
token has the same access as you. Docker publishes port 7420 on every address of the host, so if the host has an
address the internet can route to, make sure your router or firewall blocks inbound traffic to it. Use it on a network
you trust, limit port 7420 to the machines that need it if your firewall can, or put a TLS proxy in front. To revoke the token, change it in .env and run
docker compose -f docker-compose.lan.yml up -d.
Already running guide 2 or 3? Add the listener to docker-compose.yml instead: set MCP_LAN_ACCESS_TOKEN in .env and
uncomment the MCP_LAN_LISTEN and 7420:7420 lines. Its token must differ from MCP_ACCESS_TOKEN, so the one that
crosses your network in plain HTTP never opens the internet-facing connector.
Claude Code from a form: the plugins
This repository is a Claude Code plugin marketplace with two plugins. Each adds the server to Claude Code from a form
that asks for its address, so nothing you type lands in your shell history, and each brings a getting-started skill
that has Claude check the connection first and pick the right tool. Add the marketplace once, in Claude Code:
/plugin marketplace add Graf3x/unifi-mcp
Then install the one that matches how you reach the server:
| Plugin | For | The form asks for |
|---|---|---|
unifi-token |
The LAN listener (guide 4), or the connector's address with MCP_ACCESS_TOKEN |
The address, such as http://192.168.1.20:7420/mcp, and the token |
unifi |
The connector's address (guide 2 or 3), where you sign in in the browser, or the tailnet (guide 3, step 4) | The address, such as https://unifi.example.com/mcp |
/plugin install unifi-token@unifi-mcp
or /plugin install unifi@unifi-mcp. Claude Code keeps the token in its credential store, apart from its settings
(on macOS, the Keychain). To change the address or the token later, run /plugin configure unifi-token@unifi-mcp and
restart Claude Code. With unifi on the connector's address, run /mcp and choose Authenticate to sign in: the
browser shows the same sign-in page as in Claude, and the code is on the setup page. Each release moves the plugins'
version, so /plugin update picks up a new skill.
Unraid
The template in unraid/unifi-mcp.xml runs the published image with the token-only LAN listener of
guide 4, for Claude Code on other machines on your network. It is not in
Community Applications; add it by hand, in the Unraid terminal:
wget -O /boot/config/plugins/dockerMan/templates-user/my-unifi-mcp.xml \
https://raw.githubusercontent.com/Graf3x/unifi-mcp/main/unraid/unifi-mcp.xml
openssl rand -hex 32 # the token: copy it into the form below, not into a command
Then Docker, Add Container, and pick unifi-mcp under User templates. The form asks for the console's address, the API
key, the fingerprint and the token; the key and the token are masked. Unraid saves the form's values in that template
file on the flash drive, readable by root, so they stay out of your shell history but not off the server. Leave the
fingerprint empty at first: once the container runs, click WebUI and add the ?key=… part of the Setup page: link
from the container's log to the address (the link itself names localhost, which only works on the Unraid server; the
WebUI button alone opens the page locked), copy the fingerprint its certificate check shows, confirm it on the console as in
Before you start, and set it in the form. Then add the server to
Claude Code with the unifi-token plugin, at
http://<unraid address>:7420/mcp.
The listener is plain HTTP, with the same caution as guide 4: keep port 7420 off the internet. The setup page's port,
5198, is published on your network too; it opens only with the key from the log, which crosses the network in plain
HTTP when you open the link from another machine, and the server makes a new key on every start. The template runs the
container read-only, with its socket folders in memory, and keeps nothing on disk. The Claude connector (guides 2
and 3) needs a tunnel container next to this one and a /data folder; use the Compose files for that.
Sharing one server
Read this before you let more than one person, or a client you don't run yourself, use the same server.
One console key, every site it reaches. The server makes every call to the console with its one UNIFI_API_KEY.
UNIFI_SITE is only the default: any caller can name another site in siteId and read every site that key can reach,
and change it too when writes are on. The console sees one API client, so its own logs cannot tell your callers apart.
One identity per way in. Each way in gives the server one caller, and the audit log names that caller:
| Way in | Who the server sees | Name in the audit log | To end that access |
|---|---|---|---|
| Code sign-in (guide 2) | One owner: whoever can read the server's log or open the setup page | owner |
Disconnect each client on /connections. To end every grant at once, stop the server and delete ./data (every client signs in again). |
| Google sign-in (guide 3) | Each address in MCP_ALLOWED_GOOGLE_EMAILS |
The Google address | Remove the address and run docker compose up -d, or Disconnect its clients on /connections. |
MCP_ACCESS_TOKEN |
Everyone who holds the token, as one caller | access token |
Change or clear it and run docker compose up -d. |
MCP_LAN_ACCESS_TOKEN (guide 4) |
Everyone who holds the token, as one caller | LAN access token |
Change it and run docker compose -f docker-compose.lan.yml up -d. |
Tailnet (mcp.sock) |
Each login in MCP_ALLOWED_LOGINS |
The Tailscale login | Remove the login and run docker compose up -d. |
| The console key itself | Not a caller: what the server uses for everyone | Delete it in UniFi Network under Settings > Control Plane > Integrations. The server then reaches nothing until you give it a new key. |
A sign-in grant ends at the client's next refresh: the access token it already holds works until it expires, within
the hour. Stopping the server and deleting ./data ends them all at once, since the tokens were signed with a key kept
there. The two tokens and the tailnet logins end as soon as the server restarts with the new values.
What the audit can tell you. The log category UnifiMcp.Audit has one line per tool call: the name above, the tool
and how it ended. A call to the Integration API also logs its method and path (the path names the site) and, for a write,
how it was approved; arguments are never logged. Writes are logged by default. Reads are logged at Debug only; to keep
them too, set Logging__LogLevel__UnifiMcp.Audit=Debug in .env. The audit cannot tell apart two people who share a
token, a Tailscale login or the sign-in code, and a write approval comes from whoever made the call, in their own client,
so it does not protect one caller from another.
Groups that don't trust each other each need a separate instance: its own folder, .env, ./data,
UNIFI_MCP_DATA_KEY, tokens and public hostname, and its own console key. A key can do what the console lets it do, and
this server cannot narrow it. If your console can make a key with less access (for example under an admin limited to
some sites, or to viewing only), give each group such a key; check what your UniFi Network version offers.
Updating
Before you update, note the image you run and back up ./data: see Backup and rollback.
For guides 2, 3 and 4 (add -f docker-compose.lan.yml to both commands for guide 4, or -f docker-compose.funnel.yml
with Funnel). On Unraid, the Docker tab's update link pulls the new image. If image: is pinned to a
digest, set it to the new release's verified digest first (below), since a pull keeps a pinned digest:
docker compose pull && docker compose up -d
To build from your checkout instead of pulling the published image, uncomment build: . and pull_policy: build in
docker-compose.yml, then docker compose up -d --build. For guide 1, git pull and run dotnet run again.
To check a release image before you run it, with the GitHub CLI: the first command checks it was built and signed by
this repository's release workflow for the tag v<version>, the second checks its SBOM (what it contains) was signed
the same way. A tag can move (latest does with every release), so the commands resolve the tag to a digest once and check that
digest. Each step runs only if the one before it passed, so a digest is printed only once both checks pass. Run that
one: set image: to ghcr.io/graf3x/unifi-mcp@<digest> (the value printed last) in your compose file before
docker compose pull. A pinned digest never moves, so docker compose pull alone keeps the old image: repeat these
steps for each new release, and set image: to its digest before you pull.
digest=$(docker buildx imagetools inspect ghcr.io/graf3x/unifi-mcp:<version> --format '{{.Manifest.Digest}}') &&
gh attestation verify "oci://ghcr.io/graf3x/unifi-mcp@$digest" -R Graf3x/unifi-mcp \
--signer-workflow Graf3x/unifi-mcp/.github/workflows/image.yml --source-ref refs/tags/v<version> &&
gh attestation verify "oci://ghcr.io/graf3x/unifi-mcp@$digest" -R Graf3x/unifi-mcp \
--signer-workflow Graf3x/unifi-mcp/.github/workflows/image.yml --source-ref refs/tags/v<version> \
--predicate-type https://spdx.dev/Document/v2.3 &&
echo "Verified: $digest"
Moving the public socket to its own folder
Guides 2 and 3 set up before this change put both sockets in ./run and mounted all of it into the tunnel container,
so that container could also reach mcp.sock, which trusts the login its caller names. The public socket now lives in
./run-public, and the tunnel container mounts only that folder. A new image looks for the public socket there; until
you move it, the connector is down (the log says Public socket not bound) and the tailnet side keeps working.
- Create the folder as yourself:
mkdir -p run-public. - Take the new
docker-compose.yml, or change yours: add- ./run-public:/run/unifi-mcp-publicunder theunifi-mcpservice'svolumes, and replace- ./run:/run/unifi-mcpundercloudflaredwith- ./run-public:/run/unifi-mcp-public. Don't keep./runin the tunnel container, not even read-only. - If you set
MCP_PUBLIC_LISTENin.env, remove it or point it into/run/unifi-mcp-public. Do this before the next step, which recreates the containers with whatever.envsays. - In Cloudflare Zero Trust, Networks, Tunnels, edit the route's Service URL to
unix:/run/unifi-mcp-public/public.sock. docker compose pull && docker compose up -d, then open the setup page: the tunnel check should pass. Once it does, you may delete the oldrun/public.sock.
Backup and rollback
Do this before every update. ./data holds the connector's state: oauth.db (clients, consents, refresh tokens as
hashes, revoked grants and the signing key) and keys/ (the keyring that seals the signing key under
UNIFI_MCP_DATA_KEY). A new version may change the layout of oauth.db, and an older image is not promised to read
the newer one, so a rollback is the old image together with the data from before the update. Guide 4 without the
connector keeps nothing there; noting the image is enough.
Note the image by digest, stop the server so SQLite finishes its write-ahead log, copy the whole folder (with
oauth.db-wal and oauth.db-shm if they are there), and start it again (add -f docker-compose.lan.yml for guide 4):
stamp=$(date +%Y%m%d-%H%M%S)
mkdir -p backups && chmod 700 backups && mkdir -m 700 "backups/$stamp"
docker image inspect --format '{{index .RepoDigests 0}}' "$(docker compose images -q unifi-mcp)" > "backups/$stamp/image"
docker compose stop unifi-mcp
(umask 077 && tar -cf "backups/$stamp/data.tar" data)
docker compose start unifi-mcp
backups/<stamp>/image now reads ghcr.io/graf3x/unifi-mcp@sha256:…, the exact image you ran. An image you built
yourself has no digest; write down the commit you built (git rev-parse HEAD) instead.
Keep the data key apart. The backup does not hold UNIFI_MCP_DATA_KEY (it lives in .env); keep a copy of it
somewhere else, such as a password manager, and never next to the backup. Without it a backup opens nothing: the
connector answers 503. With it, a backup can sign tokens this server accepts, so anyone who has both has your access.
Roll back with the data key unchanged:
docker compose stop unifi-mcp
mv data data.before-rollback
tar -xf backups/<stamp>/data.tar
Then set image: in docker-compose.yml to the line in backups/<stamp>/image and run docker compose up -d. Delete
data.before-rollback once you are sure.
A backup is old authorization state. Restoring it brings back every client and grant that existed when it was made,
including ones you disconnected since, and forgets clients that connected later (they sign in again). After a restore,
open /connections and Disconnect anything that should not be there. Keep backups readable only by you, as above, off
shared drives, and delete the ones you no longer need. If the data key ever leaks, stop the server, delete ./data and
every backup made under that key, and set a new key: every client signs in again.
Troubleshooting
- Guide 1, 403 from
http://127.0.0.1:5199/mcp: theTailscale-User-Loginheader is missing, or its value is not inMCP_ALLOWED_LOGINS. - 503 from
https://unifi.example.com/mcp: the connector is not configured or its keys cannot be opened; the startup log line says why. - 502 from
https://unifi.example.com/mcp: the tunnel can't reach the public socket. The route's Service URL must beunix:/run/unifi-mcp-public/public.sock, and./run-publicmust be mounted in both containers (see Moving the public socket to its own folder). - Guide 4, 401 from
http://192.168.1.20:7420/mcp: the header is missing, or its token isn'tMCP_LAN_ACCESS_TOKEN(MCP_ACCESS_TOKENis not accepted there). No answer at all: the port isn't published, or a firewall is in the way. docker psshows the container as unhealthy: the server doesn't answer/healthzonmcp.sock. The image checks it every 30 seconds withdotnet unifi-mcp.dll --healthcheck; it tells whether the server is up, not whether it is configured (the setup page says that).- 421: the request reached the server under another hostname.
MCP_PUBLIC_BASE_URLmust match the tunnel's public hostname exactly. - The tunnel never connects: the host may be blocked from Cloudflare on outbound port 7844.
- Funnel:
sudo tailscale funnel statusshows what is published. The tunnel check fails with "reaches this server's tailnet listener" when Funnel (or a proxy) points atrun/mcp.sock: runsudo tailscale funnel resetand point it atrun-public/public.sockas in guide 2 step 4. - Start with the setup page: its checks name most of the problems below and link to the step that fixes each.
- The setup page says it is locked: open the
Setup page:link from the server's latest start. The key changes each time the server starts. - 421 from the setup page: open it as
localhostor by IP address (http://192.168.1.20:5198), not by a host name; that refusal is what keeps other sites from reaching it through DNS tricks. - "does not match the pin": the console has a new certificate; see Before you start.
- "not trusted" with
UNIFI_CERT_TRUST=ca: the console's certificate is not from a CA the server trusts, has expired, or was not issued for the host inUNIFI_URL; the message says which.
Writes
With UNIFI_ALLOW_WRITES=true the write tools appear. Each asks you first, on a confirmation form that shows the whole
change: the request and every field of its body. You click Accept or Decline; the model cannot answer for you. A change
too big for the form (over 10,000 characters) is refused and nothing is sent, so Claude has to make it in smaller steps.
The form needs a client on MCP revision 2026-07-28 that declares form elicitation. A client without it is refused every
write. If yours cannot show the form and you still want writes there, set UNIFI_ALLOW_CONFIRM_FALLBACK=true. Then such a
client gets a preview, and the write is sent when the model calls the tool again with confirm set to the tool's own name.
Know what that means: the model sets confirm itself, so on that client the model approves its own writes. Nothing
checks that you saw the preview or said yes. Turn it on only if you trust the model, and what it reads, with your network.
Clients that can show the form still get it, and ignore confirm.
To allow only some writes, list their tool names in UNIFI_WRITE_TOOLS, separated by commas or spaces, for example
UNIFI_WRITE_TOOLS=create_dns_policy,update_dns_policy,delete_dns_policy. Only those are listed; the others do not exist
for the client and cannot be called. Names are exact and case-sensitive, with no wildcards. A name that is not a write tool
stops the server at startup, and the error lists the write tools (below, and search_operations shows
them too). Leave it empty for every write tool. It does nothing while UNIFI_ALLOW_WRITES is off, but the names are
still checked, so a typo shows before you turn writes on. getting_started tells the model how many write tools you allowed.
The audit log says how each change was approved, or why it was refused. Set UNIFI_ALLOW_WRITES back to false and
restart to make the server read-only.
Write tools
These are the names UNIFI_WRITE_TOOLS takes. "Deletes" marks the ones that remove something from the console.
| Tool | Category | What it does | Deletes |
|---|---|---|---|
create_acl_rule |
Access Control (ACL Rules) | Create ACL Rule | no |
delete_acl_rule |
Access Control (ACL Rules) | Delete ACL Rule | yes |
update_acl_rule |
Access Control (ACL Rules) | Update ACL Rule | no |
update_acl_rule_ordering |
Access Control (ACL Rules) | Reorder User-Defined ACL Rules | no |
execute_connected_client_action |
Clients | Execute Client Action | no |
create_dns_policy |
DNS Policies | Create DNS Policy | no |
delete_dns_policy |
DNS Policies | Delete DNS Policy | yes |
update_dns_policy |
DNS Policies | Update DNS Policy | no |
create_firewall_policy |
Firewall | Create Firewall Policy | no |
create_firewall_zone |
Firewall | Create Custom Firewall Zone | no |
delete_firewall_policy |
Firewall | Delete Firewall Policy | yes |
delete_firewall_zone |
Firewall | Delete Custom Firewall Zone | yes |
patch_firewall_policy |
Firewall | Patch Firewall Policy | no |
update_firewall_policy |
Firewall | Update Firewall Policy | no |
update_firewall_policy_ordering |
Firewall | Reorder User-Defined Firewall Policies | no |
update_firewall_zone |
Firewall | Update Firewall Zone | no |
create_vouchers |
Hotspot | Generate Vouchers | no |
delete_voucher |
Hotspot | Delete Voucher | yes |
delete_vouchers |
Hotspot | Delete Vouchers | yes |
create_network |
Networks | Create Network | no |
delete_network |
Networks | Delete Network | yes |
update_network |
Networks | Update Network | no |
create_traffic_matching_list |
Traffic Matching Lists | Create Traffic Matching List | no |
delete_traffic_matching_list |
Traffic Matching Lists | Delete Traffic Matching List | yes |
update_traffic_matching_list |
Traffic Matching Lists | Update Traffic Matching List | no |
adopt_device |
UniFi Devices | Adopt Devices | no |
execute_adopted_device_action |
UniFi Devices | Execute Adopted Device Action | no |
execute_port_action |
UniFi Devices | Execute Port Action | no |
remove_device |
UniFi Devices | Remove (Unadopt) Device | yes |
create_wifi_broadcast |
WiFi Broadcasts | Create Wifi Broadcast | no |
delete_wifi_broadcast |
WiFi Broadcasts | Delete Wifi Broadcast | yes |
update_wifi_broadcast |
WiFi Broadcasts | Update Wifi Broadcast | no |
Settings reference
All settings come from the environment (.env with Docker Compose). After changing one, run docker compose up -d.
At startup the server logs a warning, by name only, for any UNIFI_* or MCP_* variable it does not read, and names
the setting it probably meant when one is close (a misspelt MCP_SETUP_PAGE would otherwise leave the setup page on).
If such a typo is what stops the server starting, the warning is printed next to the error.
| Variable | Default | What it does |
|---|---|---|
UNIFI_URL |
https://192.168.1.1 |
The console's address as the server reaches it. https only. |
UNIFI_SITE |
default |
The site tools use when they don't name one. |
UNIFI_API_KEY |
none | Network API key (Before you start). |
UNIFI_CERT_SHA256 |
none | Pinned fingerprints of the console's public key or certificate, comma separated. |
UNIFI_CERT_TRUST |
pin |
ca checks a CA-issued certificate instead of a pin. |
UNIFI_ALLOW_WRITES |
false |
Exactly true lists the write tools; see Writes. |
UNIFI_WRITE_TOOLS |
none (all) | With writes on, only these write tools, by exact name, comma or space separated; see Writes. A name that is not a write tool stops the server. |
UNIFI_REVEAL_SECRETS |
none | voucher-codes shows hotspot voucher codes in answers; see Safety. Any other value stops the server. |
UNIFI_ALLOW_CONFIRM_FALLBACK |
false |
Exactly true lets a client that cannot show the confirmation form write with confirm, so the model approves its own writes there; see Writes. |
MCP_PUBLIC_BASE_URL |
none | The connector's public origin, e.g. https://unifi.example.com. |
MCP_SIGNIN |
google |
code or google; .env.example sets code. |
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET |
none | Google OAuth web client, for google sign-in. |
MCP_ALLOWED_GOOGLE_EMAILS |
none | Google addresses allowed to sign in, comma separated. |
MCP_ACCESS_TOKEN |
none | Optional fixed token for clients that send a header; at least 32 characters. |
MCP_LAN_ACCESS_TOKEN |
none | The only token the LAN listener (guide 4) accepts; at least 32 characters, not the same as MCP_ACCESS_TOKEN. |
UNIFI_MCP_DATA_KEY |
none | Wraps the connector's signing keys in ./data. Generate once and keep it. |
MCP_ALLOWED_LOGINS |
none | Logins allowed on the tailnet socket, or in guide 1. |
TUNNEL_TOKEN |
none | Read by the cloudflared container, not the server. |
PUID, PGID |
1000 |
The user and group the containers run as. |
MCP_SETUP_PAGE |
on, except with Google sign-in and a public URL | off turns the setup page off; on turns it on in guide 3. |
| Variable | Default | What it does |
|---|---|---|
UNIFI_API_KEY_FILE |
/config/unifi-api-key |
Read when UNIFI_API_KEY is empty. |
UNIFI_CERT_SHA256_FILE |
/config/cert-sha256 |
Read when UNIFI_CERT_SHA256 is empty; re-read on each new connection. |
MCP_ALLOWED_LOGINS_FILE |
/config/allowed-logins |
Read when MCP_ALLOWED_LOGINS is empty. |
MCP_ALLOWED_GOOGLE_EMAILS_FILE |
/config/allowed-google-emails |
Read when MCP_ALLOWED_GOOGLE_EMAILS is empty. |
MCP_LISTEN |
unix:/run/unifi-mcp/mcp.sock |
The tailnet listener. A TCP address is refused unless it is loopback and MCP_ALLOW_LOOPBACK_TCP=true. |
MCP_PUBLIC_LISTEN |
unix:/run/unifi-mcp-public/public.sock |
The connector's listener. Keep it in a folder of its own: that folder is all the tunnel container mounts. |
MCP_ALLOW_LOOPBACK_TCP |
false |
Allows a loopback MCP_LISTEN, as in guide 1. |
MCP_DATA_DIR |
/data |
Where the connector keeps its sign-in store and keys. |
MCP_LAN_LISTEN |
off | The token-only LAN listener: an IP address and a port, e.g. http://0.0.0.0:7420. Serves /mcp and /healthz over plain HTTP; needs MCP_LAN_ACCESS_TOKEN. docker-compose.lan.yml sets it. |
MCP_SETUP_LISTEN |
http://127.0.0.1:5198 |
The setup page's own listener: an IP address (or localhost) and a port. docker-compose.yml sets http://0.0.0.0:5198 in the container and publishes it on the host's 127.0.0.1 only. |
FAQ
Does it need a UI.com account or cloud access? No. The server talks to the console over your network with a local API key. Claude reaches the server only the way you set up: locally, through your Cloudflare tunnel or Tailscale Funnel, over Tailscale, or over your LAN with a token.
Can Claude change my network? Only if you set UNIFI_ALLOW_WRITES=true. Even then each change asks you first, on a
confirmation form where you see the whole change and click Accept or Decline yourself. A client that cannot show the form
cannot write at all, unless you also set UNIFI_ALLOW_CONFIRM_FALLBACK=true; then Claude approves its own writes there
with confirm, as Writes explains.
Will it slow the console down? The official API is made for this. The diagnostics tools also read the console's internal API, which is not, so those calls are limited to 30 a minute and repeats within 10 seconds come from a cache. Every call is bounded too: at most 4 requests are at the console at once, each gets 30 seconds and 16 MB, and a list is read to 5,000 items. One composite answer makes at most 100 requests and reads at most 32 MB. When it stops early it starts with "Partial answer" and says how to narrow the question.
Does it keep my network data? No. ./data holds only the connector's sign-in records and keys, the keys wrapped with
UNIFI_MCP_DATA_KEY (Privacy and data). Console answers go to Claude in the conversation; the diagnostics tools leave out the secrets the
internal API returns, such as device keys.
I have several sites. Every tool takes siteId (a UUID or a site name); UNIFI_SITE sets the default. If two sites share a name, use the UUID: the server refuses a name that fits more than one site.
Which UniFi versions work? It is built against UniFi Network's Integration API 11.0.97 and tested on UniFi Network 11.
unifi_status, getting_started and the setup page show three versions: the server's, the API document's and the
console's. When the console runs a newer minor or major version than the document (11.1 against 11.0, say), the server
logs one warning, and unifi_status and the setup page's API key check show a Warn line naming both: the operations and
fields added since are missing until a release moves to the newer document. A newer patch release is not flagged.
The diagnostics use internal endpoints Ubiquiti can change without notice; if one moves, that tool says so and the rest
keep working.
What does it cover? UniFi Network only, today: the Network application's official Integration API, and read-only diagnostics from its internal API. USP Plugs and the USP PDU are Network devices, so they are covered as devices. UniFi Protect may come later, through its own official local API and only as an opt-in. UniFi Access is not planned. Site Manager is not planned either: it is a cloud API, and this server works without the cloud.
Can I use another MCP client? Yes, any client that speaks MCP over Streamable HTTP. With guide 1, guide 4, Tailscale or the access token it only needs to send a header.
Owner's Fleet setup
The owner runs this in their own homelab under Fleet, from the bundle in deploy/ (fleet.yaml, compose.yaml,
Dockerfile, SHA256SUMS). Fleet builds it from checksummed source (deploy/Dockerfile, context ./build), and
supplies values as owner keys set with fleet-key; the public hostname is set in deploy/compose.yaml. It uses Google sign-in (MCP_SIGNIN unset) and no access token. None of this is
needed to run it yourself. After changing anything under src/UnifiMcp/, regenerate deploy/SHA256SUMS from the repo
root and check it:
sha256sum -b $(git ls-files src/UnifiMcp | LC_ALL=C sort) > deploy/SHA256SUMS && sha256sum -c deploy/SHA256SUMS
Who does what
Claude never sees key values and holds no Google or Cloudflare credentials. Everything below marked owner is the owner's
to run: every fleet-key command, the Google Cloud Console, the Cloudflare dashboard, deleting files in config/, and any
UniFi firewall change. Fleet releases (the owner's merge) gate each deploy.
Owner setup (on fleet-mini)
The Network API key, the console's certificate pin, and the Google and Cloudflare values are owner keys set with
fleet-key. Allow-lists live in files in /srv/fleet/apps/unifi-mcp/config (run as a user with sudo).
# The console's certificate SHA-256 (64 hex digits, colons allowed), after confirming it on the console:
# ssh to the console, then: openssl x509 -in /data/unifi-core/config/unifi-core.crt -noout -fingerprint -sha256
.\fleet-key set UNIFI_CERT_SHA256
.\fleet-key allow UNIFI_CERT_SHA256 unifi-mcp
When the console regenerates its certificate, run fleet-key set UNIFI_CERT_SHA256 again with the new fingerprint (or the
old and new, comma separated);
Fleet redeploys the app with the new value. config/cert-sha256 still works as a fallback while the key is unset.
cd /srv/fleet/apps/unifi-mcp/config
# Tailscale logins allowed on the tailnet address, one per line.
echo 'you@example.com' | sudo tee allowed-logins >/dev/null
# Publish on the tailnet. 7420 is already open to tailnet admins in Fleet's ACL.
sudo tailscale serve --bg --https=7420 unix:/srv/fleet/apps/unifi-mcp/run/mcp.sock
Then, for Claude Code: claude mcp add --transport http unifi https://fleet-mini.<tailnet>.ts.net:7420/mcp.
Files are read on each use, so no restart is needed. Writes are on in deploy/compose.yaml (UNIFI_ALLOW_WRITES: "true");
set it to "false" and redeploy to make the server read-only. UNIFI_ALLOW_CONFIRM_FALLBACK is not set there, so only a
client that can show the confirmation form can write.
Runbook: two stages
The keys arrive in two deploys, so a tailnet-only fix is never blocked on the Google or Cloudflare setup (Fleet refuses to
deploy an app that declares a key that is unset or not granted to it). <host> is the public hostname in
deploy/compose.yaml.
Stage 1: API key from Fleet, writes on, tailnet only (v0.2.0)
fleet.yaml declares keys: [UNIFI_API_KEY]; compose.yaml passes UNIFI_API_KEY: ${UNIFI_API_KEY} and sets
UNIFI_ALLOW_WRITES: "true". MCP_PUBLIC_BASE_URL stays unset, so the public socket answers 503.
- Owner:
fleet-key set UNIFI_API_KEY(if not set yet), thenfleet-key allow UNIFI_API_KEY unifi-mcp. - Deploy through Fleet (the owner merges the release). Check the logs for
configured, writes ONandconnector not configured (...), and have Claude callgetting_started: it should say configured. - Owner: delete
config/unifi-api-key, then restart the app. The API key now comes only from the environment (the file is read only whenUNIFI_API_KEYis unset or empty). Confirm the logs still sayconfigured.
Stage 2: the connector
- Owner, Google Cloud Console: as in step 1 of guide 3, with redirect URI
https://<host>/signin-google. Store the client ID and secret withfleet-key set GOOGLE_CLIENT_IDandfleet-key set GOOGLE_CLIENT_SECRET, thenfleet-key alloweach forunifi-mcp. - Owner, Cloudflare Zero Trust: as in guide 2 step 4, route
<host>tounix:/run/unifi-mcp-public/public.sock. Store the token withfleet-key set UNIFI_MCP_TUNNEL_TOKENandfleet-key allowit. - Owner: put your Google address in
config/allowed-google-emails, one per line:echo 'you@example.com' | sudo tee allowed-google-emails >/dev/null. - Owner, only if the tunnel will not connect: fleet-mini may be blocked from Cloudflare on outbound port 7844. Opening it is a UniFi firewall change for the owner to approve.
- Deploy 2 (the owner merges the release). It adds the three keys to
keys:,secrets: [UNIFI_MCP_DATA_KEY](Fleet generates it),MCP_PUBLIC_BASE_URL,./data:/dataand thecloudflaredsidecar. No ports are published. - In Claude: Settings, Connectors, Add custom connector, URL
https://<host>/mcp. Sign in with Google, approve, and ask Claude to callgetting_started.
Migration: the public socket's own folder
The release that moves the public socket out of ./run changes the live tunnel's origin. The connector is down from the
deploy until step 3 is done; the tailnet side keeps working throughout.
- Owner, on fleet-mini, before the deploy: create
run-publicnext torun, with the same owner, unless Fleet has already made it:cd /srv/fleet/apps/unifi-mcp && sudo install -d -o "$(stat -c %u run)" -g "$(stat -c %g run)" -m 700 run-public. - Deploy (the owner merges the release).
deploy/compose.yamlmounts./run-publicinto both containers and no longer mounts./runintocloudflared. - Owner, Cloudflare Zero Trust: edit the route for
<host>, Service URLunix:/run/unifi-mcp-public/public.sock. - Check: the logs have no
Public socket not boundline, andhttps://<host>/healthzanswersok. The tailnet route (tailscale serveonrun/mcp.sock) needs no change. The oldrun/public.sockcan be deleted.
Allow-list behaviour
config/allowed-google-emails(one address per line) is re-read on every use. Removing an address ends access: the next refresh fails, and its sign-in cookie stops opening/connectionsand/oauth/authorizeat once.- Exception: if the file is empty or missing at startup, the connector reports "not configured" and stays that way until the app is restarted, even after you add an address.
MCP_ALLOWED_GOOGLE_EMAILS(a comma or newline separated list) overrides the file.MCP_ALLOWED_GOOGLE_EMAILS_FILEmoves the file.- If
UNIFI_MCP_DATA_KEYis missing or cannot open the existing keyring in./data/keys, or the Google keys or base URL are missing, the public socket refuses everything (503) and the log names what is wrong; the tailnet side keeps working. Nothing is regenerated over old keys.
Develop
dotnet test unifi-mcp.slnx. Tests run against a fake UniFi handler; nothing here talks to a real console.
For a local run: MCP_LISTEN=http://127.0.0.1:5199 MCP_ALLOW_LOOPBACK_TCP=true MCP_ALLOWED_LOGINS=you@example.com dotnet run --project src/UnifiMcp.
To exercise the device diagnostics view without a host, open tests/view-host/index.html (served by any static file
server from the repository root): it plays the host's side with sample answers.
Pushing a v* tag runs .github/workflows/image.yml: tests, then a multi-arch (amd64, arm64) image pushed to
ghcr.io/<owner>/unifi-mcp as the version, <major>.<minor> and latest. Bump <Version> in src/UnifiMcp/UnifiMcp.csproj
to match. A prerelease tag (v1.2.3-rc.1) pushes only its own version and leaves latest alone.
Issues and pull requests are welcome; CONTRIBUTING.md covers the conventions, and SECURITY.md how to report a vulnerability privately. Changes are listed in CHANGELOG.md.
Credits
Developed with Claude Code and Claude Opus 5.5, by Anthropic.
Not affiliated with or endorsed by Ubiquiti Inc. UniFi is a trademark of Ubiquiti Inc.