UniFi Protect MCP

io.github.sirkirby由 GitHub 帳號 sirkirby 發布v0.1.6更新於 Oct 26, 2026

Manage UniFi Protect cameras, events, recordings, and smart detections via MCP.

已驗證STDIO僅桌面位置與生活安全與監控

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理查詢與管理自有控制器上的 UniFi Protect 攝影機、事件、錄影、智慧偵測與裝置。

可以做什麼
  • 列出、檢視、截圖並控制攝影機,包含 PTZ、設定、錄影開關與重新開機
  • 查詢歷史事件、智慧偵測、Find Anything 搜尋與縮圖,並支援即時事件串流
  • 查看錄影狀態並匯出片段,支援縮時攝影
  • 管理 Known Faces 人臉群組並檢視多攝影機版面
  • 控制燈光、感測器與門鈴,讀取 NVR 健康、韌體與檢視端狀態
  • 管理 Alarm Manager 規則,AI 告警僅對 SuperAdmin 帳號可見
適用情境
適合在本機控制器上執行 UniFi Protect、想用自然語言詢問攝影機活動、偵測、錄影或裝置健康,或偶爾在預覽確認後調整攝影機與燈光設定的使用者。
執行需求
以 stdio 在本機執行,可從 PyPI(uvx 或 pip)或 Docker 安裝。需要能連線控制器的網路,以及 UNIFI_HOST(或 UNIFI_PROTECT_HOST)、UNIFI_USERNAME 與 UNIFI_PASSWORD;選用 UNIFI_PORT、UNIFI_VERIFY_SSL,部分 HDR、麥克風與燈光設定需要 UNIFI_API_KEY。不會自動載入 .env 檔案。
安裝前請注意
需要控制器管理員憑證,部分設定還需 API 金鑰,應避免在對話或設定檔中明文暴露。攝影機設定、重新開機、錄影開關、燈光控制及告警規則新增修改刪除會改變裝置狀態,更新失敗可能留下部分變更。在合併型主控台上 SuperAdmin 同時授予 Network 控制權。串流位址預設會去識別化,關閉後會暴露原始位址。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 UniFi Protect MCP,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

UniFi Protect MCP Server

[UniFi Protect MCP Server]

MCP server exposing UniFi Protect tools for AI assistants and other MCP-capable clients. Query cameras, events, smart detections, Find Anything detection search, recordings, lights, sensors, chimes, Known Faces, license plates, and the Alarm Manager with safe-by-default permissions and preview-before-confirm for all mutations.

Software integrating over HTTP, including automation services and MCP adapters, should use unifi-api-server for REST and GraphQL reads, actions, and SSE events.

[License: MIT] [Python 3.13+]

Install

Claude Code (recommended)

The plugin installs the MCP server, an agent skill for tool discovery, and a guided setup command:

/plugin marketplace add sirkirby/unifi-mcp/plugin install unifi-protect@unifi-plugins

Then run the interactive setup to configure your controller connection:

/unifi-protect:unifi-protect-setup

This walks you through entering your controller host, credentials, and permission preferences. Credentials are given as a file or command provider, never typed into chat. Setup saves the result as the plugin's Claude Code options, which apply in every project; a password or API key entered as an option is stored in the system keychain. Start a new Claude Code session after setup to connect.

Upgrading from a plugin version before 1.0.0, which kept settings in the project's .claude/settings.local.json? Follow the plugin upgrade guide.

Codex

Register the marketplace, then install unifi-protect from Codex's /plugins UI:

bash
codex plugin marketplace add sirkirby/unifi-mcp

After installing, ask Codex to use the UniFi Protect setup skill. Setup saves a version-pinned MCP server entry with your controller settings in Codex's config.toml and prompts you to restart Codex. After each plugin upgrade, re-run setup with --refresh.

PyPI / Docker

bash
# PyPIuvx unifi-protect-mcp@latest# or: pip install unifi-protect-mcp
# Dockerdocker pull ghcr.io/sirkirby/unifi-protect-mcp:latest
# From sourcegit clone https://github.com/sirkirby/unifi-mcp.gitcd unifi-mcp && uv sync

Usage Examples

Once connected, just ask your AI agent in natural language:

"List all cameras that detected motion in the last hour"

"Show me smart detection events from the front door camera today — people and vehicles only"

"Find driveway detections for white vans this week"

"Which cameras have the most motion events this week? Any unusual patterns?"

