UniFi MCP Server

UniFi MCP Server

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.

Category
访问服务器

README

UniFi MCP Server

A Model Context Protocol (MCP) server for comprehensive UniFi Network Management via the UniFi Cloud API. This server enables AI assistants like Claude to manage your UniFi infrastructure through natural language.

Features

  • UniFi Cloud API Integration - Full access to api.ui.com for remote management
  • OAuth 2.0 Authentication - Secure access with PKCE support for Claude Desktop, Claude Mobile, ChatGPT, and more
  • Multi-Transport Support - SSE and Streamable HTTP for flexible deployment
  • Complete UniFi Ecosystem - Network, Protect (cameras), and Access (doors) management
  • Production Ready - Docker support, Redis for token storage, Coolify/VPS deployment

Quick Start

1. Get Your UniFi Cloud API Key

  1. Go to UniFi Site Manager
  2. Navigate to API section from the left navigation
  3. Click "Create API Key"
  4. Copy the generated key

2. Installation

# Clone the repository
git clone https://github.com/yourusername/unifi-mcp-server.git
cd unifi-mcp-server

# Install dependencies
npm install

# Create environment file
cp .env.example .env

3. Configuration

Edit .env with your settings:

# Required: Your UniFi Cloud API Key
UNIFI_API_KEY=zjWD6zwI55loIpMLLcjDDvRTCuVnVyHA2

# Server settings
PORT=3000
BASE_URL=https://your-domain.com

# OAuth password for authorization (optional but recommended)
OAUTH_PASSWORD=your_secure_password

# API Key for direct access (optional)
API_KEY=your_api_key

4. Run the Server

Development (stdio mode for Claude Desktop):

npm run dev

Production (HTTP server with OAuth):

npm run start:http

Docker:

docker-compose up -d

Claude Desktop Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "unifi": {
      "command": "node",
      "args": ["/path/to/unifi-mcp-server/src/index.js"],
      "env": {
        "UNIFI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Remote Access (Claude Mobile / ChatGPT)

For remote access, deploy the HTTP server and connect via OAuth:

  1. Deploy to your VPS or Coolify
  2. Configure your domain with HTTPS
  3. Connect using the OAuth flow:
    • Server URL: https://your-domain.com
    • Client ID: claude-mobile or chatgpt
    • Scope: unifi-api

Available Tools

Network & System

Tool Description
unifi_health Check UniFi Cloud API connectivity
get_system_status Comprehensive system status overview
list_hosts List all UniFi OS consoles
list_sites List all network sites
get_isp_metrics Get ISP performance metrics

Devices

Tool Description
list_all_devices List all UniFi devices
get_device Get device details
locate_device Flash LEDs to locate a device
restart_device Restart a device
find_device_by_mac Search by MAC address
get_offline_devices List offline devices

Clients

Tool Description
list_all_clients List all connected clients
block_client Block a client from network
unblock_client Unblock a client
reconnect_client Force reconnect a client
find_client_by_name Search clients by name
get_client_bandwidth_summary Bandwidth usage analysis

UniFi Protect (Cameras)

Tool Description
list_cameras List all cameras
get_camera Get camera details
set_camera_privacy Toggle privacy mode
set_camera_recording Set recording mode

UniFi Access (Doors)

Tool Description
list_doors List all access doors
unlock_door Temporarily unlock a door
lock_door Lock a door

Example Usage

Once connected, you can use natural language:

  • "Show me the status of my UniFi network"
  • "List all offline devices"
  • "Who's using the most bandwidth?"
  • "Block the device with MAC XX:XX:XX:XX:XX:XX"
  • "Unlock the front door for 10 seconds"
  • "Turn on privacy mode for the garage camera"

Deployment

Coolify

  1. Create new application from Git repository
  2. Set environment variables in Coolify dashboard
  3. Configure your domain with HTTPS
  4. Deploy!

Docker Compose

# Set environment variables
export UNIFI_API_KEY=your_key
export OAUTH_PASSWORD=your_password
export BASE_URL=https://your-domain.com

# Start services
docker-compose up -d

Manual VPS

# Install Node.js 20+
# Clone repository
# Install dependencies: npm install
# Set up systemd service or PM2
# Configure reverse proxy (nginx/caddy) with SSL

API Endpoints

Endpoint Description
GET /health Health check
GET /status Server status
GET /.well-known/oauth-authorization-server OAuth discovery
GET /oauth/authorize OAuth authorization
POST /oauth/token Token exchange
GET /sse SSE transport
POST /mcp/messages MCP messages (authenticated)

Security

  • HTTPS Required - Always use HTTPS in production
  • OAuth 2.0 + PKCE - Secure authorization flow
  • API Key Authentication - Alternative for server-to-server
  • Password Protection - Optional OAuth authorization password
  • Redis Token Storage - Secure token management with TTL

Troubleshooting

API Key Issues

# Test your API key
curl -H "X-API-Key: YOUR_KEY" https://api.ui.com/v1/hosts

OAuth Issues

  • Check OAUTH_PASSWORD is set correctly
  • Verify BASE_URL uses HTTPS
  • Ensure redirect URIs match client configuration

Connection Issues

  • Verify UniFi Cloud API is accessible
  • Check firewall rules for port 3000
  • Review container logs: docker-compose logs -f

License

MIT License - See LICENSE file for details.

Contributing

Pull requests welcome! Please ensure:

  • Tests pass
  • Documentation updated
  • Code follows existing style

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选