unifi-mcp
unifi-mcp
只读远程 MCP 服务器,通过官方 UniFi Site Manager API(api.ui.com)将 Example Corp / examplecorp 的 UniFi 设备群暴露为 Claude 自定义连接器。
是 odoo-ticket-mcp 和 TRMM MCP servers 的同类项目,架构相同:
Claude (claude.ai / Claude Code)
│ OAuth 2.0 bearer token (Microsoft Entra ID)
▼
nginx — TLS, Anthropic egress-IP allowlist (160.79.104.0/21), 403 otherwise
│ http://127.0.0.1:8097
▼
unifi-mcp container (Portainer stack, FastMCP 3.x, Streamable HTTP at /mcp)
│ X-API-KEY (Site Manager API key, read-only usage)
▼
api.ui.com — Site Manager API + connector proxy into each console's Network API客户端 → 服务器认证: Microsoft Entra ID,资源服务器模式。服务器验证已绑定受众的 bearer token;它从不颁发这些 token。访问权限由应用注册上的 Entra 组成员身份控制。
服务器 → UniFi 认证: 一个固定的 Site Manager API 密钥(在 unifi.ui.com → API Keys 中创建,具有 Site Manager + Network 应用范围,All Sites)。调用方身份在 v1 中有意不转发给 UniFi。
网络路径: 公共 DNS → nginx(TLS + Anthropic IP 允许列表)→ 容器。纵深防御:允许列表是在 OAuth 之外额外增加的。
工具(全部只读)
Site Manager(全设备群):
工具 | 返回内容 |
| 每个控制台(UDM Pro / UNVR / Cloud Key):id、name、model、IP、state、version |
| 单个控制台的详细信息(可选完整原始记录) |
| 跨控制台的所有 Network 站点,包含设备/客户端数量 |
| 全设备群中已采纳的设备(AP、交换机、网关),可选的按控制台过滤 |
| 所有站点的 WAN/ISP 健康状态(延迟、丢包、停机时间、吞吐量),5m 或 1h 粒度 |
| 相同,但针对特定的 (host, site) 组合和时间窗口 |
| SD-WAN 拓扑 + 部署状态 |
连接器代理(按控制台下钻,无需 VPN):
工具 | 返回内容 |
| 控制台本地的站点列表(本地 id 与 Site Manager id 不同) |
| 来自控制台自身 Network API 的某站点设备 |
| 完整设备详情 + 最新实时统计(CPU、内存、上行链路、射频) |
| 实时连接的客户端:名称、MAC、IP、连接类型、上行链路 |
典型流程:unifi_list_hosts → 选择控制台 → unifi_network_sites → unifi_network_clients / unifi_network_device。
Related MCP server: UniFi MCP Server
本地开发
python -m venv .venv
.venv\Scripts\pip install -r requirements.txt
copy .env.example .env # fill in UNIFI_API_KEY; set MCP_AUTH_ENABLED=false
.venv\Scripts\python -m unifi_mcp
# → http://127.0.0.1:8000/mcp (test with MCP Inspector)MCP_AUTH_ENABLED=false 会开放该端点——仅用于本地测试,切勿在生产环境中使用。
Entra ID 应用注册(一次性)
带注释的版本请参阅 TrmmMCPServer/ENTRA_SSO_PLAYBOOK.md。摘要——请按顺序完成以下操作:
应用注册 → 新建注册 — 名称为
UniFi MCP,单租户,暂不设置重定向 URI。复制 client id 和 tenant id。公开 API → Application ID URI — 必须准确设置为
https://unifi-mcp.example.com/mcp(防止出现 AADSTS9010010)。公开 API → 添加范围 —
access_as_user,管理员和用户可以同意,已启用。证书和机密 → 新建客户端机密 —
claude-connector,24 个月。立即复制该值。身份验证 → 添加平台 → Web — 重定向 URI 为
https://claude.ai/api/mcp/auth_callback和https://claude.com/api/mcp/auth_callback。清单 — 将
requestedAccessTokenVersion设置为2(防止签发者不匹配的 401 错误)。企业应用程序 → UniFi MCP → 属性 — 需要分配 = 是。
企业应用程序 → 用户和组 — 添加
Unifi-MCP-Users组。组成员身份 = 谁可以使用该连接器。
部署
请参阅 PORTAINER_DEPLOY.md(Portainer Git stack + webhook 重新部署)和 deploy/nginx-unifi-mcp.conf(TLS + Anthropic IP 允许列表)。
在 claude.ai 中注册连接器
设置 → 连接器 → 添加自定义连接器:
字段 | 值 |
URL |
|
Client ID | Entra 应用的 client id |
Client Secret | Entra 客户端机密 |
Authorization URL |
|
Token URL |
|
Scopes |
|
验收测试
# 1. Discovery doc advertises the full resource scope (not api://…)
curl -s https://unifi-mcp.example.com/.well-known/oauth-protected-resource/mcp | jq .scopes_supported
# 2. Unauthenticated /mcp is challenged
curl -i https://unifi-mcp.example.com/mcp # 401 + WWW-Authenticate: Bearer
# 3. Non-Anthropic source IP is blocked at nginx
curl -i https://unifi-mcp.example.com/mcp # from anywhere else: 403
# 4. Health (host-local, bypasses nginx)
curl http://<docker-host>:8097/healthz # {"status":"ok","service":"unifi_mcp"}
# 5. In claude.ai: connect as a Unifi-MCP-Users member → tools appear;
# non-member → AADSTS50105 at sign-in.This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables 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.101GPL 3.0
- 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.3952Apache 2.0
- AlicenseBqualityDmaintenanceEnables 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.41MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to manage UniFi network infrastructure through 50+ tools covering devices, clients, networks, WiFi, firewall rules, and guest access using the official UniFi Network API.52585MIT
Related MCP Connectors
Uptime, SSL, DNS and domain monitoring you can talk to from Claude or any MCP client.
Hosted Amazon Seller Central and Amazon Ads MCP server for Claude, ChatGPT, Cursor, and agents.
Connect Claude to Fathom meeting recordings, transcripts, and summaries
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/JohnGilligan2/unifi-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server