An MCP server that leverages official UniFi API
Valid MCP server (1 strong, 2 medium validity signals). No known CVEs in dependencies. Package registry verified. Imported from the Official MCP Registry.
3 files analyzed Β· 1 issue found
Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.
Set these up before or after installing:
Environment variable: UNIFI_HOST
Environment variable: UNIFI_USERNAME
Environment variable: UNIFI_PASSWORD
Environment variable: UNIFI_PORT
Environment variable: UNIFI_VERIFY_SSL
Environment variable: UNIFI_SITE
Add this to your MCP configuration file:
{
"mcpServers": {
"io-github-enuno-unifi-mcp-server": {
"env": {
"UNIFI_HOST": "your-unifi-host-here",
"UNIFI_PORT": "your-unifi-port-here",
"UNIFI_SITE": "your-unifi-site-here",
"UNIFI_PASSWORD": "your-unifi-password-here",
"UNIFI_USERNAME": "your-unifi-username-here",
"UNIFI_VERIFY_SSL": "your-unifi-verify-ssl-here"
},
"args": [
"-y",
"unifi-mcp-server"
],
"command": "npx"
}
}
}From the project's GitHub README.
A Model Context Protocol (MCP) server that exposes the UniFi Network Controller API, enabling AI agents and applications to interact with UniFi network infrastructure in a standardized way.
Current Stable Release: 0.2.4 (2026-02-19) π
Installation:
pip install unifi-mcp-server
What's New in v0.2.4 (Hotfix):
ImportError: cannot import 'config' from 'agnost' prevented the server from starting for all users, even when AGNOST_ENABLED=false. The fix moves agnost imports inside the conditional block with graceful error handling.agnost==0.1.13 from the version range (>=0.1.12,!=0.1.13)Previous Release - v0.2.3 (2026-02-18):
Previous Release - v0.2.2 (2026-02-16):
Major Release - v0.2.0 (2026-01-25):
See CHANGELOG.md for complete release notes and VERIFICATION_REPORT.md for detailed verification.
The UniFi MCP Server supports three distinct API modes with different capabilities:
Full feature support - Direct access to your UniFi gateway.
UNIFI_API_TYPE=local + UNIFI_LOCAL_HOST=<gateway-ip>Site-centric access - UniFi cloud API with limited but functional read-only capabilities.
siteId, _id, name, or meta.name)UNIFI_SITE_MANAGER_ENABLED=trueUNIFI_API_TYPE=cloud-ea + optional UNIFI_SITE_MANAGER_ENABLED=trueLimited to aggregate statistics - UniFi stable v1 cloud API.
UNIFI_API_TYPE=cloud-v1π‘ Recommendation: Use Local Gateway API (UNIFI_API_TYPE=local) for full functionality. Cloud APIs are suitable only for high-level monitoring dashboards.
confirm=True flagdry_run=Trueaudit.log for complianceThe UniFi MCP Server is published on PyPI and can be installed with pip or uv:
# Install from PyPI
pip install unifi-mcp-server
# Or using uv (faster)
uv pip install unifi-mcp-server
# Install specific version
pip install unifi-mcp-server==0.2.0
After installation, the unifi-mcp-server command will be available globally.
PyPI Package: https://pypi.org/project/unifi-mcp-server/
# Pull the latest release
docker pull ghcr.io/enuno/unifi-mcp-server:0.2.4
# Multi-architecture support: amd64, arm64, arm/v7
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository
git clone https://github.com/enuno/unifi-mcp-server.git
cd unifi-mcp-server
# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev]"
# Clone the repository
git clone https://github.com/enuno/unifi-mcp-server.git
cd unifi-mcp-server
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -e ".[dev]"
The recommended way to run the UniFi MCP Server with full monitoring capabilities:
# 1. Copy and configure environment variables
cp .env.docker.example .env
# Edit .env with your UNIFI_API_KEY and AGNOST_ORG_ID
# 2. Start all services (MCP Server + Redis + MCP Toolbox)
docker-compose up -d
# 3. Check service status
docker-compose ps
# 4. View logs
docker-compose logs -f unifi-mcp
# 5. Access MCP Toolbox dashboard
open http://localhost:8080
# 6. Stop all services
docker-compose down
Included Services:
See MCP_TOOLBOX.md for detailed Toolbox documentation.
For standalone Docker usage (not with MCP clients):
# Pull the image
docker pull ghcr.io/enuno/unifi-mcp-server:latest
# Run the container in background (Cloud API)
# Note: -i flag keeps stdin open for STDIO transport
docker run -i -d \
--name unifi-mcp \
-e UNIFI_API_KEY=your-api-key \
-e UNIFI_API_TYPE=cloud \
ghcr.io/enuno/unifi-mcp-server:latest
# OR run with local gateway proxy
docker run -i -d \
--name unifi-mcp \
-e UNIFI_API_KEY=your-api-key \
-e UNIFI_API_TYPE=local \
-e UNIFI_HOST=192.168.2.1 \
ghcr.io/enuno/unifi-mcp-server:latest
# Check container status
docker ps --filter name=unifi-mcp
# View logs
docker logs unifi-mcp
# Stop and remove
docker rm -f unifi-mcp
Note: For MCP client integration (Claude Desktop, etc.), see the Usage section below for the correct configuration without -d flag.
git clone https://github.com/enuno/unifi-mcp-server.git
cd unifi-mcp-server
Using uv (Recommended):
# Install uv if not already installed
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create virtual environment
uv venv
# Activate virtual environment
source .venv/bin/activate # Linux/macOS
# Or on Windows: .venv\Scripts\activate
# Install development dependencies
uv pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
pre-commit install --hook-type commit-msg
Using pip:
# Create virtual environment
python -m venv .venv
# Activate virtual environment
source .venv/bin/activate # Linux/macOS
# Or on Windows: .venv\Scripts\activate
# Upgrade pip
pip install --upgrade pip
# Install development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
pre-commit install --hook-type commit-msg
# Copy example configuration
cp .env.example .env
# Edit .env with your UniFi credentials
# Required: UNIFI_API_KEY
# Recommended: UNIFI_API_TYPE=local, UNIFI_LOCAL_HOST=<gateway-ip>
# Run all unit tests
pytest tests/unit/ -v
# Run with coverage report
pytest tests/unit/ --cov=src --cov-report=html --cov-report=term-missing
# View coverage report
open htmlcov/index.html # macOS
# Or: xdg-open htmlcov/index.html # Linux
# Development mode with MCP Inspector
uv run mcp dev src/main.py
# Production mode
uv run python -m src.main
# The MCP Inspector will be available at http://localhost:5173
# Install build tools
uv pip install build
# Build wheel and source distribution
python -m build
# Output: dist/unifi_mcp_server-0.2.0-py3-none-any.whl
# dist/unifi_mcp_server-0.2.0.tar.gz
# Build for current architecture
docker build -t unifi-mcp-server:0.2.0 .
# Build multi-architecture (requires buildx)
docker buildx create --use
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-t ghcr.io/enuno/unifi-mcp-server:0.2.0 \
--push .
# Test the image
docker run -i --rm \
-e UNIFI_API_KEY=your-key \
-e UNIFI_API_TYPE=cloud \
unifi-mcp-server:0.2.0
# Install twine
uv pip install twine
# Check distribution
twine check dist/*
# Upload to PyPI (requires PyPI account and token)
twine upload dist/*
# Or upload to Test PyPI first
twine upload --repository testpypi dist/*
# Ensure package.json is up to date
cat package.json
# Login to npm (if not already)
npm login
# Publish package
npm publish --access public
# Verify publication
npm view unifi-mcp-server
# Install mcp-publisher
brew install mcp-publisher
# Or: curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher && sudo mv mcp-publisher /usr/local/bin/
# Authenticate with GitHub (for io.github.enuno namespace)
mcp-publisher login github
# Publish to registry (requires npm package published first)
mcp-publisher publish
# Verify
curl "https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.enuno/unifi-mcp-server"
See docs/RELEASE_PROCESS.md for the complete release workflow, including automated GitHub Actions, manual PyPI/npm publishing, and MCP registry submission.
.env fileCreate a .env file in the project root:
# Required: Your UniFi API Key
UNIFI_API_KEY=your-api-key-here
# API Mode Selection (choose one):
# - 'local': Full access via local gateway (RECOMMENDED)
# - 'cloud-ea': Early Access cloud API (limited to statistics)
# - 'cloud-v1': Stable v1 cloud API (limited to statistics)
UNIFI_API_TYPE=local
# Local Gateway Configuration (for UNIFI_API_TYPE=local)
UNIFI_LOCAL_HOST=192.168.2.1
UNIFI_LOCAL_PORT=443
UNIFI_LOCAL_VERIFY_SSL=false
# Cloud API Configuration (for cloud-ea or cloud-v1)
# UNIFI_CLOUD_API_URL=https://api.ui.com
# Site Manager API (cloud-ea only, optional)
# UNIFI_SITE_MANAGER_ENABLED=true
# Optional settings
UNIFI_DEFAULT_SITE=default
# Redis caching (optional - improves performance)
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
# REDIS_PASSWORD=your-password # If Redis requires authentication
# Webhook support (optional - for real-time events)
WEBHOOK_SECRET=your-webhook-secret-here
# Performance tracking with agnost.ai (optional - for analytics)
# Get your Organization ID from https://app.agnost.ai
# AGNOST_ENABLED=true
# AGNOST_ORG_ID=your-organization-id-here
# AGNOST_ENDPOINT=https://api.agnost.ai
# AGNOST_DISABLE_INPUT=false # Set to true to disable input tracking
# AGNOST_DISABLE_OUTPUT=false # Set to true to disable output tracking
See .env.example for all available options.
# Development mode with MCP Inspector
uv run mcp dev src/main.py
# Production mode
uv run python src/main.py
The MCP Inspector will be available at http://localhost:5173 for interactive testing.
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
After installing via pip install unifi-mcp-server:
{
"mcpServers": {
"unifi": {
"command": "unifi-mcp-server",
"env": {
"UNIFI_API_KEY": "your-api-key-here",
"UNIFI_API_TYPE": "local",
"UNIFI_LOCAL_HOST": "192.168.2.1"
}
}
}
}
For cloud API access, use:
{
"mcpServers": {
"unifi": {
"command": "unifi-mcp-server",
"env": {
"UNIFI_API_KEY": "your-api-key-here",
"UNIFI_API_TYPE": "cloud-v1"
}
}
}
}
{
"mcpServers": {
"unifi": {
"command": "uvx",
"args": ["unifi-mcp-server"],
"env": {
"UNIFI_API_KEY": "your-api-key-here",
"UNIFI_API_TYPE": "local",
"UNIFI_LOCAL_HOST": "192.168.2.1"
}
}
}
}
{
"mcpServers": {
"unifi": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"UNIFI_API_KEY=your-api-key-here",
"-e",
"UNIFI_API_TYPE=cloud",
"ghcr.io/enuno/unifi-mcp-server:latest"
]
}
}
}
Important: Do NOT use -d (detached mode) in MCP client configurations. The MCP client needs to maintain a persistent stdin/stdout connection to the container.
Add to your Cursor MCP configuration (mcp.json via "View: Open MCP Settings β New MCP Server"):
After installing via pip install unifi-mcp-server:
{
"mcpServers": {
"unifi-mcp": {
"command": "unifi-mcp-server",
"env": {
"UNIFI_API_KEY": "your-api-key-here",
"UNIFI_API_TYPE": "local",
"UNIFI_LOCAL_HOST": "192.168.2.1",
"UNIFI_LOCAL_VERIFY_SSL": "false"
},
"disabled": false
}
}
}
{
"mcpServers": {
"unifi-mcp": {
"command": "uvx",
"args": ["unifi-mcp-server"],
"env": {
"UNIFI_API_KEY": "your-api-key-here",
"UNIFI_API_TYPE": "local",
"UNIFI_LOCAL_HOST": "192.168.2.1"
},
"disabled": false
}
}
}
{
"mcpServers": {
"unifi-mcp": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"--name", "unifi-mcp-server",
"-e", "UNIFI_API_KEY=your_unifi_api_key_here",
"-e", "UNIFI_API_TYPE=local",
"-e", "UNIFI_LOCAL_HOST=192.168.2.1",
"-e", "UNIFI_LOCAL_VERIFY_SSL=false",
"ghcr.io/enuno/unifi-mcp-server:latest"
],
"disabled": false
}
}
}
Configuration Notes:
UNIFI_API_KEY with your actual UniFi API keyUNIFI_API_TYPE=local and provide UNIFI_LOCAL_HOSTUNIFI_API_TYPE=cloud-v1 or cloud-eaThe UniFi MCP Server works with any MCP-compatible client. Here are generic configuration patterns:
After installing from PyPI (pip install unifi-mcp-server):
{
"mcpServers": {
"unifi": {
"command": "unifi-mcp-server",
"env": {
"UNIFI_API_KEY": "your-api-key-here",
"UNIFI_API_TYPE": "local",
"UNIFI_LOCAL_HOST": "192.168.2.1"
}
}
}
}
{
"mcpServers": {
"unifi": {
"command": "uvx",
"args": ["unifi-mcp-server"],
"env": {
"UNIFI_API_KEY": "your-api-key-here",
"UNIFI_API_TYPE": "local",
"UNIFI_LOCAL_HOST": "192.168.2.1"
}
}
}
}
{
"mcpServers": {
"unifi": {
"command": "python3",
"args": ["-m", "src.main"],
"env": {
"UNIFI_API_KEY": "your-api-key-here",
"UNIFI_API_TYPE": "local",
"UNIFI_LOCAL_HOST": "192.168.2.1"
}
}
}
}
Environment Variables (All Clients):
UNIFI_API_KEY (required): Your UniFi API key from unifi.ui.comUNIFI_API_TYPE (required): local, cloud-v1, or cloud-eaUNIFI_LOCAL_HOST: Gateway IP (e.g., 192.168.2.1)UNIFI_LOCAL_PORT: Gateway port (default: 443)UNIFI_LOCAL_VERIFY_SSL: SSL verification (default: false)UNIFI_CLOUD_API_URL: Cloud API URL (default: https://api.ui.com)UNIFI_DEFAULT_SITE: Default site ID (default: default)UNIFI_SITE_MANAGER_ENABLED: Enable Site Manager multi-site tools for cloud-ea (default: false)from mcp import MCP
import asyncio
async def main():
mcp = MCP("unifi-mcp-server")
# List all devices
devices = await mcp.call_tool("list_devices", {
"site_id": "default"
})
for device in devices:
print(f"{device['name']}: {device['status']}")
# Get network information via resource
networks = await mcp.read_resource("sites://default/networks")
print(f"Networks: {len(networks)}")
# Create a guest WiFi network with VLAN isolation
wifi = await mcp.call_tool("create_wlan", {
"site_id": "default",
"name": "Guest WiFi",
"security": "wpapsk",
"password": "GuestPass123!",
"is_guest": True,
"vlan_id": 100,
"confirm": True # Required for safety
})
print(f"Created WiFi: {wifi['name']}")
# Get DPI statistics for top bandwidth users
top_apps = await mcp.call_tool("list_top_applications", {
"site_id": "default",
"limit": 5,
"time_range": "24h"
})
for app in top_apps:
gb = app['total_bytes'] / 1024**3
print(f"{app['application']}: {gb:.2f} GB")
# Create Zone-Based Firewall zones (UniFi Network 9.0+)
lan_zone = await mcp.call_tool("create_firewall_zone", {
"site_id": "default",
"name": "LAN",
"description": "Trusted local network",
"confirm": True
})
iot_zone = await mcp.call_tool("create_firewall_zone", {
"site_id": "default",
"name": "IoT",
"description": "Internet of Things devices",
"confirm": True
})
# Set zone-to-zone policy (LAN can access IoT, but IoT cannot access LAN)
await mcp.call_tool("update_zbf_policy", {
"site_id": "default",
"source_zone_id": lan_zone["_id"],
"destination_zone_id": iot_zone["_id"],
"action": "accept",
"confirm": True
})
asyncio.run(main())
See API.md for complete API documentation, including:
# Install development dependencies
uv pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
pre-commit install --hook-type commit-msg
# Run all tests
pytest tests/unit/
# Run with coverage report
pytest tests/unit/ --cov=src --cov-report=html --cov-report=term-missing
# Run specific test file
pytest tests/unit/test_zbf_tools.py -v
# Run tests for new v0.2.0 features
pytest tests/unit/test_new_models.py tests/unit/test_zbf_tools.py tests/unit/test_traffic_flow_tools.py
# Run only unit tests (fast)
pytest -m unit
# Run only integration tests (requires UniFi controller)
pytest -m integration
Current Test Coverage (v0.2.0):
By Module Category:
Top Coverage Performers (>95%):
See VERIFICATION_REPORT.md for complete coverage details and TESTING_PLAN.md for testing strategy.
# Format code
black src/ tests/
isort src/ tests/
# Lint code
ruff check src/ tests/ --fix
# Type check
mypy src/
# Run all pre-commit checks
pre-commit run --all-files
# Start development server with inspector
uv run mcp dev src/main.py
# Open http://localhost:5173 in your browser
unifi-mcp-server/
βββ .github/
β βββ workflows/ # CI/CD pipelines (CI, security, release)
βββ .claude/
β βββ commands/ # Custom slash commands for development
βββ src/
β βββ main.py # MCP server entry point (77 tools registered)
β βββ cache.py # Redis caching implementation
β βββ config/ # Configuration management
β βββ api/ # UniFi API client with rate limiting
β βββ models/ # Pydantic data models
β β βββ zbf.py # Zone-Based Firewall models
β βββ tools/ # MCP tool definitions
β β βββ clients.py # Client query tools
β β βββ devices.py # Device query tools
β β βββ networks.py # Network query tools
β β βββ sites.py # Site query tools
β β βββ firewall.py # Firewall management (Phase 4)
β β βββ firewall_zones.py # Zone-Based Firewall zone management (v0.1.4)
β β βββ zbf_matrix.py # Zone-Based Firewall policy matrix (v0.1.4)
β β βββ network_config.py # Network configuration (Phase 4)
β β βββ device_control.py # Device control (Phase 4)
β β βββ client_management.py # Client management (Phase 4)
β β βββ wifi.py # WiFi/SSID management (Phase 5)
β β βββ port_forwarding.py # Port forwarding (Phase 5)
β β βββ dpi.py # DPI statistics (Phase 5)
β βββ resources/ # MCP resource definitions
β βββ webhooks/ # Webhook receiver and handlers (Phase 5)
β βββ utils/ # Utility functions and validators
βββ tests/
β βββ unit/ # Unit tests (213 tests, 37% coverage)
β βββ integration/ # Integration tests (planned)
β βββ performance/ # Performance benchmarks (planned)
βββ docs/ # Additional documentation
β βββ AI-Coding/ # AI coding guidelines
βββ .env.example # Environment variable template
βββ pyproject.toml # Project configuration
βββ README.md # This file
βββ API.md # Complete API documentation
βββ DEVELOPMENT_PLAN.md # Development roadmap
βββ docs/archive/ # Archived planning & session docs
βββ CONTRIBUTING.md # Contribution guidelines
βββ SECURITY.md # Security policy and best practices
βββ AGENTS.md # AI agent guidelines
βββ LICENSE # Apache 2.0 License
We welcome contributions from both human developers and AI coding assistants! Please see:
git checkout -b feature/your-feature-namepytest && pre-commit run --all-filesfeat: add new featureFound a bug? Issues with [Bug] in the title are automatically analyzed by our AI bug handler:
See CONTRIBUTING.md for more details.
Security is a top priority. Please see SECURITY.md for:
Never commit credentials or sensitive data!
All 7 Feature Phases Complete - 74 MCP Tools
Phase 3: Read-Only Operations (16 tools)
Phase 4: Mutating Operations with Safety (13 tools)
Phase 5: Advanced Features (11 tools)
Phase 6: Zone-Based Firewall (12 working tools)
Phase 7: Traffic Flow Monitoring (15 tools) β COMPLETE
ZBF Implementation Notes (Verified 2025-11-18):
Phase 1: QoS Enhancements (11 tools) β
Phase 2: Backup & Restore (8 tools) β
Phase 3: Multi-Site Aggregation (4 tools) β
Phase 4: ACL & Traffic Filtering (7 tools) β
Phase 5: Site Management Enhancements (9 tools) β
Phase 6: RADIUS & Guest Portal (6 tools) β
Phase 7: Network Topology (5 tools) β
Quality Achievements:
Total: 74 MCP tools + Comprehensive documentation and verification
This project is inspired by and builds upon:
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
io.github.enuno/unifi-mcp-server at https://registry.modelcontextprotocol.ioIf you find this project useful, please consider starring it on GitHub to help others discover it!
Documentation truncated β see the full README on GitHub.
Be the first to review this server!
by Modelcontextprotocol Β· Developer Tools
Read, search, and manipulate Git repositories programmatically
by Toleno Β· Developer Tools
Toleno Network MCP Server β Manage your Toleno mining account with Claude AI using natural language.
by mcp-marketplace Β· Developer Tools
Create, build, and publish Python MCP servers to PyPI β conversationally.
by Microsoft Β· Content & Media
Convert files (PDF, Word, Excel, images, audio) to Markdown for LLM consumption
by mcp-marketplace Β· Developer Tools
Scaffold, build, and publish TypeScript MCP servers to npm β conversationally
by mcp-marketplace Β· Finance
Free stock data and market news for any MCP-compatible AI assistant.