iflow-mcp_enuno-unifi-mcp-server 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. iflow_mcp_enuno_unifi_mcp_server-0.2.1.dist-info/METADATA +1282 -0
  2. iflow_mcp_enuno_unifi_mcp_server-0.2.1.dist-info/RECORD +81 -0
  3. iflow_mcp_enuno_unifi_mcp_server-0.2.1.dist-info/WHEEL +4 -0
  4. iflow_mcp_enuno_unifi_mcp_server-0.2.1.dist-info/entry_points.txt +2 -0
  5. iflow_mcp_enuno_unifi_mcp_server-0.2.1.dist-info/licenses/LICENSE +201 -0
  6. src/__init__.py +3 -0
  7. src/__main__.py +6 -0
  8. src/api/__init__.py +5 -0
  9. src/api/client.py +727 -0
  10. src/api/site_manager_client.py +176 -0
  11. src/cache.py +483 -0
  12. src/config/__init__.py +5 -0
  13. src/config/config.py +321 -0
  14. src/main.py +2234 -0
  15. src/models/__init__.py +126 -0
  16. src/models/acl.py +41 -0
  17. src/models/backup.py +272 -0
  18. src/models/client.py +74 -0
  19. src/models/device.py +53 -0
  20. src/models/dpi.py +50 -0
  21. src/models/firewall_policy.py +123 -0
  22. src/models/firewall_zone.py +28 -0
  23. src/models/network.py +62 -0
  24. src/models/qos_profile.py +458 -0
  25. src/models/radius.py +141 -0
  26. src/models/reference_data.py +34 -0
  27. src/models/site.py +59 -0
  28. src/models/site_manager.py +120 -0
  29. src/models/topology.py +138 -0
  30. src/models/traffic_flow.py +137 -0
  31. src/models/traffic_matching_list.py +56 -0
  32. src/models/voucher.py +42 -0
  33. src/models/vpn.py +73 -0
  34. src/models/wan.py +48 -0
  35. src/models/zbf_matrix.py +49 -0
  36. src/resources/__init__.py +8 -0
  37. src/resources/clients.py +111 -0
  38. src/resources/devices.py +102 -0
  39. src/resources/networks.py +93 -0
  40. src/resources/site_manager.py +64 -0
  41. src/resources/sites.py +86 -0
  42. src/tools/__init__.py +25 -0
  43. src/tools/acls.py +328 -0
  44. src/tools/application.py +42 -0
  45. src/tools/backups.py +1173 -0
  46. src/tools/client_management.py +505 -0
  47. src/tools/clients.py +203 -0
  48. src/tools/device_control.py +325 -0
  49. src/tools/devices.py +354 -0
  50. src/tools/dpi.py +241 -0
  51. src/tools/dpi_tools.py +89 -0
  52. src/tools/firewall.py +417 -0
  53. src/tools/firewall_policies.py +430 -0
  54. src/tools/firewall_zones.py +515 -0
  55. src/tools/network_config.py +388 -0
  56. src/tools/networks.py +190 -0
  57. src/tools/port_forwarding.py +263 -0
  58. src/tools/qos.py +1070 -0
  59. src/tools/radius.py +763 -0
  60. src/tools/reference_data.py +107 -0
  61. src/tools/site_manager.py +466 -0
  62. src/tools/site_vpn.py +95 -0
  63. src/tools/sites.py +187 -0
  64. src/tools/topology.py +406 -0
  65. src/tools/traffic_flows.py +1062 -0
  66. src/tools/traffic_matching_lists.py +371 -0
  67. src/tools/vouchers.py +249 -0
  68. src/tools/vpn.py +76 -0
  69. src/tools/wans.py +30 -0
  70. src/tools/wifi.py +498 -0
  71. src/tools/zbf_matrix.py +326 -0
  72. src/utils/__init__.py +88 -0
  73. src/utils/audit.py +213 -0
  74. src/utils/exceptions.py +114 -0
  75. src/utils/helpers.py +159 -0
  76. src/utils/logger.py +105 -0
  77. src/utils/sanitize.py +244 -0
  78. src/utils/validators.py +160 -0
  79. src/webhooks/__init__.py +6 -0
  80. src/webhooks/handlers.py +196 -0
  81. src/webhooks/receiver.py +290 -0