"Are there any cameras offline or with degraded connections?"

"Show me all recording events from the driveway camera between 2 AM and 5 AM last night"

"What sensors triggered alerts today and what were the readings?"

All camera and event queries are read-only by default. Mutations (camera settings, light controls) use a preview-then-confirm flow.

Configure

Set these variables in the server's process environment. The plugin setup skill already does this for Codex and OpenClaw; in Claude Code the plugin maps its options onto these variables. The server does not automatically load .env or working-directory YAML files; load a trusted env file explicitly in your launcher (Docker env_file: is supported), or select custom YAML with an absolute CONFIG_PATH. See configuration for migration examples.

With no controller host configured, the server still starts in setup mode: it tells the client how to configure it, offers only the read-only protect_setup_status tool, and makes no controller connections.

bash
# Server-specific variables (recommended)UNIFI_PROTECT_HOST=192.168.1.1      # Controller IP or hostnameUNIFI_PROTECT_USERNAME=admin         # Local admin usernameUNIFI_PROTECT_PASSWORD=your-password # Admin password# Optional:# UNIFI_PROTECT_API_KEY=             # Required for camera HDR/mic volume and light power/brightness/PIR settings# UNIFI_PROTECT_PORT=443             # Controller HTTPS port# UNIFI_PROTECT_VERIFY_SSL=false     # SSL certificate verification

Camera HDR and microphone volume, plus floodlight power, brightness, PIR sensitivity, and duration now use the Protect public Integration API with uiprotect 16.x. Set UNIFI_PROTECT_API_KEY (or the shared fallback UNIFI_API_KEY) and restart the server before using these settings. Session credentials remain required for other Protect operations. Missing keys or incompatible public device IDs fail before any settings in the request are written.

Microphone volume updates accept 1–100; zero is rejected by the public API. Existing HDR aliases are preserved: true/on/normal mean auto, false means off, and always/superHdr select public HDR on. Light brightness remains 1–6, sensitivity 0–100, and duration 15–900 seconds. light_on and is_light_on are equivalent inputs and control forced illumination; turning forced illumination off does not disable motion-triggered lighting.

Settings updates retain preview/confirmation and policy gates. Requests are validated before writing; controller failures can still leave a partial update. Failed updates return an error with the settings that applied, so callers can inspect the current state before retrying.

Fallback: The shared UNIFI_* variables (e.g., UNIFI_HOST) also work. The server checks for UNIFI_PROTECT_* first and falls back to UNIFI_* if the server-specific variable is not set. For single-controller setups, the shared variables are all you need.

MCP response size

For tool results that already provide structured output, adaptive is the default response mode. It classifies each request by the canonical date-based protocolVersion advertised during MCP initialization, not by the client's product name or application version. Requests advertising MCP 2025-06-18 or later receive concise content plus the full result once in structuredContent; requests advertising an earlier revision (such as 2024-11-05 or 2025-03-26), or whose revision metadata is missing or malformed, keep full compatibility JSON in content. Set UNIFI_PROTECT_MCP_CONTENT_MODE to compat to force the duplicated compatibility form, or to compact to force concise text plus full structured output outside a negotiated request. This server-specific variable overrides UNIFI_MCP_CONTENT_MODE; use compat for any client that consumes the full result only from content, regardless of its advertised revision.

The lazy-loading meta-tools (*_tool_index, *_execute, *_batch, *_batch_status, and lazy-only *_load_tools) remain content-only; they are not the pre-2025-06-18 protocol category described above. For structured inner results, *_execute and *_batch_status expose one normalized JSON payload in content rather than a nested transport pair; content-only execute results remain unchanged. Response modes do not convert these meta-tools to structuredContent.

When Network is enabled alongside Protect, its largest source responses are independently bounded: unifi_get_dashboard defaults to summary=true, and unifi_list_rogue_aps defaults to a summarized page of at most 100 records; summary=false restores the full selected data.

AI-powered alarms need SuperAdmin. The alarm-rule tools (protect_alarm_list_rules / protect_alarm_get_rule / protect_alarm_create_rule / protect_alarm_update_rule / protect_alarm_delete_rule) transparently use the modern UniFi-OS Alarm Manager when the account is SuperAdmin, and fall back to the classic automations view otherwise. The modern path surfaces and manages AI-powered alarms (e.g. AI Natural Language); the legacy path cannot see those rules and responses include a standard MCP _meta notice when the view is limited. Grant the account SuperAdmin on the console hosting Protect to view/manage AI alarms. Blast radius: on a standalone UNVR this is contained to Protect; on a combined UDM console SuperAdmin also grants Network/UniFi-OS control.

