loading…
Search for a command to run...
loading…
Read-only MCP server for UniFi Network controllers
Read-only MCP server for UniFi Network controllers
Read-only data retriever for the UniFi Network application (UniFi OS and classic). Provides TypeScript library functions, a CLI, and an MCP server for LLM clients. This repo contains the TypeScript source, specs, and per-agent configuration snippets required to self-host the MCP.
Multiple controller targets with independent auth, TLS, timeouts, and rate limits.
Auth flows: UniFi OS via POST /api/auth/login and classic via POST /api/login.
Routing: UniFi OS under /proxy/network/api/..., classic under /api/....
Network Integration API (API key) support:
GET /integration/v1/info → get_sysinfoGET /integration/v1/sites → list_sitesGET /integration/v1/sites/{siteId}/devices → get_devicesGET /integration/v1/sites/{siteId}/clients → get_clientsRead-only only. No mutations.
Scope note: When connecting with an API key generated from the UniFi Network Integrations UI, only the Integration API endpoints listed above are guaranteed to work on UniFi Dream Machine / UniFi OS controllers. Endpoints such as
stat/health,stat/event, andstat/reportrequire username/password authentication and are not available to Integration API keys.
git and a POSIX shell (macOS/Linux)Clone and install:
git clone https://github.com/ryanbehan/unifi-network-mcp.git
cd unifi-network-mcp/servers/unifi-network-mcp
npm install
Export UNIFI_TARGETS (single or multiple controllers). Example:
export UNIFI_TARGETS='[
{
"id": "home",
"base_url": "https://<unifi_host>",
"controller_type": "unifi_os",
"default_site": "default",
"auth": { "apiKey": "UNIFI_API_KEY", "headerName": "X-API-KEY" },
"verify_ssl": false,
"timeout_ms": 20000,
"rate_limit_per_sec": 5
}
]'
Key fields:
home, lab). Use this id as targetId in MCP tool calls when you have more than one controller.https://<unifi_host>). This is the same URL you use to access the UniFi Network UI.UNIFI_API_KEY obtained from UniFi Network → Settings → System → Integrations for the Network Application.site. Often Default; if your controller uses a different site name, check the Integration API Sites endpoint in the Network App.Multiple targets are supported:
export UNIFI_TARGETS='[
{ "id": "home", "base_url": "https://<unifi_host_home>", "controller_type": "unifi_os", "default_site": "Default", "auth": { "apiKey": "UNIFI_API_KEY_HOME", "headerName": "X-API-KEY" }, "verify_ssl": false, "timeout_ms": 20000, "rate_limit_per_sec": 5 },
{ "id": "lab", "base_url": "https://<unifi_host_lab>", "controller_type": "unifi_os", "default_site": "Default", "auth": { "apiKey": "UNIFI_API_KEY_LAB", "headerName": "X-API-KEY" }, "verify_ssl": false, "timeout_ms": 20000, "rate_limit_per_sec": 5 }
]'
targetId and will automatically use that single target.targetId (e.g. home or lab) in the MCP tool arguments so the server knows which controller to use.Example tool calls (multi-target):
home (default site):{ "targetId": "home" }lab / Default site:{ "targetId": "lab", "site": "Default" }codex exec "call get_devices with targetId lab and site Default" --skip-git-repo-check
Build once (emits dist/ artifacts shared by every tool below):
npm run build
curl -L https://github.com/ryanbehan/unifi-network-mcp/releases/download/v0.1.0/unifi-network-mcp-v0.1.0.tar.gz | tar -xz -C ~/.local/share/
cd ~/.local/share/unifi-network-mcp
cp .env.example .env
# Edit .env with your UNIFI_TARGETS
All quickstarts use the same launch script, which validates UNIFI_TARGETS, builds on demand, and starts the MCP on STDIO:
cd /path/to/unifi-network-mcp
./run-mcp.sh
Leave this process running while your IDE/CLI talks to the MCP.
npx-y unifi-network-mcpUNIFI_TARGETS in the dialog (paste the JSON string) if not globally exported:[{"id":"home","base_url":"https://<unifi_host>","controller_type":"unifi_os","default_site":"Default","auth":{"apiKey":"UNIFI_API_KEY","headerName":"X-API-KEY"},"verify_ssl":false,"timeout_ms":20000,"rate_limit_per_sec":5}]
.cursor/mcp.config.json in your repo:{
"servers": [
{
"name": "unifi-network",
"command": "npx",
"args": ["-y", "unifi-network-mcp"],
"env": {
"UNIFI_TARGETS": "[{\"id\":\"home\",\"base_url\":\"https://<unifi_host>\",\"controller_type\":\"unifi_os\",\"default_site\":\"Default\",\"auth\":{\"apiKey\":\"UNIFI_API_KEY\",\"headerName\":\"X-API-KEY\"},\"verify_ssl\":false,\"timeout_ms\":20000,\"rate_limit_per_sec\":5}]"
}
}
]
}
npx the MCP whenever needed.~/.codex/config.toml:[mcp_servers.unifi-network-mcp]
command = "npx"
args = ["-y", "unifi-network-mcp"]
[mcp_servers.unifi-network-mcp.env]
UNIFI_TARGETS = '[{"id":"home","base_url":"https://<unifi_host>","controller_type":"unifi_os","default_site":"Default","auth":{"apiKey":"UNIFI_API_KEY","headerName":"X-API-KEY"},"verify_ssl":false,"timeout_ms":20000,"rate_limit_per_sec":5}]'
Tip: replace <API_KEY> and any controller metadata with your own values. Codex will download + cache the MCP automatically on first launch.codex exec list_sites --skip-git-repo-check to confirm connectivity.gemini CLI (Early Access) and enable MCP support.~/.gemini/mcp.yaml:servers:
- name: unifi-network
command: npx
args:
- -y
- unifi-network-mcp
env:
UNIFI_TARGETS: "[{\"id\":\"home\",\"base_url\":\"https://<unifi_host>\",\"controller_type\":\"unifi_os\",\"default_site\":\"Default\",\"auth\":{\"apiKey\":\"UNIFI_API_KEY\",\"headerName\":\"X-API-KEY\"},\"verify_ssl\":false,\"timeout_ms\":20000,\"rate_limit_per_sec\":5}]"
gemini mcp servers list to confirm, then gemini chat --use-mcp unifi-network.~/.aws/amazonq/mcp.json:{
"servers": [
{
"name": "unifi-network",
"command": "npx",
"args": ["-y", "unifi-network-mcp"],
"env": {
"UNIFI_TARGETS": "[{\"id\":\"home\",\"base_url\":\"https://<unifi_host>\",\"controller_type\":\"unifi_os\",\"default_site\":\"Default\",\"auth\":{\"apiKey\":\"UNIFI_API_KEY\",\"headerName\":\"X-API-KEY\"},\"verify_ssl\":false,\"timeout_ms\":20000,\"rate_limit_per_sec\":5}]"
}
}
]
}
amazon-q chat --mcp unifi-network.~/.config/opencode/opencode.json:{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"unifi-network-mcp": {
"type": "local",
"command": ["npx", "-y", "unifi-network-mcp"],
"enabled": true,
"environment": {
"UNIFI_TARGETS": "[{\"id\":\"home\",\"base_url\":\"https://<unifi_host>\",\"controller_type\":\"unifi_os\",\"default_site\":\"Default\",\"auth\":{\"apiKey\":\"UNIFI_API_KEY\",\"headerName\":\"X-API-KEY\"},\"verify_ssl\":false,\"timeout_ms\":20000,\"rate_limit_per_sec\":5}]"
}
}
}
}
unifi-network-mcp server will be available in chats.claude.mcpServers key:"claude.mcpServers": {
"unifi-network-mcp": {
"command": "npx",
"args": ["-y", "unifi-network-mcp"],
"env": {
"UNIFI_TARGETS": "[{\"id\":\"home\",\"base_url\":\"https://<unifi_host>\",\"controller_type\":\"unifi_os\",\"default_site\":\"Default\",\"auth\":{\"apiKey\":\"UNIFI_API_KEY\",\"headerName\":\"X-API-KEY\"},\"verify_ssl\":false,\"timeout_ms\":20000,\"rate_limit_per_sec\":5}]"
}
}
}
@mcp unifi-network-mcp list_sites in a Claude chat.For Claude terminal / global config (outside VS Code), add the server to ~/.claude/settings.json:
{
"mcpServers": {
"unifi-network-mcp": {
"command": "npx",
"args": ["-y", "unifi-network-mcp"],
"env": {
"UNIFI_TARGETS": "[{\"id\":\"home\",\"base_url\":\"https://<unifi_host>\",\"controller_type\":\"unifi_os\",\"default_site\":\"Default\",\"auth\":{\"apiKey\":\"UNIFI_API_KEY\",\"headerName\":\"X-API-KEY\"},\"verify_ssl\":false,\"timeout_ms\":20000,\"rate_limit_per_sec\":5}]"
}
}
}
}
After saving, restart Claude terminal or Desktop; the unifi-network-mcp server will be available there as well.
You can extend GitHub Copilot Chat with this MCP by adding a local server configuration in the same format documented by GitHub:
.vscode/mcp.json file in the root of your repo.settings.json under Copilot's MCP configuration (see GitHub docs for exact key names).Example mcp.json contents for this server:
{
"servers": {
"unifi-network-mcp": {
"command": "npx",
"args": ["-y", "unifi-network-mcp"],
"env": {
"UNIFI_TARGETS": "[{\"id\":\"home\",\"base_url\":\"https://<unifi_host>\",\"controller_type\":\"unifi_os\",\"default_site\":\"Default\",\"auth\":{\"apiKey\":\"UNIFI_API_KEY\",\"headerName\":\"X-API-KEY\"},\"verify_ssl\":false,\"timeout_ms\":20000,\"rate_limit_per_sec\":5}]"
}
}
}
}
npm run test:env calls list_sites against every configured target and fails fast on TLS/auth errors.codex exec get_sysinfo --skip-git-repo-check
To share a prebuilt MCP without requiring every consumer to run npm install:
npm run build to populate dist/.dist/, node_modules/, run-mcp.sh, and package.json into unifi-network-mcp-<version>.tar.gz.UNIFI_TARGETS, and run ./run-mcp.sh without compiling TypeScript.releases/ branch and serve via GitHub Pages for simple curl | tar installs./usr/local/bin.dist/ copied in, expose STDIO via docker run --entrypoint ./run-mcp.sh ....Each approach keeps the project free to distribute (only prebuilt JS + shell script) while letting downstream users skip the TypeScript toolchain.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"unifi-network-mcp": {
"command": "npx",
"args": [
"-y",
"unifi-network-mcp"
]
}
}
}