UniFi Network MCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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 that dials out carries the traffic, and you sign in with a one-time code from the server's 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? |
|
Which switch port is the office printer plugged into? |
|
Is the NAS getting the fixed IP I reserved for it? |
|
Did the internet drop out this week, and how bad was the packet loss? |
|
Are any access points on a busy or noisy channel? |
|
Do any switch ports show errors, drops or a flapping link? |
|
Why does my laptop keep losing Wi-Fi? |
|
Who signed in to the console in the last day? |
|
Which devices are offline or have firmware updates waiting? |
|
What ports are forwarded to the internet? |
|
With writes on: add a DNS record so |
|
Anything else the API offers, Claude finds with search_operations and runs with call_read_operation.
Related MCP server: unifi-mcp
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. 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.
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) | 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 Cloudflare tunnel | Only through the Cloudflare tunnel | 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 -sha256Then 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 export UNIFI_API_KEY='<your API key>' 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 = '<your API key>' $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/UnifiMcpIn 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 through a Cloudflare tunnel: the tunnel container dials out, so you open no ports. You sign in with a one-time code that the server writes to its own 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, and a domain on Cloudflare.
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
cp .env.example .env
mkdir -p data run run-publicOnly docker-compose.yml and .env.example are needed at run time if you would rather copy those two files. Create
data, run and run-public as yourself: the containers run as PUID:PGID from .env (your id -u / id -g) and
must be able to write there.
Step 2: Console values
Put the two values from Before you start in .env as UNIFI_API_KEY
and UNIFI_CERT_SHA256, and set UNIFI_URL to the console's address (https://192.168.1.1).
Step 3: Cloudflare tunnel
In Cloudflare Zero Trust, Networks, Tunnels: create a Cloudflared tunnel and copy its token (the long value after
--token in the Docker command shown). Put it in .env as TUNNEL_TOKEN. The wizard waits for a connection; you can
leave it and come back under Networks, Tunnels.
On the tunnel, add a published application route (public hostname): unifi.example.com, Path empty, Service URL
unix:/run/unifi-mcp-public/public.sock, defaults otherwise.
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.
Step 4: The rest of .env, then start
openssl rand -base64 32 # paste as UNIFI_MCP_DATA_KEY, once; keep itSet MCP_PUBLIC_BASE_URL=https://unifi.example.com. Leave MCP_SIGNIN=code as .env.example has it.
UNIFI_ALLOW_WRITES=false keeps the server read-only; see Writes. Every variable is described in
.env.example.
docker compose up -d
docker compose logs unifi-mcpThe 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 to test every
value, including the tunnel from the outside. UNIFI_MCP_DATA_KEY wraps the OAuth signing keys in ./data: a
different value cannot open them (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 5: Add the connector in Claude
In Claude: Settings, Connectors, Add custom connector, URL https://unifi.example.com/mcp. Claude opens a sign-in page
in your browser, and the server writes a one-time code to its log as the page loads:
The code also 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.
claude mcp add --transport http unifi https://unifi.example.com/mcp --header "Authorization: Bearer <token>"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 4 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 offChanging 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 5, 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/mcpSee .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 server with its address and the token:
claude mcp add --transport http unifi http://192.168.1.20:7420/mcp --header "Authorization: Bearer <token>"Then ask Claude to call
getting_started. 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.
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 |
| Disconnect each client on |
Google sign-in (guide 3) | Each address in | The Google address | Remove the address and run |
| Everyone who holds the token, as one caller |
| Change or clear it and run |
| Everyone who holds the token, as one caller |
| Change it and run |
Tailnet ( | Each login in | The Tailscale login | Remove the login and run |
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). 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 -dTo 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 Cloudflare 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-mcpbackups/<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.tarThen 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.
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 |
| Access Control (ACL Rules) | Create ACL Rule | no |
| Access Control (ACL Rules) | Delete ACL Rule | yes |
| Access Control (ACL Rules) | Update ACL Rule | no |
| Access Control (ACL Rules) | Reorder User-Defined ACL Rules | no |
| Clients | Execute Client Action | no |
| DNS Policies | Create DNS Policy | no |
| DNS Policies | Delete DNS Policy | yes |
| DNS Policies | Update DNS Policy | no |
| Firewall | Create Firewall Policy | no |
| Firewall | Create Custom Firewall Zone | no |
| Firewall | Delete Firewall Policy | yes |
| Firewall | Delete Custom Firewall Zone | yes |
| Firewall | Patch Firewall Policy | no |
| Firewall | Update Firewall Policy | no |
| Firewall | Reorder User-Defined Firewall Policies | no |
| Firewall | Update Firewall Zone | no |
| Hotspot | Generate Vouchers | no |
| Hotspot | Delete Voucher | yes |
| Hotspot | Delete Vouchers | yes |
| Networks | Create Network | no |
| Networks | Delete Network | yes |
| Networks | Update Network | no |
| Traffic Matching Lists | Create Traffic Matching List | no |
| Traffic Matching Lists | Delete Traffic Matching List | yes |
| Traffic Matching Lists | Update Traffic Matching List | no |
| UniFi Devices | Adopt Devices | no |
| UniFi Devices | Execute Adopted Device Action | no |
| UniFi Devices | Execute Port Action | no |
| UniFi Devices | Remove (Unadopt) Device | yes |
| WiFi Broadcasts | Create Wifi Broadcast | no |
| WiFi Broadcasts | Delete Wifi Broadcast | yes |
| 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 |
|
| The console's address as the server reaches it. https only. |
|
| The site tools use when they don't name one. |
| none | Network API key (Before you start). |
| none | Pinned fingerprints of the console's public key or certificate, comma separated. |
|
|
|
|
| Exactly |
| 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. |
| none |
|
|
| Exactly |
| none | The connector's public origin, e.g. |
|
|
|
| none | Google OAuth web client, for |
| none | Google addresses allowed to sign in, comma separated. |
| none | Optional fixed token for clients that send a header; at least 32 characters. |
| none | The only token the LAN listener (guide 4) accepts; at least 32 characters, not the same as |
| none | Wraps the connector's signing keys in |
| none | Logins allowed on the tailnet socket, or in guide 1. |
| none | Read by the |
|
| The user and group the containers run as. |
| on, except with Google sign-in and a public URL |
|
Variable | Default | What it does |
|
| Read when |
|
| Read when |
|
| Read when |
|
| Read when |
|
| The tailnet listener. A TCP address is refused unless it is loopback and |
|
| The connector's listener. Keep it in a folder of its own: that folder is all the tunnel container mounts. |
|
| Allows a loopback |
|
| Where the connector keeps its sign-in store and keys. |
| off | The token-only LAN listener: an IP address and a port, e.g. |
|
| The setup page's own listener: an IP address (or |
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, 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/SHA256SUMSWho 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-mcpWhen 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.sockThen, 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 3, 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.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Read-only access to your own crypto portfolio across 11+ exchanges and 20+ chains: holdings, full history, FIFO cost basis and P&L, fees and income. Ask Claude or ChatGPT about your portfolio; the connector can never trade, move funds or act as a login.
Read-only access to your own bank, card and brokerage accounts for Claude, ChatGPT and other AI agents: balances, transactions, spending, subscriptions, cashflow and investment holdings. It can never move money.
- platform7nDeprecatedtech.p7n
Connect Claude to your Platform7n workspaces: chat, links, work and decks. One-click OAuth.
Connect Claude to your Platform7n workspaces: chat, links, work and decks. One-click OAuth.
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.39MIT
- AlicenseAqualityDmaintenanceMCP server that turns Claude into a UniFi network specialist. Manage devices, optimize WiFi, audit security, and troubleshoot your network through natural language.3113 npm2MIT
- FlicenseNot gradedqualityBmaintenanceRead-only MCP server that surfaces UniFi network data from a UCG-Fiber console to Claude, enabling monitoring of hosts, sites, devices, clients, ISP metrics, and device stats via read-only API tools.-
- FlicenseNot gradedqualityDmaintenanceEnables read-only querying of a UniFi fleet via the Site Manager API and per-console connector proxy, allowing users to list hosts, sites, devices, ISP metrics, and live network clients through Claude.-