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? |
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 (its operation lists 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_operations finds an operation and describe_operation shows 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 give client_path_faq the switch port and dhcp_reservation_faq the fixed IP.
device_diagnostics_faq also 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_WRITES is exactly true; 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_TOOLS can 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_KEY environment variable, falling back to /config/unifi-api-key only 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, set UNIFI_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 fixed MCP_ACCESS_TOKEN.
run/mcp.sock, optional tailnet access: reached through tailscale serve, which stamps Tailscale-User-Login; the server
checks it against an allow-list. The public socket ignores that header. The tunnel container mounts only
run-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_LISTEN is set. It serves only
/mcp and /healthz, accepts only MCP_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:5198 on 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 set
UNIFI_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.db and keys, the keys
wrapped with UNIFI_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_TOOLS and 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) |
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_SHA256 empty. 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_SHA256 to 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.