Skip to main content

UniFi Protect MCP Server

UniFi Protect MCP Server

MCP server exposing UniFi Protect tools for LLMs, agents, and automation platforms. 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.

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:setup

This walks you through entering your controller host, credentials, and permission preferences — then writes everything to .claude/settings.local.json so it persists across sessions. If you already have the Network plugin configured on the same controller, the setup will detect and reuse those credentials. Restart Claude Code after setup to connect.

Codex

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

codex plugin marketplace add sirkirby/unifi-mcp

After installing, ask Codex to use the UniFi Protect setup skill. The setup flow registers the MCP server with codex mcp add, stores your controller environment values in Codex's MCP configuration, and prompts you to restart Codex.

PyPI / Docker

# PyPI
uvx unifi-protect-mcp@latest
# or: pip install unifi-protect-mcp

# Docker
docker pull ghcr.io/sirkirby/unifi-protect-mcp:latest

# From source
git clone https://github.com/sirkirby/unifi-mcp.git
cd 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 environment variables (or create a .env file). If you used /unifi-protect:setup, this is already done.

# Server-specific variables (recommended)
UNIFI_PROTECT_HOST=192.168.1.1      # Controller IP or hostname
UNIFI_PROTECT_USERNAME=admin         # Local admin username
UNIFI_PROTECT_PASSWORD=your-password # Admin password
# Optional:
# UNIFI_PROTECT_API_KEY=             # UniFi Protect API key for selected settings capabilities
# UNIFI_PROTECT_PORT=443             # Controller HTTPS port
# UNIFI_PROTECT_VERIFY_SSL=false     # SSL certificate verification

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

# stdio transport (default -- for Claude Desktop, LM Studio, etc.)
unifi-protect-mcp

# Docker
docker 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:

{
  "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:

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

After:

{ "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.

# Standard call
protect_list_events(limit=50)

# Compact — recommended for digests, summaries, and context-constrained workflows
protect_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

  • Configuration -- Full env var reference, YAML config, Protect-specific options
  • Permissions -- Permission system, category defaults, how to enable mutations
  • Tool Catalog -- All 61 tools organized by category
  • Event Streaming -- Real-time event architecture, MCP resources, polling
  • Troubleshooting -- Connection issues, SSL, missing tools

Development

cd apps/protect
make test         # Run tests
make lint         # Lint
make format       # Format
make manifest     # Regenerate tools_manifest.json
make pre-commit   # All of the above

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

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unifi_protect_mcp-0.7.9.tar.gz (51.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unifi_protect_mcp-0.7.9-py3-none-any.whl (64.5 kB view details)

Uploaded Python 3

File details

Details for the file unifi_protect_mcp-0.7.9.tar.gz.

File metadata

  • Download URL: unifi_protect_mcp-0.7.9.tar.gz
  • Upload date:
  • Size: 51.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for unifi_protect_mcp-0.7.9.tar.gz
Algorithm Hash digest
SHA256 ef5de85036e88e4094eb1b7966becb23ae80883a2716f2747bcf82d7820bcb9e
MD5 5b2e24c63ae1568c01f20dcc79bcf548
BLAKE2b-256 8c3b2212ae21e0370ffae7d0e703ed4d7c9f7a7d8eb2b7bcae90d770d6dc013f

See more details on using hashes here.

Provenance

The following attestation bundles were made for unifi_protect_mcp-0.7.9.tar.gz:

Publisher: release-protect.yml on sirkirby/unifi-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unifi_protect_mcp-0.7.9-py3-none-any.whl.

File metadata

File hashes

Hashes for unifi_protect_mcp-0.7.9-py3-none-any.whl
Algorithm Hash digest
SHA256 f87c6ada3f890c44424135dce25aeeed6de84c9863dcfaac90f13622036695e5
MD5 bf71288b19f582909f3b72c3def19ce1
BLAKE2b-256 7f75a699cad0eba2c254e0bc147a95eace27ad81762f9db067bde78880fa231d

See more details on using hashes here.

Provenance

The following attestation bundles were made for unifi_protect_mcp-0.7.9-py3-none-any.whl:

Publisher: release-protect.yml on sirkirby/unifi-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.7.9 This release

2 files

0.7.8

2 files

0.7.7

2 files

0.7.6

2 files

0.7.5

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.11

2 files

0.4.10

2 files

0.4.9

2 files

0.4.8

2 files

0.4.7

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.12

2 files

0.3.11

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page