Sensitive response fields

Protect tools redact secret-bearing stream fields by default before returning data to MCP clients. This includes RTSP/RTSPS stream aliases and URLs from protect_get_camera_streams. Disable redaction for a trusted local administration process with UNIFI_PROTECT_REDACT_SENSITIVE_FIELDS=false or the global UNIFI_REDACT_SENSITIVE_FIELDS=false policy flag when raw stream values are required.

Run

bash
# stdio transport (default -- for Claude Desktop, LM Studio, etc.)unifi-protect-mcp
# Dockerdocker run -i --rm \  -e UNIFI_PROTECT_HOST=192.168.1.1 \  -e UNIFI_PROTECT_USERNAME=admin \  -e UNIFI_PROTECT_PASSWORD=secret \  ghcr.io/sirkirby/unifi-protect-mcp:latest

Claude Desktop

Add to claude_desktop_config.json:

jsonc
{  "mcpServers": {    "unifi-protect": {      "command": "uvx",      "args": ["unifi-protect-mcp"],      "env": {        "UNIFI_PROTECT_HOST": "192.168.1.1",        "UNIFI_PROTECT_USERNAME": "admin",        "UNIFI_PROTECT_PASSWORD": "your-password"      }    }  }}

Features

  • Cameras -- list, inspect, snapshot, RTSP streams, PTZ control, settings, recording toggle, reboot
  • Events -- query historical events, smart detections (person/vehicle/animal/package), Find Anything detection search, thumbnails
  • Real-time streaming -- websocket event buffer with MCP resource subscriptions and polling
  • Recordings -- status, availability, clip export with timelapse support
  • Known Faces -- list, rename, merge, and remove face recognition groups
  • Devices -- lights (brightness, PIR sensitivity), sensors (temperature, humidity, motion), chimes (volume, trigger)
  • Liveviews -- list and inspect multi-camera layouts
  • System -- NVR info, health metrics, firmware status, connected viewers

Agent Skills

The Protect plugin ships one agent skill that works alongside the MCP tools:

Security Digest

Cross-product event intelligence that generates a concise security summary across all connected UniFi systems.

  • Sources: Protect camera events, Access door events, Network firewall activity
  • Severity classification: Events are classified by time-of-day context (business hours vs. after hours vs. overnight) and event type (person detection, vehicle, door access, firewall block, etc.)
  • Cross-product correlation: Five built-in correlation rules surface patterns that span products:
    • Motion at a door camera without a corresponding badge-in
    • Multiple failed door access attempts in a short window
    • Person detection coinciding with firewall blocks from the same timeframe
    • After-hours camera activity with no Access event
    • Repeated vehicle detections at the perimeter
  • Activity counts: Aggregated totals across all sources for quick at-a-glance awareness

Invoke via the skill command after installing the plugin:

/unifi-protect:security-digest

Event Improvements

camera_name in Event Responses

All event-related tools now include camera_name alongside camera_id in every event object. The name is resolved from bootstrap data cached at startup — no extra API calls required.

Affected tools: protect_list_events, protect_list_smart_detections, protect_recent_events

Before:

json
{ "camera_id": "abc123", "type": "motion", ... }

After:

json
{ "camera_id": "abc123", "camera_name": "Front Door", "type": "motion", ... }

This eliminates the need to call protect_list_cameras separately just to map IDs to names.

Compact Mode

protect_list_events and protect_list_smart_detections accept a compact=true parameter that strips low-signal fields from responses: thumbnail_id, category, sub_category, and is_favorite. This produces responses roughly 40% smaller.

python
# Standard callprotect_list_events(limit=50)
# Compact — recommended for digests, summaries, and context-constrained workflowsprotect_list_events(limit=50, compact=True)

Compact mode is the recommended default when building summaries or feeding events into downstream prompts where token budget matters.

Documentation

Development

bash
cd apps/protectmake test         # Run testsmake lint         # Lintmake format       # Formatmake manifest     # Regenerate tools_manifest.jsonmake pre-commit   # All of the above

See the root CONTRIBUTING.md for the full monorepo workflow.

License

MIT

來源:apps/protect/README.md,提交 fbd083c

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.6最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分