@@ -0,0 +1,1282 @@
1
+ Metadata-Version: 2.4
2
+ Name: iflow-mcp_enuno-unifi-mcp-server
3
+ Version: 0.2.1
4
+ Summary: A Model Context Protocol (MCP) server for UniFi Network API
5
+ Project-URL: Homepage, https://github.com/enuno/unifi-mcp-server
6
+ Project-URL: Repository, https://github.com/enuno/unifi-mcp-server
7
+ Project-URL: Issues, https://github.com/enuno/unifi-mcp-server/issues
8
+ Author-email: enuno <noreply@github.com>
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: api,automation,mcp,network,unifi
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Topic :: System :: Networking
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: agnost>=0.1.0
23
+ Requires-Dist: fastmcp>=0.1.0
24
+ Requires-Dist: httpx>=0.27.0
25
+ Requires-Dist: mcp[cli]>=1.16.0
26
+ Requires-Dist: pydantic-settings>=2.0.0
27
+ Requires-Dist: pydantic>=2.0.0
28
+ Requires-Dist: python-dotenv>=1.0.0
29
+ Requires-Dist: pyyaml>=6.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: bandit>=1.7.0; extra == 'dev'
32
+ Requires-Dist: black>=24.0.0; extra == 'dev'
33
+ Requires-Dist: flake8>=7.0.0; extra == 'dev'
34
+ Requires-Dist: isort>=5.13.0; extra == 'dev'
35
+ Requires-Dist: mypy>=1.8.0; extra == 'dev'
36
+ Requires-Dist: pre-commit>=3.6.0; extra == 'dev'
37
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
38
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
39
+ Requires-Dist: pytest-mock>=3.12.0; extra == 'dev'
40
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
41
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
42
+ Requires-Dist: safety>=3.0.0; extra == 'dev'
43
+ Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
44
+ Requires-Dist: types-redis>=4.6.0; extra == 'dev'
45
+ Requires-Dist: types-requests>=2.31.0; extra == 'dev'
46
+ Description-Content-Type: text/markdown
47
+
48
+ # <img src="https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/unifi-dark.png" alt="UniFi Dark Logo" width="40" /> UniFi MCP Server
49
+
50
+ [![CI](https://github.com/enuno/unifi-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/enuno/unifi-mcp-server/actions/workflows/ci.yml)
51
+ [![Security](https://github.com/enuno/unifi-mcp-server/actions/workflows/security.yml/badge.svg)](https://github.com/enuno/unifi-mcp-server/actions/workflows/security.yml)
52
+ [![codecov](https://codecov.io/github/enuno/unifi-mcp-server/graph/badge.svg?token=ZD314B59CE)](https://codecov.io/github/enuno/unifi-mcp-server)
53
+ [![PyPI](https://img.shields.io/pypi/v/unifi-mcp-server.svg)](https://pypi.org/project/unifi-mcp-server/)
54
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
55
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
56
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/enuno/unifi-mcp-server)
57
+
58
+ 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.
59
+
60
+ ## 📋 Version Notice
61
+
62
+ **Current Stable Release**: v0.2.1 (2026-01-26) 🎉
63
+
64
+ **Installation:**
65
+
66
+ ```bash
67
+ pip install unifi-mcp-server
68
+ ```
69
+
70
+ **What's New in v0.2.1:**
71
+
72
+ - 🔧 **CI/CD Improvements** - Fixed all CI/CD pipeline failures
73
+ - ✅ **Test Infrastructure** - Proper pytest configuration with integration markers
74
+ - 🧪 **990 Tests Passing** - All unit tests passing across Python 3.10, 3.11, 3.12
75
+ - 🔍 **Integration Tests** - 24 integration tests validated on local APIs
76
+ - 📋 **Code Quality** - Black formatting, Ruff linting, pre-commit hooks all passing
77
+
78
+ This is a maintenance release focused on improving the development and testing infrastructure. All 74 MCP tools from v0.2.0 remain unchanged.
79
+
80
+ **Previous Major Release - v0.2.0 (2026-01-25):**
81
+
82
+ - ✨ **74 MCP Tools** - All 7 feature phases complete
83
+ - 📦 **Published on PyPI** - Easy installation with pip/uv
84
+ - 📊 **QoS Management** - Traffic prioritization and bandwidth control (11 tools)
85
+ - 💾 **Backup & Restore** - Automated scheduling and verification (8 tools)
86
+ - 🌐 **Multi-Site Aggregation** - Cross-site analytics and management (4 tools)
87
+ - 🔒 **ACL & Traffic Filtering** - Advanced traffic control (7 tools)
88
+ - 🏢 **Site Management** - Multi-site provisioning and VPN (9 tools)
89
+ - 🔐 **RADIUS & Guest Portal** - 802.1X authentication (6 tools)
90
+ - 🗺️ **Network Topology** - Complete topology mapping and visualization (5 tools)
91
+ - 🧪 **990 Tests** - 78.18% coverage with comprehensive validation
92
+ - 📖 **30+ Example Prompts** - AI assistant usage examples
93
+
94
+ See [CHANGELOG.md](CHANGELOG.md) for complete release notes and [VERIFICATION_REPORT.md](VERIFICATION_REPORT.md) for detailed verification.
95
+
96
+ ## 🌐 API Mode Support
97
+
98
+ The UniFi MCP Server supports **three distinct API modes** with different capabilities:
99
+
100
+ ### Local Gateway API (Recommended) ✅
101
+
102
+ **Full feature support** - Direct access to your UniFi gateway.
103
+
104
+ - ✅ **All Features Available**: Device management, client control, network configuration, firewall rules, WiFi management
105
+ - ✅ **Real-time Data**: Access to live device/client statistics and detailed information
106
+ - ✅ **Configuration Changes**: Create, update, delete networks, VLANs, firewall rules, SSIDs
107
+ - 📍 **Requirement**: Local network access to your UniFi gateway (e.g., 192.168.1.1)
108
+ - ⚙️ **Configuration**: `UNIFI_API_TYPE=local` + `UNIFI_LOCAL_HOST=<gateway-ip>`
109
+
110
+ ### Cloud Early Access API ⚠️
111
+
112
+ **Limited to aggregate statistics** - UniFi cloud API in testing phase.
113
+
114
+ - ✅ **Site Information**: List sites with aggregate statistics (device counts, client counts, bandwidth)
115
+ - ⚠️ **No Individual Device/Client Access**: Cannot query specific devices or clients
116
+ - ⚠️ **No Configuration Changes**: Cannot modify networks, firewall rules, or settings
117
+ - ⚙️ **Configuration**: `UNIFI_API_TYPE=cloud-ea`
118
+ - 📊 **Rate Limit**: 100 requests/minute
119
+
120
+ ### Cloud V1 API ⚠️
121
+
122
+ **Limited to aggregate statistics** - UniFi stable v1 cloud API.
123
+
124
+ - ✅ **Site Information**: List sites with aggregate statistics (device counts, client counts, bandwidth)
125
+ - ⚠️ **No Individual Device/Client Access**: Cannot query specific devices or clients
126
+ - ⚠️ **No Configuration Changes**: Cannot modify networks, firewall rules, or settings
127
+ - ⚙️ **Configuration**: `UNIFI_API_TYPE=cloud-v1`
128
+ - 📊 **Rate Limit**: 10,000 requests/minute
129
+
130
+ **💡 Recommendation**: Use **Local Gateway API** (`UNIFI_API_TYPE=local`) for full functionality. Cloud APIs are suitable only for high-level monitoring dashboards.
131
+
132
+ ## Features
133
+
134
+ ### Core Network Management
135
+
136
+ - **Device Management**: List, monitor, restart, locate, and upgrade UniFi devices (APs, switches, gateways)
137
+ - **Network Configuration**: Create, update, and delete networks, VLANs, and subnets with DHCP configuration
138
+ - **Client Management**: Query, block, unblock, and reconnect clients with detailed analytics
139
+ - **WiFi/SSID Management**: Create and manage wireless networks with WPA2/WPA3, guest networks, and VLAN isolation
140
+ - **Port Forwarding**: Configure port forwarding rules for external access
141
+ - **DPI Statistics**: Deep Packet Inspection analytics for bandwidth usage by application and category
142
+ - **Multi-Site Support**: Work with multiple UniFi sites seamlessly
143
+ - **Real-time Monitoring**: Access device, network, client, and WiFi statistics
144
+
145
+ ### Security & Firewall (v0.2.0)
146
+
147
+ - **Firewall Rules**: Create, update, and delete firewall rules with advanced traffic filtering
148
+ - **ACL Management**: Layer 3/4 access control lists with rule ordering and priority
149
+ - **Traffic Matching Lists**: IP, MAC, domain, and port-based traffic classification
150
+ - **Zone-Based Firewall**: Modern zone-based security with zone management and zone-to-zone policies
151
+ - **RADIUS Authentication**: 802.1X authentication with RADIUS server configuration
152
+ - **Guest Portal**: Customizable captive portals with hotspot billing and voucher management
153
+
154
+ ### Quality of Service (v0.2.0)
155
+
156
+ - **QoS Profiles**: Create and manage QoS profiles for traffic prioritization
157
+ - **Traffic Routes**: Time-based routing with schedules and application awareness
158
+ - **Bandwidth Management**: Upload/download limits with guaranteed minimums
159
+ - **ProAV Mode**: Professional audio/video QoS templates
160
+ - **Reference Profiles**: Built-in QoS templates for common applications
161
+
162
+ ### Backup & Operations (v0.2.0)
163
+
164
+ - **Automated Backups**: Schedule backups with cron expressions
165
+ - **Backup Management**: Create, download, restore, and delete backups
166
+ - **Cloud Sync Tracking**: Monitor backup cloud synchronization status
167
+ - **Checksum Verification**: Ensure backup integrity with SHA-256 checksums
168
+ - **Multiple Backup Types**: Network configurations and full system backups
169
+
170
+ ### Multi-Site Management (v0.2.0)
171
+
172
+ - **Site Provisioning**: Create, update, and delete UniFi sites
173
+ - **Site-to-Site VPN**: Configure VPN tunnels between sites
174
+ - **Device Migration**: Move devices between sites seamlessly
175
+ - **Site Health Monitoring**: Track site health scores and metrics
176
+ - **Cross-Site Analytics**: Aggregate device and client statistics across locations
177
+ - **Configuration Export**: Export site configurations for backup/documentation
178
+
179
+ ### Network Topology (v0.2.0)
180
+
181
+ - **Topology Discovery**: Complete network graph with devices and clients
182
+ - **Connection Mapping**: Port-level device interconnections
183
+ - **Multi-Format Export**: JSON, GraphML (Gephi), and DOT (Graphviz) formats
184
+ - **Network Depth Analysis**: Identify network hierarchy and uplink relationships
185
+ - **Visual Coordinates**: Optional device positioning for diagrams
186
+
187
+ ### Advanced Features
188
+
189
+ - **Redis Caching**: Optional Redis-based caching for improved performance (configurable TTL per resource type)
190
+ - **Webhook Support**: Real-time event processing with HMAC signature verification
191
+ - **Automatic Cache Invalidation**: Smart cache invalidation when configuration changes
192
+ - **Event Handlers**: Built-in handlers for device, client, and alert events
193
+ - **Performance Tracking**: Optional agnost.ai integration for monitoring MCP tool performance and usage analytics
194
+
195
+ ### Safety & Security
196
+
197
+ - **Confirmation Required**: All mutating operations require explicit `confirm=True` flag
198
+ - **Dry-Run Mode**: Preview changes before applying them with `dry_run=True`
199
+ - **Audit Logging**: All operations logged to `audit.log` for compliance
200
+ - **Input Validation**: Comprehensive parameter validation with detailed error messages
201
+ - **Password Masking**: Sensitive data automatically masked in logs
202
+ - **Type-Safe**: Full type hints and Pydantic validation throughout
203
+ - **Security Scanners**: CodeQL, Trivy, Bandit, Safety, and detect-secrets integration
204
+
205
+ ### Technical Excellence
206
+
207
+ - **Async Support**: Built with async/await for high performance and concurrency
208
+ - **MCP Protocol**: Standard Model Context Protocol for AI agent integration
209
+ - **Comprehensive Testing**: 990 unit tests with 78.18% coverage (4,865 of 6,105 statements)
210
+ - **CI/CD Pipelines**: Automated testing, security scanning, and Docker builds (18 checks)
211
+ - **Multi-Architecture**: Docker images for amd64, arm64, arm/v7 (32-bit ARM), and arm64/v8
212
+ - **Zero Security Issues**: Clean scans from Bandit, Trivy, OSV Scanner, and Socket Security
213
+ - **Quality Metrics**: Black formatting, Ruff linting, comprehensive type hints
214
+
215
+ ## Quick Start
216
+
217
+ ### Prerequisites
218
+
219
+ - Python 3.10 or higher
220
+ - A UniFi account at [unifi.ui.com](https://unifi.ui.com)
221
+ - UniFi API key (obtain from Settings → Control Plane → Integrations)
222
+ - Access to UniFi Cloud API or local gateway
223
+
224
+ ### Installation
225
+
226
+ #### Using PyPI (Recommended)
227
+
228
+ The UniFi MCP Server is published on PyPI and can be installed with pip or uv:
229
+
230
+ ```bash
231
+ # Install from PyPI
232
+ pip install unifi-mcp-server
233
+
234
+ # Or using uv (faster)
235
+ uv pip install unifi-mcp-server
236
+
237
+ # Install specific version
238
+ pip install unifi-mcp-server==0.2.0
239
+ ```
240
+
241
+ After installation, the `unifi-mcp-server` command will be available globally.
242
+
243
+ **PyPI Package**: <https://pypi.org/project/unifi-mcp-server/>
244
+
245
+ #### Using Docker (Alternative)
246
+
247
+ ```bash
248
+ # Pull the latest release
249
+ docker pull ghcr.io/enuno/unifi-mcp-server:0.2.0
250
+
251
+ # Multi-architecture support: amd64, arm64, arm/v7
252
+ ```
253
+
254
+ #### Build from Source (Development)
255
+
256
+ ##### Using uv (Recommended)
257
+
258
+ ```bash
259
+ # Install uv if you haven't already
260
+ curl -LsSf https://astral.sh/uv/install.sh | sh
261
+
262
+ # Clone the repository
263
+ git clone https://github.com/enuno/unifi-mcp-server.git
264
+ cd unifi-mcp-server
265
+
266
+ # Create virtual environment and install dependencies
267
+ uv venv
268
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
269
+ uv pip install -e ".[dev]"
270
+ ```
271
+
272
+ #### Using pip
273
+
274
+ ```bash
275
+ # Clone the repository
276
+ git clone https://github.com/enuno/unifi-mcp-server.git
277
+ cd unifi-mcp-server
278
+
279
+ # Create virtual environment
280
+ python -m venv .venv
281
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
282
+
283
+ # Install dependencies
284
+ pip install -e ".[dev]"
285
+ ```
286
+
287
+ #### Using Docker Compose (Recommended for Production)
288
+
289
+ The recommended way to run the UniFi MCP Server with full monitoring capabilities:
290
+
291
+ ```bash
292
+ # 1. Copy and configure environment variables
293
+ cp .env.docker.example .env
294
+ # Edit .env with your UNIFI_API_KEY and AGNOST_ORG_ID
295
+
296
+ # 2. Start all services (MCP Server + Redis + MCP Toolbox)
297
+ docker-compose up -d
298
+
299
+ # 3. Check service status
300
+ docker-compose ps
301
+
302
+ # 4. View logs
303
+ docker-compose logs -f unifi-mcp
304
+
305
+ # 5. Access MCP Toolbox dashboard
306
+ open http://localhost:8080
307
+
308
+ # 6. Stop all services
309
+ docker-compose down
310
+ ```
311
+
312
+ **Included Services:**
313
+
314
+ - **UniFi MCP Server**: Main MCP server with 77 tools (69 functional, 8 deprecated)
315
+ - **MCP Toolbox**: Web-based analytics dashboard (port 8080)
316
+ - **Redis**: High-performance caching layer
317
+
318
+ See [MCP_TOOLBOX.md](MCP_TOOLBOX.md) for detailed Toolbox documentation.
319
+
320
+ #### Using Docker (Standalone)
321
+
322
+ For standalone Docker usage (not with MCP clients):
323
+
324
+ ```bash
325
+ # Pull the image
326
+ docker pull ghcr.io/enuno/unifi-mcp-server:latest
327
+
328
+ # Run the container in background (Cloud API)
329
+ # Note: -i flag keeps stdin open for STDIO transport
330
+ docker run -i -d \
331
+ --name unifi-mcp \
332
+ -e UNIFI_API_KEY=your-api-key \
333
+ -e UNIFI_API_TYPE=cloud \
334
+ ghcr.io/enuno/unifi-mcp-server:latest
335
+
336
+ # OR run with local gateway proxy
337
+ docker run -i -d \
338
+ --name unifi-mcp \
339
+ -e UNIFI_API_KEY=your-api-key \
340
+ -e UNIFI_API_TYPE=local \
341
+ -e UNIFI_HOST=192.168.1.1 \
342
+ ghcr.io/enuno/unifi-mcp-server:latest
343
+
344
+ # Check container status
345
+ docker ps --filter name=unifi-mcp
346
+
347
+ # View logs
348
+ docker logs unifi-mcp
349
+
350
+ # Stop and remove
351
+ docker rm -f unifi-mcp
352
+ ```
353
+
354
+ **Note**: For MCP client integration (Claude Desktop, etc.), see the [Usage](#usage) section below for the correct configuration without `-d` flag.
355
+
356
+ ## Build from Source
357
+
358
+ ### Prerequisites
359
+
360
+ - **Python 3.10+**: Required for running the server
361
+ - **Git**: For cloning the repository
362
+ - **uv** (recommended) or **pip**: For dependency management
363
+ - **Docker** (optional): For containerized builds
364
+ - **Node.js & npm** (optional): For npm package publishing
365
+
366
+ ### Development Build
367
+
368
+ #### 1. Clone the Repository
369
+
370
+ ```bash
371
+ git clone https://github.com/enuno/unifi-mcp-server.git
372
+ cd unifi-mcp-server
373
+ ```
374
+
375
+ #### 2. Set Up Development Environment
376
+
377
+ **Using uv (Recommended):**
378
+
379
+ ```bash
380
+ # Install uv if not already installed
381
+ curl -LsSf https://astral.sh/uv/install.sh | sh
382
+
383
+ # Create virtual environment
384
+ uv venv
385
+
386
+ # Activate virtual environment
387
+ source .venv/bin/activate # Linux/macOS
388
+ # Or on Windows: .venv\Scripts\activate
389
+
390
+ # Install development dependencies
391
+ uv pip install -e ".[dev]"
392
+
393
+ # Install pre-commit hooks
394
+ pre-commit install
395
+ pre-commit install --hook-type commit-msg
396
+ ```
397
+
398
+ **Using pip:**
399
+
400
+ ```bash
401
+ # Create virtual environment
402
+ python -m venv .venv
403
+
404
+ # Activate virtual environment
405
+ source .venv/bin/activate # Linux/macOS
406
+ # Or on Windows: .venv\Scripts\activate
407
+
408
+ # Upgrade pip
409
+ pip install --upgrade pip
410
+
411
+ # Install development dependencies
412
+ pip install -e ".[dev]"
413
+
414
+ # Install pre-commit hooks
415
+ pre-commit install
416
+ pre-commit install --hook-type commit-msg
417
+ ```
418
+
419
+ #### 3. Configure Environment
420
+
421
+ ```bash
422
+ # Copy example configuration
423
+ cp .env.example .env
424
+
425
+ # Edit .env with your UniFi credentials
426
+ # Required: UNIFI_API_KEY
427
+ # Recommended: UNIFI_API_TYPE=local, UNIFI_LOCAL_HOST=<gateway-ip>
428
+ ```
429
+
430
+ #### 4. Run Tests
431
+
432
+ ```bash
433
+ # Run all unit tests
434
+ pytest tests/unit/ -v
435
+
436
+ # Run with coverage report
437
+ pytest tests/unit/ --cov=src --cov-report=html --cov-report=term-missing
438
+
439
+ # View coverage report
440
+ open htmlcov/index.html # macOS
441
+ # Or: xdg-open htmlcov/index.html # Linux
442
+ ```
443
+
444
+ #### 5. Run the Server
445
+
446
+ ```bash
447
+ # Development mode with MCP Inspector
448
+ uv run mcp dev src/main.py
449
+
450
+ # Production mode
451
+ uv run python -m src.main
452
+
453
+ # The MCP Inspector will be available at http://localhost:5173
454
+ ```
455
+
456
+ ### Production Build
457
+
458
+ #### Build Python Package
459
+
460
+ ```bash
461
+ # Install build tools
462
+ uv pip install build
463
+
464
+ # Build wheel and source distribution
465
+ python -m build
466
+
467
+ # Output: dist/unifi_mcp_server-0.2.0-py3-none-any.whl
468
+ # dist/unifi_mcp_server-0.2.0.tar.gz
469
+ ```
470
+
471
+ #### Build Docker Image
472
+
473
+ ```bash
474
+ # Build for current architecture
475
+ docker build -t unifi-mcp-server:0.2.0 .
476
+
477
+ # Build multi-architecture (requires buildx)
478
+ docker buildx create --use
479
+ docker buildx build \
480
+ --platform linux/amd64,linux/arm64,linux/arm/v7 \
481
+ -t ghcr.io/enuno/unifi-mcp-server:0.2.0 \
482
+ --push .
483
+
484
+ # Test the image
485
+ docker run -i --rm \
486
+ -e UNIFI_API_KEY=your-key \
487
+ -e UNIFI_API_TYPE=cloud \
488
+ unifi-mcp-server:0.2.0
489
+ ```
490
+
491
+ ### Publishing
492
+
493
+ #### Publish to PyPI
494
+
495
+ ```bash
496
+ # Install twine
497
+ uv pip install twine
498
+
499
+ # Check distribution
500
+ twine check dist/*
501
+
502
+ # Upload to PyPI (requires PyPI account and token)
503
+ twine upload dist/*
504
+
505
+ # Or upload to Test PyPI first
506
+ twine upload --repository testpypi dist/*
507
+ ```
508
+
509
+ #### Publish to npm (Metadata Wrapper)
510
+
511
+ ```bash
512
+ # Ensure package.json is up to date
513
+ cat package.json
514
+
515
+ # Login to npm (if not already)
516
+ npm login
517
+
518
+ # Publish package
519
+ npm publish --access public
520
+
521
+ # Verify publication
522
+ npm view unifi-mcp-server
523
+ ```
524
+
525
+ #### Publish to MCP Registry
526
+
527
+ ```bash
528
+ # Install mcp-publisher
529
+ brew install mcp-publisher
530
+ # 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/
531
+
532
+ # Authenticate with GitHub (for io.github.enuno namespace)
533
+ mcp-publisher login github
534
+
535
+ # Publish to registry (requires npm package published first)
536
+ mcp-publisher publish
537
+
538
+ # Verify
539
+ curl "https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.enuno/unifi-mcp-server"
540
+ ```
541
+
542
+ ### Release Process
543
+
544
+ See [docs/RELEASE_PROCESS.md](docs/RELEASE_PROCESS.md) for the complete release workflow, including automated GitHub Actions, manual PyPI/npm publishing, and MCP registry submission.
545
+
546
+ ### Configuration
547
+
548
+ #### Obtaining Your API Key
549
+
550
+ 1. Log in to [UniFi Site Manager](https://unifi.ui.com)
551
+ 2. Navigate to **Settings → Control Plane → Integrations**
552
+ 3. Click **Create API Key**
553
+ 4. **Save the key immediately** - it's only shown once!
554
+ 5. Store it securely in your `.env` file
555
+
556
+ #### Configuration File
557
+
558
+ Create a `.env` file in the project root:
559
+
560
+ ```env
561
+ # Required: Your UniFi API Key
562
+ UNIFI_API_KEY=your-api-key-here
563
+
564
+ # API Mode Selection (choose one):
565
+ # - 'local': Full access via local gateway (RECOMMENDED)
566
+ # - 'cloud-ea': Early Access cloud API (limited to statistics)
567
+ # - 'cloud-v1': Stable v1 cloud API (limited to statistics)
568
+ UNIFI_API_TYPE=local
569
+
570
+ # Local Gateway Configuration (for UNIFI_API_TYPE=local)
571
+ UNIFI_LOCAL_HOST=192.168.1.1
572
+ UNIFI_LOCAL_PORT=443
573
+ UNIFI_LOCAL_VERIFY_SSL=false
574
+
575
+ # Cloud API Configuration (for cloud-ea or cloud-v1)
576
+ # UNIFI_CLOUD_API_URL=https://api.ui.com
577
+
578
+ # Optional settings
579
+ UNIFI_DEFAULT_SITE=default
580
+
581
+ # Redis caching (optional - improves performance)
582
+ REDIS_HOST=localhost
583
+ REDIS_PORT=6379
584
+ REDIS_DB=0
585
+ # REDIS_PASSWORD=your-password # If Redis requires authentication
586
+
587
+ # Webhook support (optional - for real-time events)
588
+ WEBHOOK_SECRET=your-webhook-secret-here
589
+
590
+ # Performance tracking with agnost.ai (optional - for analytics)
591
+ # Get your Organization ID from https://app.agnost.ai
592
+ # AGNOST_ENABLED=true
593
+ # AGNOST_ORG_ID=your-organization-id-here
594
+ # AGNOST_ENDPOINT=https://api.agnost.ai
595
+ # AGNOST_DISABLE_INPUT=false # Set to true to disable input tracking
596
+ # AGNOST_DISABLE_OUTPUT=false # Set to true to disable output tracking
597
+ ```
598
+
599
+ See `.env.example` for all available options.
600
+
601
+ ### Running the Server
602
+
603
+ ```bash
604
+ # Development mode with MCP Inspector
605
+ uv run mcp dev src/main.py
606
+
607
+ # Production mode
608
+ uv run python src/main.py
609
+ ```
610
+
611
+ The MCP Inspector will be available at `http://localhost:5173` for interactive testing.
612
+
613
+ ## Usage
614
+
615
+ ### With Claude Desktop
616
+
617
+ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
618
+
619
+ #### Option 1: Using PyPI Package (Recommended)
620
+
621
+ After installing via `pip install unifi-mcp-server`:
622
+
623
+ ```json
624
+ {
625
+ "mcpServers": {
626
+ "unifi": {
627
+ "command": "unifi-mcp-server",
628
+ "env": {
629
+ "UNIFI_API_KEY": "your-api-key-here",
630
+ "UNIFI_API_TYPE": "local",
631
+ "UNIFI_LOCAL_HOST": "192.168.1.1"
632
+ }
633
+ }
634
+ }
635
+ }
636
+ ```
637
+
638
+ For cloud API access, use:
639
+
640
+ ```json
641
+ {
642
+ "mcpServers": {
643
+ "unifi": {
644
+ "command": "unifi-mcp-server",
645
+ "env": {
646
+ "UNIFI_API_KEY": "your-api-key-here",
647
+ "UNIFI_API_TYPE": "cloud-v1"
648
+ }
649
+ }
650
+ }
651
+ }
652
+ ```
653
+
654
+ #### Option 2: Using uv with PyPI Package
655
+
656
+ ```json
657
+ {
658
+ "mcpServers": {
659
+ "unifi": {
660
+ "command": "uvx",
661
+ "args": ["unifi-mcp-server"],
662
+ "env": {
663
+ "UNIFI_API_KEY": "your-api-key-here",
664
+ "UNIFI_API_TYPE": "local",
665
+ "UNIFI_LOCAL_HOST": "192.168.1.1"
666
+ }
667
+ }
668
+ }
669
+ }
670
+ ```
671
+
672
+ #### Option 3: Using Docker
673
+
674
+ ```json
675
+ {
676
+ "mcpServers": {
677
+ "unifi": {
678
+ "command": "docker",
679
+ "args": [
680
+ "run",
681
+ "-i",
682
+ "--rm",
683
+ "-e",
684
+ "UNIFI_API_KEY=your-api-key-here",
685
+ "-e",
686
+ "UNIFI_API_TYPE=cloud",
687
+ "ghcr.io/enuno/unifi-mcp-server:latest"
688
+ ]
689
+ }
690
+ }
691
+ }
692
+ ```
693
+
694
+ **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.
695
+
696
+ ### With Cursor
697
+
698
+ Add to your Cursor MCP configuration (`mcp.json` via "View: Open MCP Settings → New MCP Server"):
699
+
700
+ #### Option 1: Using PyPI Package (Recommended)
701
+
702
+ After installing via `pip install unifi-mcp-server`:
703
+
704
+ ```json
705
+ {
706
+ "mcpServers": {
707
+ "unifi-mcp": {
708
+ "command": "unifi-mcp-server",
709
+ "env": {
710
+ "UNIFI_API_KEY": "your-api-key-here",
711
+ "UNIFI_API_TYPE": "local",
712
+ "UNIFI_LOCAL_HOST": "192.168.1.1",
713
+ "UNIFI_LOCAL_VERIFY_SSL": "false"
714
+ },
715
+ "disabled": false
716
+ }
717
+ }
718
+ }
719
+ ```
720
+
721
+ #### Option 2: Using uv with PyPI Package
722
+
723
+ ```json
724
+ {
725
+ "mcpServers": {
726
+ "unifi-mcp": {
727
+ "command": "uvx",
728
+ "args": ["unifi-mcp-server"],
729
+ "env": {
730
+ "UNIFI_API_KEY": "your-api-key-here",
731
+ "UNIFI_API_TYPE": "local",
732
+ "UNIFI_LOCAL_HOST": "192.168.1.1"
733
+ },
734
+ "disabled": false
735
+ }
736
+ }
737
+ }
738
+ ```
739
+
740
+ #### Option 3: Using Docker
741
+
742
+ ```json
743
+ {
744
+ "mcpServers": {
745
+ "unifi-mcp": {
746
+ "command": "docker",
747
+ "args": [
748
+ "run", "--rm", "-i",
749
+ "--name", "unifi-mcp-server",
750
+ "-e", "UNIFI_API_KEY=your_unifi_api_key_here",
751
+ "-e", "UNIFI_API_TYPE=local",
752
+ "-e", "UNIFI_LOCAL_HOST=192.168.1.1",
753
+ "-e", "UNIFI_LOCAL_VERIFY_SSL=false",
754
+ "ghcr.io/enuno/unifi-mcp-server:latest"
755
+ ],
756
+ "disabled": false
757
+ }
758
+ }
759
+ }
760
+ ```
761
+
762
+ **Configuration Notes:**
763
+
764
+ - Replace `UNIFI_API_KEY` with your actual UniFi API key
765
+ - For local gateway access, set `UNIFI_API_TYPE=local` and provide `UNIFI_LOCAL_HOST`
766
+ - For cloud API access, use `UNIFI_API_TYPE=cloud-v1` or `cloud-ea`
767
+ - After saving, restart Cursor to activate the server
768
+ - Invoke tools in the Chat sidebar (e.g., "List my UniFi devices")
769
+
770
+ ### With Other MCP Clients
771
+
772
+ The UniFi MCP Server works with any MCP-compatible client. Here are generic configuration patterns:
773
+
774
+ #### Using the Installed Command
775
+
776
+ After installing from PyPI (`pip install unifi-mcp-server`):
777
+
778
+ ```json
779
+ {
780
+ "mcpServers": {
781
+ "unifi": {
782
+ "command": "unifi-mcp-server",
783
+ "env": {
784
+ "UNIFI_API_KEY": "your-api-key-here",
785
+ "UNIFI_API_TYPE": "local",
786
+ "UNIFI_LOCAL_HOST": "192.168.1.1"
787
+ }
788
+ }
789
+ }
790
+ }
791
+ ```
792
+
793
+ #### Using uvx (Run from PyPI without installation)
794
+
795
+ ```json
796
+ {
797
+ "mcpServers": {
798
+ "unifi": {
799
+ "command": "uvx",
800
+ "args": ["unifi-mcp-server"],
801
+ "env": {
802
+ "UNIFI_API_KEY": "your-api-key-here",
803
+ "UNIFI_API_TYPE": "local",
804
+ "UNIFI_LOCAL_HOST": "192.168.1.1"
805
+ }
806
+ }
807
+ }
808
+ }
809
+ ```
810
+
811
+ #### Using Python Module Directly
812
+
813
+ ```json
814
+ {
815
+ "mcpServers": {
816
+ "unifi": {
817
+ "command": "python3",
818
+ "args": ["-m", "src.main"],
819
+ "env": {
820
+ "UNIFI_API_KEY": "your-api-key-here",
821
+ "UNIFI_API_TYPE": "local",
822
+ "UNIFI_LOCAL_HOST": "192.168.1.1"
823
+ }
824
+ }
825
+ }
826
+ }
827
+ ```
828
+
829
+ **Environment Variables (All Clients):**
830
+
831
+ - `UNIFI_API_KEY` (required): Your UniFi API key from unifi.ui.com
832
+ - `UNIFI_API_TYPE` (required): `local`, `cloud-v1`, or `cloud-ea`
833
+ - **For Local Gateway API**:
834
+ - `UNIFI_LOCAL_HOST`: Gateway IP (e.g., 192.168.1.1)
835
+ - `UNIFI_LOCAL_PORT`: Gateway port (default: 443)
836
+ - `UNIFI_LOCAL_VERIFY_SSL`: SSL verification (default: false)
837
+ - **For Cloud APIs**:
838
+ - `UNIFI_CLOUD_API_URL`: Cloud API URL (default: <https://api.ui.com>)
839
+ - `UNIFI_DEFAULT_SITE`: Default site ID (default: default)
840
+
841
+ ### Programmatic Usage
842
+
843
+ ```python
844
+ from mcp import MCP
845
+ import asyncio
846
+
847
+ async def main():
848
+ mcp = MCP("unifi-mcp-server")
849
+
850
+ # List all devices
851
+ devices = await mcp.call_tool("list_devices", {
852
+ "site_id": "default"
853
+ })
854
+
855
+ for device in devices:
856
+ print(f"{device['name']}: {device['status']}")
857
+
858
+ # Get network information via resource
859
+ networks = await mcp.read_resource("sites://default/networks")
860
+ print(f"Networks: {len(networks)}")
861
+
862
+ # Create a guest WiFi network with VLAN isolation
863
+ wifi = await mcp.call_tool("create_wlan", {
864
+ "site_id": "default",
865
+ "name": "Guest WiFi",
866
+ "security": "wpapsk",
867
+ "password": "GuestPass123!",
868
+ "is_guest": True,
869
+ "vlan_id": 100,
870
+ "confirm": True # Required for safety
871
+ })
872
+ print(f"Created WiFi: {wifi['name']}")
873
+
874
+ # Get DPI statistics for top bandwidth users
875
+ top_apps = await mcp.call_tool("list_top_applications", {
876
+ "site_id": "default",
877
+ "limit": 5,
878
+ "time_range": "24h"
879
+ })
880
+
881
+ for app in top_apps:
882
+ gb = app['total_bytes'] / 1024**3
883
+ print(f"{app['application']}: {gb:.2f} GB")
884
+
885
+ # Create Zone-Based Firewall zones (UniFi Network 9.0+)
886
+ lan_zone = await mcp.call_tool("create_firewall_zone", {
887
+ "site_id": "default",
888
+ "name": "LAN",
889
+ "description": "Trusted local network",
890
+ "confirm": True
891
+ })
892
+
893
+ iot_zone = await mcp.call_tool("create_firewall_zone", {
894
+ "site_id": "default",
895
+ "name": "IoT",
896
+ "description": "Internet of Things devices",
897
+ "confirm": True
898
+ })
899
+
900
+ # Set zone-to-zone policy (LAN can access IoT, but IoT cannot access LAN)
901
+ await mcp.call_tool("update_zbf_policy", {
902
+ "site_id": "default",
903
+ "source_zone_id": lan_zone["_id"],
904
+ "destination_zone_id": iot_zone["_id"],
905
+ "action": "accept",
906
+ "confirm": True
907
+ })
908
+
909
+ asyncio.run(main())
910
+ ```
911
+
912
+ ## API Documentation
913
+
914
+ See [API.md](API.md) for complete API documentation, including:
915
+
916
+ - Available MCP tools
917
+ - Resource URI schemes
918
+ - Request/response formats
919
+ - Error handling
920
+ - Examples
921
+
922
+ ## Development
923
+
924
+ ### Setup Development Environment
925
+
926
+ ```bash
927
+ # Install development dependencies
928
+ uv pip install -e ".[dev]"
929
+
930
+ # Install pre-commit hooks
931
+ pre-commit install
932
+ pre-commit install --hook-type commit-msg
933
+ ```
934
+
935
+ ### Running Tests
936
+
937
+ ```bash
938
+ # Run all tests
939
+ pytest tests/unit/
940
+
941
+ # Run with coverage report
942
+ pytest tests/unit/ --cov=src --cov-report=html --cov-report=term-missing
943
+
944
+ # Run specific test file
945
+ pytest tests/unit/test_zbf_tools.py -v
946
+
947
+ # Run tests for new v0.2.0 features
948
+ pytest tests/unit/test_new_models.py tests/unit/test_zbf_tools.py tests/unit/test_traffic_flow_tools.py
949
+
950
+ # Run only unit tests (fast)
951
+ pytest -m unit
952
+
953
+ # Run only integration tests (requires UniFi controller)
954
+ pytest -m integration
955
+ ```
956
+
957
+ **Current Test Coverage (v0.2.0)**:
958
+
959
+ - **Overall**: 78.18% (990 tests passing)
960
+ - **Total Statements**: 6,105 statements, 4,865 covered
961
+ - **Branch Coverage**: 75.03%
962
+
963
+ [![Coverage Sunburst](https://codecov.io/github/enuno/unifi-mcp-server/graphs/sunburst.svg?token=ZD314B59CE)](https://codecov.io/github/enuno/unifi-mcp-server)
964
+
965
+ **By Module Category:**
966
+
967
+ - **Models**: 98%+ coverage (Excellent)
968
+ - **Core Tools**: 90-100% coverage (Excellent)
969
+ - **v0.2.0 Features**: 70-96% coverage (Good to Excellent)
970
+ - Topology: 95.83% (29 tests)
971
+ - Backup & Restore: 86.32% (10 tests)
972
+ - Multi-Site Aggregation: 92.95% (10 tests)
973
+ - QoS: 82.43% (46 tests)
974
+ - RADIUS: 69.77% (17 tests)
975
+ - **Utilities**: 90%+ coverage (Excellent)
976
+
977
+ **Top Coverage Performers** (>95%):
978
+
979
+ - clients.py: 98.72%
980
+ - devices.py: 98.44%
981
+ - device_control.py: 99.10%
982
+ - topology.py: 95.83% ⭐ (v0.2.0)
983
+ - vouchers.py: 96.36%
984
+ - firewall.py: 96.11%
985
+
986
+ See [VERIFICATION_REPORT.md](VERIFICATION_REPORT.md) for complete coverage details and [TESTING_PLAN.md](TESTING_PLAN.md) for testing strategy.
987
+
988
+ ### Code Quality
989
+
990
+ ```bash
991
+ # Format code
992
+ black src/ tests/
993
+ isort src/ tests/
994
+
995
+ # Lint code
996
+ ruff check src/ tests/ --fix
997
+
998
+ # Type check
999
+ mypy src/
1000
+
1001
+ # Run all pre-commit checks
1002
+ pre-commit run --all-files
1003
+ ```
1004
+
1005
+ ### Testing with MCP Inspector
1006
+
1007
+ ```bash
1008
+ # Start development server with inspector
1009
+ uv run mcp dev src/main.py
1010
+
1011
+ # Open http://localhost:5173 in your browser
1012
+ ```
1013
+
1014
+ ## Project Structure
1015
+
1016
+ ```
1017
+ unifi-mcp-server/
1018
+ ├── .github/
1019
+ │ └── workflows/ # CI/CD pipelines (CI, security, release)
1020
+ ├── .claude/
1021
+ │ └── commands/ # Custom slash commands for development
1022
+ ├── src/
1023
+ │ ├── main.py # MCP server entry point (77 tools registered)
1024
+ │ ├── cache.py # Redis caching implementation
1025
+ │ ├── config/ # Configuration management
1026
+ │ ├── api/ # UniFi API client with rate limiting
1027
+ │ ├── models/ # Pydantic data models
1028
+ │ │ └── zbf.py # Zone-Based Firewall models
1029
+ │ ├── tools/ # MCP tool definitions
1030
+ │ │ ├── clients.py # Client query tools
1031
+ │ │ ├── devices.py # Device query tools
1032
+ │ │ ├── networks.py # Network query tools
1033
+ │ │ ├── sites.py # Site query tools
1034
+ │ │ ├── firewall.py # Firewall management (Phase 4)
1035
+ │ │ ├── firewall_zones.py # Zone-Based Firewall zone management (v0.1.4)
1036
+ │ │ ├── zbf_matrix.py # Zone-Based Firewall policy matrix (v0.1.4)
1037
+ │ │ ├── network_config.py # Network configuration (Phase 4)
1038
+ │ │ ├── device_control.py # Device control (Phase 4)
1039
+ │ │ ├── client_management.py # Client management (Phase 4)
1040
+ │ │ ├── wifi.py # WiFi/SSID management (Phase 5)
1041
+ │ │ ├── port_forwarding.py # Port forwarding (Phase 5)
1042
+ │ │ └── dpi.py # DPI statistics (Phase 5)
1043
+ │ ├── resources/ # MCP resource definitions
1044
+ │ ├── webhooks/ # Webhook receiver and handlers (Phase 5)
1045
+ │ └── utils/ # Utility functions and validators
1046
+ ├── tests/
1047
+ │ ├── unit/ # Unit tests (213 tests, 37% coverage)
1048
+ │ ├── integration/ # Integration tests (planned)
1049
+ │ └── performance/ # Performance benchmarks (planned)
1050
+ ├── docs/ # Additional documentation
1051
+ │ └── AI-Coding/ # AI coding guidelines
1052
+ ├── .env.example # Environment variable template
1053
+ ├── pyproject.toml # Project configuration
1054
+ ├── README.md # This file
1055
+ ├── API.md # Complete API documentation
1056
+ ├── ZBF_STATUS.md # Zone-Based Firewall implementation status
1057
+ ├── TESTING_PLAN.md # Testing strategy and roadmap
1058
+ ├── DEVELOPMENT_PLAN.md # Development roadmap
1059
+ ├── CONTRIBUTING.md # Contribution guidelines
1060
+ ├── SECURITY.md # Security policy and best practices
1061
+ ├── AGENTS.md # AI agent guidelines
1062
+ └── LICENSE # Apache 2.0 License
1063
+ ```
1064
+
1065
+ ## Contributing
1066
+
1067
+ We welcome contributions from both human developers and AI coding assistants! Please see:
1068
+
1069
+ - [CONTRIBUTING.md](CONTRIBUTING.md) - Contribution guidelines
1070
+ - [AGENTS.md](AGENTS.md) - AI agent-specific guidelines
1071
+ - [AI_CODING_ASSISTANT.md](AI_CODING_ASSISTANT.md) - AI coding standards
1072
+ - [AI_GIT_PRACTICES.md](AI_GIT_PRACTICES.md) - AI Git practices
1073
+
1074
+ ### Quick Contribution Guide
1075
+
1076
+ 1. Fork the repository
1077
+ 2. Create a feature branch: `git checkout -b feature/your-feature-name`
1078
+ 3. Make your changes
1079
+ 4. Run tests and linting: `pytest && pre-commit run --all-files`
1080
+ 5. Commit with conventional commits: `feat: add new feature`
1081
+ 6. Push and create a pull request
1082
+
1083
+ ## Security
1084
+
1085
+ Security is a top priority. Please see [SECURITY.md](SECURITY.md) for:
1086
+
1087
+ - Reporting vulnerabilities
1088
+ - Security best practices
1089
+ - Supported versions
1090
+
1091
+ **Never commit credentials or sensitive data!**
1092
+
1093
+ ## Roadmap
1094
+
1095
+ ### Version 0.2.0 (Current - Complete ✅ 2026-01-25)
1096
+
1097
+ **All 7 Feature Phases Complete - 74 MCP Tools**
1098
+
1099
+ **Phase 3: Read-Only Operations (16 tools)**
1100
+
1101
+ - [x] Device management (list, details, statistics, search by type)
1102
+ - [x] Client management (list, details, statistics, search)
1103
+ - [x] Network information (details, VLANs, subnets, statistics)
1104
+ - [x] Site management (list, details, statistics)
1105
+ - [x] MCP resources (sites, devices, clients, networks)
1106
+
1107
+ **Phase 4: Mutating Operations with Safety (13 tools)**
1108
+
1109
+ - [x] Firewall rule management (create, update, delete)
1110
+ - [x] Network configuration (create, update, delete networks/VLANs)
1111
+ - [x] Device control (restart, locate, upgrade)
1112
+ - [x] Client management (block, unblock, reconnect)
1113
+ - [x] Safety mechanisms (confirmation, dry-run, audit logging)
1114
+
1115
+ **Phase 5: Advanced Features (11 tools)**
1116
+
1117
+ - [x] WiFi/SSID management (create, update, delete, statistics)
1118
+ - [x] Port forwarding configuration (create, delete, list)
1119
+ - [x] DPI statistics (site-wide, top apps, per-client)
1120
+ - [x] Redis caching with automatic invalidation
1121
+ - [x] Webhook support for real-time events
1122
+
1123
+ **Phase 6: Zone-Based Firewall (12 working tools)**
1124
+
1125
+ - [x] Zone management (create, update, delete, list, assign networks) - 7 tools ✅ WORKING
1126
+ - [x] **Zone-to-zone policies via Firewall Policies v2 API** - 5 tools ✅ WORKING (PR #13)
1127
+ - [x] Legacy zone matrix endpoints - 5 tools ❌ ENDPOINTS DO NOT EXIST (use v2 API instead)
1128
+ - [x] Application blocking per zone (DPI-based blocking) - 2 tools ❌ ENDPOINTS DO NOT EXIST
1129
+ - [x] Zone statistics and monitoring - 1 tool ❌ ENDPOINT DOES NOT EXIST
1130
+ - [x] Type-safe Pydantic models for ZBF and Firewall Policies
1131
+ - [x] Comprehensive unit tests (84% coverage)
1132
+ - [x] Endpoint verification on U7 Express and UDM Pro (v10.0.156)
1133
+
1134
+ **Phase 7: Traffic Flow Monitoring (15 tools) ✅ COMPLETE**
1135
+
1136
+ - [x] Real-time traffic flow monitoring and analysis
1137
+ - [x] Flow filtering by IP, protocol, application, time range
1138
+ - [x] Connection state tracking (active, closed, timed-out)
1139
+ - [x] Client traffic aggregation with top applications/destinations
1140
+ - [x] Bandwidth rate calculations for streaming flows
1141
+ - [x] Security quick-response capabilities (block suspicious IPs)
1142
+ - [x] Type-safe Pydantic models for traffic flows
1143
+ - [x] Comprehensive unit tests (86.62% coverage)
1144
+ - [x] Advanced analytics and reporting capabilities
1145
+
1146
+ **ZBF Implementation Notes (Verified 2025-11-18):**
1147
+
1148
+ - ✅ Zone CRUD operations work (local gateway API only)
1149
+ - ✅ **Zone-to-zone policies work via Firewall Policies v2 API** (local gateway API only)
1150
+ - ❌ Legacy zone matrix endpoints NOT available via API (use v2 API instead)
1151
+ - ❌ Application blocking per zone NOT available via API
1152
+ - ❌ Zone statistics NOT available via API
1153
+ - See ZBF_STATUS.md for complete details and examples
1154
+
1155
+ **Phase 1: QoS Enhancements (11 tools) ✅**
1156
+
1157
+ - [x] QoS profile management (CRUD operations)
1158
+ - [x] Reference profiles and ProAV templates
1159
+ - [x] Traffic routing with time-based schedules
1160
+ - [x] Application-based QoS configuration
1161
+ - [x] Coverage: 82.43% (46 tests passing)
1162
+
1163
+ **Phase 2: Backup & Restore (8 tools) ✅**
1164
+
1165
+ - [x] Manual and automated backup creation
1166
+ - [x] Backup listing, download, and verification
1167
+ - [x] Backup restore functionality
1168
+ - [x] Automated scheduling with cron expressions
1169
+ - [x] Cloud synchronization tracking
1170
+ - [x] Coverage: 86.32% (10 tests passing)
1171
+
1172
+ **Phase 3: Multi-Site Aggregation (4 tools) ✅**
1173
+
1174
+ - [x] Cross-site device and client analytics
1175
+ - [x] Site health monitoring with scoring
1176
+ - [x] Side-by-side site comparison
1177
+ - [x] Consolidated reporting across locations
1178
+ - [x] Coverage: 92.95% (10 tests passing)
1179
+
1180
+ **Phase 4: ACL & Traffic Filtering (7 tools) ✅**
1181
+
1182
+ - [x] Layer 3/4 access control list management
1183
+ - [x] Traffic matching lists (IP, MAC, domain, port)
1184
+ - [x] Firewall policy automation
1185
+ - [x] Rule ordering and priority
1186
+ - [x] Coverage: 89.30-93.84%
1187
+
1188
+ **Phase 5: Site Management Enhancements (9 tools) ✅**
1189
+
1190
+ - [x] Multi-site provisioning and configuration
1191
+ - [x] Site-to-site VPN setup
1192
+ - [x] Device migration between sites
1193
+ - [x] Advanced site settings management
1194
+ - [x] Configuration export for backup
1195
+ - [x] Coverage: 92.95% (10 tests passing)
1196
+
1197
+ **Phase 6: RADIUS & Guest Portal (6 tools) ✅**
1198
+
1199
+ - [x] RADIUS profile configuration (802.1X)
1200
+ - [x] RADIUS accounting server support
1201
+ - [x] Guest portal customization
1202
+ - [x] Hotspot billing and voucher management
1203
+ - [x] Session timeout and redirect control
1204
+ - [x] Coverage: 69.77% (17 tests passing)
1205
+
1206
+ **Phase 7: Network Topology (5 tools) ✅**
1207
+
1208
+ - [x] Complete topology graph retrieval
1209
+ - [x] Multi-format export (JSON, GraphML, DOT)
1210
+ - [x] Device interconnection mapping
1211
+ - [x] Port-level connection tracking
1212
+ - [x] Network depth analysis
1213
+ - [x] Coverage: 95.83% (29 tests passing)
1214
+
1215
+ **Quality Achievements:**
1216
+
1217
+ - [x] 990 tests passing (78.18% coverage)
1218
+ - [x] 18/18 CI/CD checks passing
1219
+ - [x] Zero security vulnerabilities
1220
+ - [x] 30+ AI assistant example prompts
1221
+ - [x] Comprehensive documentation (VERIFICATION_REPORT.md, API.md)
1222
+
1223
+ **Total: 74 MCP tools + Comprehensive documentation and verification**
1224
+
1225
+ ### Version 0.3.0 (Future - Planned)
1226
+
1227
+ - [ ] VPN Management (site_vpn.py - 0% coverage currently)
1228
+ - [ ] WAN Management (wans.py - 0% coverage currently)
1229
+ - [ ] Enhanced ZBF Matrix (zbf_matrix.py - improve 65% coverage)
1230
+ - [ ] Integration tests for caching and webhooks
1231
+ - [ ] Performance benchmarks and optimization
1232
+ - [ ] Additional DPI analytics (historical trends)
1233
+ - [ ] Bulk device/client operations
1234
+ - [ ] Advanced traffic flow analytics
1235
+
1236
+ ### Version 1.0.0 (Future)
1237
+
1238
+ - [ ] Complete UniFi API coverage (remaining endpoints)
1239
+ - [ ] Advanced analytics dashboard
1240
+ - [ ] VPN configuration management
1241
+ - [ ] Alert and notification management
1242
+ - [ ] Bulk operations for devices
1243
+ - [ ] Traffic shaping and QoS management
1244
+
1245
+ ## Acknowledgments
1246
+
1247
+ This project is inspired by and builds upon:
1248
+
1249
+ - [sirkirby/unifi-network-mcp](https://github.com/sirkirby/unifi-network-mcp) - Reference implementation
1250
+ - [MakeWithData UniFi MCP Guide](https://www.makewithdata.tech/p/build-a-mcp-server-for-ai-access) - Tutorial and guide
1251
+ - [Anthropic MCP](https://github.com/anthropics/mcp) - Model Context Protocol specification
1252
+ - [FastMCP](https://github.com/jlowin/fastmcp) - MCP server framework
1253
+
1254
+ ## License
1255
+
1256
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
1257
+
1258
+ ## Support
1259
+
1260
+ - **Issues**: [GitHub Issues](https://github.com/enuno/unifi-mcp-server/issues)
1261
+ - **Discussions**: [GitHub Discussions](https://github.com/enuno/unifi-mcp-server/discussions)
1262
+ - **Documentation**: See [API.md](API.md) and other docs in this repository
1263
+
1264
+ ## Links
1265
+
1266
+ - **Repository**: <https://github.com/enuno/unifi-mcp-server>
1267
+ - **Releases**: <https://github.com/enuno/unifi-mcp-server/releases>
1268
+ - **Docker Registry**: <https://ghcr.io/enuno/unifi-mcp-server>
1269
+ - **npm Package**: <https://www.npmjs.com/package/unifi-mcp-server>
1270
+ - **MCP Registry**: Search for `io.github.enuno/unifi-mcp-server` at <https://registry.modelcontextprotocol.io>
1271
+ - **Documentation**: [API.md](API.md) | [VERIFICATION_REPORT.md](VERIFICATION_REPORT.md)
1272
+ - **UniFi Official**: <https://www.ui.com/>
1273
+
1274
+ ## 🌟 Star History
1275
+
1276
+ If you find this project useful, please consider starring it on GitHub to help others discover it!
1277
+
1278
+ [![Star History Chart](https://api.star-history.com/svg?repos=enuno/unifi-mcp-server&type=date&legend=top-left)](https://www.star-history.com/#enuno/unifi-mcp-server&type=date&legend=top-left)
1279
+
1280
+ ---
1281
+
1282
+ Made with ❤️ for the UniFi and AI communities