UniFi Protect

Developer tools

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

Your AI app calls the UniFi Protect MCP server, which does the developer tools work and sends the result back to the chat.

About UniFi Protect

UniFi Protect is a community MCP server from sirkirby, filed in our directory under developer tools. Manage UniFi Protect cameras, events, recordings, and smart detections via MCP.

UniFi Protect runs on your own machine: your AI app starts it with the command uvx unifi-protect-mcp==0.1.6 and talks to it over standard input and output. It needs UNIFI_HOST, UNIFI_USERNAME and UNIFI_PASSWORD set before UniFi Protect starts.

UniFi Protect is listed in the official MCP registry as io.github.sirkirby/unifi-protect-mcp, version 0.1.6.

At a glance

Publisher
sirkirby (community)
Runs
Locally on your machine
Install from
Python package on PyPI: unifi-protect-mcp
Written in
Python
License
MIT
GitHub stars
1,174
Official MCP registry
io.github.sirkirby/unifi-protect-mcp

How to set up UniFi Protect

  1. Install uv on the machine that runs your AI app, because UniFi Protect starts with uvx and fetches its Python package on first run.
  2. Create UNIFI_HOST, UNIFI_USERNAME and UNIFI_PASSWORD for UniFi Protect in the connected service's own settings, scoped to the smallest permissions the job needs.
  3. Add UniFi Protect to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the UniFi Protect tools to confirm the connection.
  5. Run one read-only task with UniFi Protect first, and keep your app asking before each tool call until the results look right.

UniFi Protect compared with similar servers

  • QGIS by jjsantos01 has fewer GitHub stars than UniFi Protect (1.2k against 1.2k); both are community servers, and both run locally.
  • UniFi Network by sirkirby has fewer GitHub stars than UniFi Protect (1.2k against 1.2k); both are community servers, and both run locally.
  • CPU Performance Engineering by usamahz has fewer GitHub stars than UniFi Protect (1.2k against 1.2k); both are community servers, and both run locally.

Before you connect UniFi Protect

  • Give UniFi Protect its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each UniFi Protect tool call until you trust what it does with them.
  • Treat text that UniFi Protect fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for UniFi Protect on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for UniFi Protect

How marketing and sales teams put UniFi Protect to work, by company size. Pick the size closest to yours and start UniFi Protect on one use case.

Small business

  • A small business with a developer can use UniFi Protect to ship site and tracking fixes faster, with the AI reading the code it changes.
  • Technical founders can ask UniFi Protect to explain and fix a marketing site issue without context switching between tools.
  • UniFi Protect runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineers can use UniFi Protect to build landing pages, tracking and integrations in fewer cycles, with reviews kept in the normal flow.
  • Marketing ops engineers can connect UniFi Protect to keep scripts and automations documented and versioned as they change.
  • Start UniFi Protect on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprise engineering teams can roll out UniFi Protect with repo scopes and audit logs, so agents work only where they are allowed.
  • Platform teams can standardize on UniFi Protect so web and marketing engineering share one reviewed way of working with AI.
  • UniFi Protect is a community server, so have security review the code and pin a version before UniFi Protect touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

UniFi Protect README

From sirkirby/unifi-mcp on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

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.

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:

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
# 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 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.

# 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=             # 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
# UNIFI_PROTECT_SSL_FINGERPRINT=      # Pin the controller certificate by SHA-256

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 UNIFI_API_KEY, when Protect runs on the console named by UNIFI_HOST) 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. On newer server releases, the shared username, password and API key are used only when UNIFI_PROTECT_HOST is unset or names the same console as UNIFI_HOST; a server pointed at another console needs its own UNIFI_PROTECT_* credentials (see Configuration).

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, *_batch_cancel, 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, crossing line and smart-detect zone names
  • 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

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

Questions about UniFi Protect

What is the UniFi Protect MCP server?

Manage UniFi Protect cameras, events, recordings, and smart detections via MCP. UniFi Protect is maintained by sirkirby on GitHub at sirkirby/unifi-mcp, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the UniFi Protect MCP server?

Add UniFi Protect to your AI app's MCP config with the command uvx unifi-protect-mcp==0.1.6. In Claude Code, run claude mcp add --transport stdio sirkirby-protect -- uvx unifi-protect-mcp==0.1.6. To run UniFi Protect this way you need uv installed.

Does UniFi Protect need an API key?

Yes. UniFi Protect expects UNIFI_HOST, UNIFI_USERNAME and UNIFI_PASSWORD to be set. Create the key for UniFi Protect in the connected service's own settings, give it the smallest permissions the job needs, and keep it out of shared config files.

Is UniFi Protect an official MCP server?

No. UniFi Protect is a community server maintained by sirkirby. Community servers can be excellent; read the code and the open issues before you give UniFi Protect access to company data.

What license is UniFi Protect under?

UniFi Protect is released under the MIT license, according to its GitHub repository. The license covers the code of UniFi Protect; the service it connects to has its own terms.