Skip to main content
Glama

mcp-ubiquiti

A remote MCP connector that lets Claude observe your UniFi network — who's connected, device health, throughput, and ISP/WAN status — through Ubiquiti's own cloud API.

There is no local proxy, tunnel, or always-on box in your house. The connector runs as a Cloudflare Worker and talks to api.ui.com, which relays to your console over the link it already maintains. Works behind CGNAT.

Claude  ──OAuth──▶  Cloudflare Worker  ──X-API-KEY──▶  api.ui.com  ──▶  your UniFi console
     (via Cloudflare Access)         (this repo)      (Ubiquiti cloud)

What Claude can see

Mostly observation. The writes are deliberately narrow: rename_client sets a display label, and the traffic-rule tools manage scheduled block rules (for example, keeping a child's console offline during school hours):

Tool

What it returns

network_overview

Device/client counts, ISP, WAN uptime, tx-retry

list_clients

Connected clients: IP, MAC, VLAN, SSID, live throughput, plus (wifi) which AP they're on, signal in dBm, SNR, band, channel, and the negotiated PHY (Wi-Fi generation, channel width, spatial streams, link rate)

list_devices

Gateways/switches/APs: online state, model, firmware, client count

list_wifi

Configured SSIDs, security mode, VLAN mapping (no passphrases)

list_networks

Networks/VLANs and their VLAN IDs

client_history

Traffic over time for a client, or a ranked list of the busiest. 5-min buckets ~1 day, hourly ~1 week, daily ~30 days

client_sessions

Association history: when clients joined and left, which AP, duration, and roam count

rename_client

(write) Sets a client's display name, by MAC. Returns the previous name so the change can be reversed.

list_traffic_rules

Traffic rules: what each blocks, who it applies to (by client and network name), when it runs, and whether it's on

set_traffic_rule

(write) Creates or edits a rule that blocks the whole internet, DPI app categories (e.g. games) or domains, for chosen clients and/or networks, always or in a weekly window. Edits change only the fields passed (e.g. just enabled: false to pause for the holidays) and return the previous version

delete_traffic_rule

(write) Deletes a rule and returns it in full so it can be recreated

archie_status

A child's screen-time rules right now: blocking or not, schedule, any active pause and when it ends

archie_allow

(write) Pause the rules for N minutes or until HH:MM; they come back by themselves

archie_revoke

(write) End a pause early

archie_kick_off

(write) Cut whatever is open right now without changing schedules

archie_usage

Today per device: first online, time online, download, traffic kinds, timeline

The archie_* tools talk to a policy engine running at home (archie-control) through a Cloudflare Tunnel and Access service token; they appear only when the HOME_* secrets are set.

Related MCP server: UniFi MCP Server

Security model

  • Access is bound to one identity. Login is delegated to Cloudflare Access, whose policies perform the real identity check. The Worker then rejects any authenticated email that isn't ALLOWED_EMAIL, so nobody else can complete the flow even with the URL.

  • All secrets live as encrypted Cloudflare secrets, never in the repo. The .gitignore also blocks .dev.vars and any *.rtf key-scratch files.

  • The UniFi key never reaches Claude — it stays server-side in the Worker.

  • Writes are narrow. rename_client sets a display label; the traffic-rule tools manage block rules and nothing else. There is no code path to SSID, VLAN, firewall-zone or DHCP settings. Write tools carry MCP annotations (readOnlyHint: false, and destructiveHint on delete) so clients can ask before running them.

Prerequisites

  • A UniFi console (firmware ≥ 5.0.3) adopted into Site Manager.

  • A Cloudflare account (free tier is fine).

  • Cloudflare Zero Trust (Access) enabled on that account, with at least one identity provider configured.

Setup

1. Clone & install

git clone https://github.com/<you>/mcp-ubiquiti.git
cd mcp-ubiquiti
npm install

2. Create a UniFi API key

At unifi.ui.comSettings → API Keys → Create New API Key. Give it Site Manager + Network scope. Copy the key (shown once).

Find your console's host id (you'll set it as a secret in step 5):

curl -s -H "X-API-KEY: <your-key>" https://api.ui.com/v1/hosts | jq '.data[].id'

3. Create a Cloudflare Access OIDC app

Login is delegated to Cloudflare Access, so it uses whichever identity providers you've already configured there (Google, Entra, one-time PIN) — there is no third-party developer console to set up.

In Cloudflare Zero TrustAccess → Applications → Add an application → SaaS, choose OIDC and set the redirect URL to your Worker's callback (printed during wrangler deploy, of the form https://mcp-ubiquiti.<subdomain>.workers.dev/callback).

Note the client ID, client secret, and your team domain (your-team.cloudflareaccess.com). Add an Access policy restricting the app to the identity you want. ALLOWED_EMAIL (step 5) is then a second, local check so the connector stays bound to one person even if the policy is later widened.

4. Create the KV namespace

npx wrangler kv namespace create OAUTH_KV

Paste the returned id into wrangler.jsonc under kv_namespaces[0].id.

5. Set secrets

npx wrangler secret put UNIFI_API_KEY        # the Site Manager API key
npx wrangler secret put UNIFI_HOST_ID        # console id from step 2
npx wrangler secret put ALLOWED_EMAIL        # the one identity allowed in
npx wrangler secret put ACCESS_TEAM_DOMAIN   # your-team.cloudflareaccess.com
npx wrangler secret put ACCESS_CLIENT_ID
npx wrangler secret put ACCESS_CLIENT_SECRET

6. Deploy

npm run deploy

7. Add to Claude

In Claude → Settings → Connectors → Add custom connector, paste your Worker URL (https://mcp-ubiquiti.<subdomain>.workers.dev/mcp). Claude will walk you through the Cloudflare Access login; only ALLOWED_EMAIL succeeds.

Local development

cp .dev.vars.example .dev.vars   # fill in real values (gitignored)
npm run dev

Roadmap

  • Admin change events (stat/event is not relayed by the cloud proxy; it 404s on both GET and POST, so connect/disconnect is served from client_sessions instead).

  • WAN latency trends over time.

  • Further write tools (SSID, firewall zones) behind an explicit confirmation flag.

License

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables AI assistants to interact with Ubiquiti UniFi network infrastructure for monitoring devices, managing clients, and performing configuration tasks like blocking/unblocking devices and viewing network health.
    10
    1
    GPL 3.0
  • A
    license
    D
    quality
    D
    maintenance
    Enables 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.
    39
    27 npm
    Apache 2.0
  • A
    license
    B
    quality
    D
    maintenance
    Enables AI assistants to manage and monitor UniFi Network Controllers through natural language. Provides 25 read-only tools for discovering devices and clients, viewing security configurations, analyzing network statistics, and exporting configuration data.
    41
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables 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.
    Academic Free v1.1