unifi-network-mcp 0.3.0__tar.gz → 0.3.1__tar.gz
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.
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/.well-known/mcp-server.json +8 -4
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/PKG-INFO +131 -50
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/README.md +130 -49
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/pyproject.toml +1 -1
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/config/config.yaml +34 -4
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/main.py +54 -20
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools_manifest.json +13 -13
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/utils/diagnostics.py +9 -0
- unifi_network_mcp-0.3.1/src/utils/meta_tools.py +350 -0
- unifi_network_mcp-0.3.1/src/utils/tool_loader.py +103 -0
- unifi_network_mcp-0.3.0/src/utils/meta_tools.py +0 -211
- unifi_network_mcp-0.3.0/src/utils/tool_loader.py +0 -37
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/.gitignore +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/LICENSE +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/bootstrap.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/jobs.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/client_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/connection_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/device_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/event_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/firewall_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/hotspot_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/network_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/qos_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/routing_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/stats_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/system_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/traffic_route_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/usergroup_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/managers/vpn_manager.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/runtime.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/schemas.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tool_index.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/clients.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/config.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/devices.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/events.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/firewall.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/hotspot.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/network.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/port_forwards.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/qos.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/routing.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/stats.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/system.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/traffic_routes.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/usergroups.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/tools/vpn.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/utils/confirmation.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/utils/lazy_tool_loader.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/utils/permissions.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/validator_registry.py +0 -0
- {unifi_network_mcp-0.3.0 → unifi_network_mcp-0.3.1}/src/validators.py +0 -0
|
@@ -46,10 +46,14 @@
|
|
|
46
46
|
"tool": "unifi_tool_index",
|
|
47
47
|
"description": "Returns machine-readable list of all available tools with schemas"
|
|
48
48
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
49
|
+
"execution": {
|
|
50
|
+
"tool": "unifi_execute",
|
|
51
|
+
"description": "Execute any discovered tool synchronously"
|
|
52
|
+
},
|
|
53
|
+
"batch_operations": {
|
|
54
|
+
"start_tool": "unifi_batch",
|
|
55
|
+
"status_tool": "unifi_batch_status",
|
|
56
|
+
"description": "Parallel batch execution for bulk operations"
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: unifi-network-mcp
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Unifi Network MCP Server
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Requires-Python: >=3.13
|
|
@@ -45,7 +45,7 @@ A self-hosted [Model Context Protocol](https://github.com/modelcontextprotocol)
|
|
|
45
45
|
* [Overview](#overview)
|
|
46
46
|
* [Context Optimization](#context-optimization)
|
|
47
47
|
* [Tool Index](#tool-index)
|
|
48
|
-
* [
|
|
48
|
+
* [Tool Execution](#tool-execution)
|
|
49
49
|
* [Runtime Configuration](#runtime-configuration)
|
|
50
50
|
* [Diagnostics (Advanced Logging)](#diagnostics-advanced-logging)
|
|
51
51
|
* [Developer Console (Local Tool Tester)](#developer-console-local-tool-tester)
|
|
@@ -268,73 +268,73 @@ The server exposes a special `unifi_tool_index` tool that returns a complete lis
|
|
|
268
268
|
- Dynamic client configuration
|
|
269
269
|
- IDE autocomplete support
|
|
270
270
|
|
|
271
|
-
###
|
|
271
|
+
### Tool Execution
|
|
272
272
|
|
|
273
|
-
|
|
273
|
+
The server provides two execution modes for discovered tools:
|
|
274
274
|
|
|
275
|
-
**
|
|
275
|
+
**Single Tool Execution (synchronous):**
|
|
276
276
|
```json
|
|
277
277
|
{
|
|
278
|
-
"name": "
|
|
278
|
+
"name": "unifi_execute",
|
|
279
279
|
"arguments": {
|
|
280
|
-
"tool": "
|
|
281
|
-
"arguments": {
|
|
282
|
-
"mac_address": "aa:bb:cc:dd:ee:ff",
|
|
283
|
-
"confirm": true
|
|
284
|
-
}
|
|
280
|
+
"tool": "unifi_list_clients",
|
|
281
|
+
"arguments": {}
|
|
285
282
|
}
|
|
286
283
|
}
|
|
287
284
|
```
|
|
288
285
|
|
|
289
|
-
**
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
"jobId": "af33b233cbdc860c"
|
|
293
|
-
}
|
|
294
|
-
```
|
|
286
|
+
**Batch Execution (parallel, async):**
|
|
287
|
+
|
|
288
|
+
For bulk operations or long-running tasks, use batch mode:
|
|
295
289
|
|
|
296
|
-
**Check job status:**
|
|
297
290
|
```json
|
|
298
291
|
{
|
|
299
|
-
"name": "
|
|
292
|
+
"name": "unifi_batch",
|
|
300
293
|
"arguments": {
|
|
301
|
-
"
|
|
294
|
+
"operations": [
|
|
295
|
+
{"tool": "unifi_get_client_details", "arguments": {"mac": "aa:bb:cc:dd:ee:ff"}},
|
|
296
|
+
{"tool": "unifi_get_client_details", "arguments": {"mac": "11:22:33:44:55:66"}}
|
|
297
|
+
]
|
|
302
298
|
}
|
|
303
299
|
}
|
|
304
300
|
```
|
|
305
301
|
|
|
306
|
-
**Response
|
|
302
|
+
**Response:**
|
|
307
303
|
```json
|
|
308
304
|
{
|
|
309
|
-
"
|
|
310
|
-
|
|
305
|
+
"jobs": [
|
|
306
|
+
{"index": 0, "tool": "unifi_get_client_details", "jobId": "af33b233cbdc860c"},
|
|
307
|
+
{"index": 1, "tool": "unifi_get_client_details", "jobId": "bf44c344dcde971d"}
|
|
308
|
+
],
|
|
309
|
+
"message": "Started 2 operation(s). Use unifi_batch_status to check progress."
|
|
311
310
|
}
|
|
312
311
|
```
|
|
313
312
|
|
|
314
|
-
**
|
|
313
|
+
**Check batch status:**
|
|
315
314
|
```json
|
|
316
315
|
{
|
|
317
|
-
"
|
|
318
|
-
"
|
|
319
|
-
|
|
320
|
-
|
|
316
|
+
"name": "unifi_batch_status",
|
|
317
|
+
"arguments": {
|
|
318
|
+
"jobIds": ["af33b233cbdc860c", "bf44c344dcde971d"]
|
|
319
|
+
}
|
|
321
320
|
}
|
|
322
321
|
```
|
|
323
322
|
|
|
324
|
-
**Response
|
|
323
|
+
**Response:**
|
|
325
324
|
```json
|
|
326
325
|
{
|
|
327
|
-
"
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
326
|
+
"jobs": [
|
|
327
|
+
{"jobId": "af33b233cbdc860c", "status": "done", "result": {...}},
|
|
328
|
+
{"jobId": "bf44c344dcde971d", "status": "done", "result": {...}}
|
|
329
|
+
]
|
|
331
330
|
}
|
|
332
331
|
```
|
|
333
332
|
|
|
334
333
|
**Notes:**
|
|
334
|
+
- Use `unifi_execute` for single operations (returns result directly)
|
|
335
|
+
- Use `unifi_batch` + `unifi_batch_status` for parallel/bulk operations
|
|
335
336
|
- Jobs are stored in-memory only (no persistence)
|
|
336
337
|
- Job IDs are unique per server session
|
|
337
|
-
- Failed jobs capture exception details in the `error` field
|
|
338
338
|
|
|
339
339
|
### Using with Claude Desktop
|
|
340
340
|
|
|
@@ -361,22 +361,32 @@ Practical examples showing programmatic usage:
|
|
|
361
361
|
```python
|
|
362
362
|
from mcp import ClientSession, stdio_client
|
|
363
363
|
|
|
364
|
-
#
|
|
365
|
-
|
|
364
|
+
# Discover tools
|
|
365
|
+
tools = await session.call_tool("unifi_tool_index", {})
|
|
366
|
+
|
|
367
|
+
# Execute a single tool (returns result directly)
|
|
368
|
+
result = await session.call_tool("unifi_execute", {
|
|
369
|
+
"tool": "unifi_list_clients",
|
|
370
|
+
"arguments": {}
|
|
371
|
+
})
|
|
366
372
|
|
|
367
|
-
#
|
|
368
|
-
|
|
369
|
-
"
|
|
370
|
-
|
|
373
|
+
# Batch execution for parallel operations
|
|
374
|
+
batch = await session.call_tool("unifi_batch", {
|
|
375
|
+
"operations": [
|
|
376
|
+
{"tool": "unifi_get_client_details", "arguments": {"mac": "..."}},
|
|
377
|
+
{"tool": "unifi_get_device_details", "arguments": {"mac": "..."}}
|
|
378
|
+
]
|
|
371
379
|
})
|
|
372
380
|
|
|
373
|
-
# Check
|
|
374
|
-
status = await session.call_tool("
|
|
381
|
+
# Check batch status
|
|
382
|
+
status = await session.call_tool("unifi_batch_status", {
|
|
383
|
+
"jobIds": [j["jobId"] for j in batch["jobs"]]
|
|
384
|
+
})
|
|
375
385
|
```
|
|
376
386
|
|
|
377
387
|
**Three complete examples:**
|
|
378
388
|
- `query_tool_index.py` - Discover available tools
|
|
379
|
-
- `use_async_jobs.py` -
|
|
389
|
+
- `use_async_jobs.py` - Batch operations and status checking
|
|
380
390
|
- `programmatic_client.py` - Build custom Python clients
|
|
381
391
|
|
|
382
392
|
See [`examples/python/README.md`](examples/python/README.md) for complete examples.
|
|
@@ -393,15 +403,18 @@ The server advertises its capabilities via an MCP identity file at [`.well-known
|
|
|
393
403
|
"capabilities": {
|
|
394
404
|
"tools": true,
|
|
395
405
|
"tool_index": true,
|
|
396
|
-
"
|
|
406
|
+
"batch_operations": true
|
|
397
407
|
},
|
|
398
408
|
"features": {
|
|
399
409
|
"tool_index": {
|
|
400
410
|
"tool": "unifi_tool_index"
|
|
401
411
|
},
|
|
402
|
-
"
|
|
403
|
-
"
|
|
404
|
-
|
|
412
|
+
"execution": {
|
|
413
|
+
"tool": "unifi_execute"
|
|
414
|
+
},
|
|
415
|
+
"batch_operations": {
|
|
416
|
+
"start_tool": "unifi_batch",
|
|
417
|
+
"status_tool": "unifi_batch_status"
|
|
405
418
|
}
|
|
406
419
|
}
|
|
407
420
|
}
|
|
@@ -522,6 +535,43 @@ The server merges settings from **environment variables**, an optional `.env` fi
|
|
|
522
535
|
| `UNIFI_CONTROLLER_TYPE` | Controller API path type: `auto` (detect), `proxy` (UniFi OS), `direct` (standalone). Default `auto` |
|
|
523
536
|
| `UNIFI_MCP_HTTP_ENABLED` | Set `true` to enable optional HTTP SSE server (default `false`) |
|
|
524
537
|
| `UNIFI_AUTO_CONFIRM` | Set `true` to auto-confirm all mutating operations (skips preview step). Ideal for workflow automation (n8n, Make, Zapier). Default `false` |
|
|
538
|
+
| `UNIFI_TOOL_REGISTRATION_MODE` | Tool loading mode: `lazy` (default), `eager`, or `meta_only`. See [Context Optimization](#context-optimization) |
|
|
539
|
+
| `UNIFI_ENABLED_CATEGORIES` | Comma-separated list of tool categories to load (eager mode). See table below |
|
|
540
|
+
| `UNIFI_ENABLED_TOOLS` | Comma-separated list of specific tool names to register (eager mode) |
|
|
541
|
+
|
|
542
|
+
### Tool Categories (for UNIFI_ENABLED_CATEGORIES)
|
|
543
|
+
|
|
544
|
+
When using eager mode with category filtering, these are the valid category names:
|
|
545
|
+
|
|
546
|
+
| Category | Description | Example Tools |
|
|
547
|
+
|----------|-------------|---------------|
|
|
548
|
+
| `clients` | Client listing, blocking, guest auth | `unifi_list_clients`, `unifi_block_client` |
|
|
549
|
+
| `config` | Configuration management | - |
|
|
550
|
+
| `devices` | Device listing, reboot, locate, upgrade | `unifi_list_devices`, `unifi_reboot_device` |
|
|
551
|
+
| `events` | Events and alarms | `unifi_list_events`, `unifi_list_alarms` |
|
|
552
|
+
| `firewall` | Firewall rules and groups | `unifi_list_firewall_rules`, `unifi_create_firewall_rule` |
|
|
553
|
+
| `hotspot` | Vouchers for guest network | `unifi_list_vouchers`, `unifi_create_voucher` |
|
|
554
|
+
| `network` | Network/VLAN management | `unifi_list_networks`, `unifi_create_network` |
|
|
555
|
+
| `port_forwards` | Port forwarding rules | `unifi_list_port_forwards` |
|
|
556
|
+
| `qos` | QoS/traffic shaping rules | `unifi_list_qos_rules`, `unifi_create_qos_rule` |
|
|
557
|
+
| `routing` | Static routes (V1 API) | `unifi_list_routes`, `unifi_create_route` |
|
|
558
|
+
| `stats` | Statistics and metrics | `unifi_get_client_stats`, `unifi_get_device_stats` |
|
|
559
|
+
| `system` | System info, health, settings | `unifi_get_system_info`, `unifi_get_network_health` |
|
|
560
|
+
| `traffic_routes` | Policy-based routing (V2 API) | `unifi_list_traffic_routes` |
|
|
561
|
+
| `usergroups` | Bandwidth profiles/user groups | `unifi_list_usergroups`, `unifi_create_usergroup` |
|
|
562
|
+
| `vpn` | VPN servers and clients | `unifi_list_vpn_servers`, `unifi_list_vpn_clients` |
|
|
563
|
+
|
|
564
|
+
**Example usage:**
|
|
565
|
+
```bash
|
|
566
|
+
# Load only client and system tools
|
|
567
|
+
export UNIFI_TOOL_REGISTRATION_MODE=eager
|
|
568
|
+
export UNIFI_ENABLED_CATEGORIES=clients,system
|
|
569
|
+
|
|
570
|
+
# Or load specific tools only
|
|
571
|
+
export UNIFI_ENABLED_TOOLS=unifi_list_clients,unifi_list_devices,unifi_get_system_info
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
**Note:** Tools may also be filtered by the `permissions` section in config.yaml (e.g., `clients.update: false` blocks mutating client tools).
|
|
525
575
|
|
|
526
576
|
### Controller Type Detection
|
|
527
577
|
|
|
@@ -844,6 +894,37 @@ See [docs/permissions.md](docs/permissions.md) for complete documentation includ
|
|
|
844
894
|
* `unifi_force_reconnect_client`
|
|
845
895
|
* `unifi_authorize_guest`
|
|
846
896
|
* `unifi_unauthorize_guest`
|
|
897
|
+
* `unifi_set_client_ip_settings`
|
|
898
|
+
|
|
899
|
+
### Events & Alarms
|
|
900
|
+
|
|
901
|
+
* `unifi_list_events`
|
|
902
|
+
* `unifi_list_alarms`
|
|
903
|
+
* `unifi_archive_alarm`
|
|
904
|
+
* `unifi_archive_all_alarms`
|
|
905
|
+
* `unifi_get_event_types`
|
|
906
|
+
|
|
907
|
+
### Routing (Static Routes)
|
|
908
|
+
|
|
909
|
+
* `unifi_list_routes`
|
|
910
|
+
* `unifi_get_route_details`
|
|
911
|
+
* `unifi_create_route`
|
|
912
|
+
* `unifi_update_route`
|
|
913
|
+
* `unifi_list_active_routes`
|
|
914
|
+
|
|
915
|
+
### Hotspot (Vouchers)
|
|
916
|
+
|
|
917
|
+
* `unifi_list_vouchers`
|
|
918
|
+
* `unifi_get_voucher_details`
|
|
919
|
+
* `unifi_create_voucher`
|
|
920
|
+
* `unifi_revoke_voucher`
|
|
921
|
+
|
|
922
|
+
### User Groups
|
|
923
|
+
|
|
924
|
+
* `unifi_list_usergroups`
|
|
925
|
+
* `unifi_get_usergroup_details`
|
|
926
|
+
* `unifi_create_usergroup`
|
|
927
|
+
* `unifi_update_usergroup`
|
|
847
928
|
|
|
848
929
|
### Statistics & Alerts
|
|
849
930
|
|
|
@@ -1020,9 +1101,9 @@ uv run python devtools/dev_console.py
|
|
|
1020
1101
|
|
|
1021
1102
|
# You'll see a menu of all tools including:
|
|
1022
1103
|
# - unifi_tool_index (list all tools with schemas)
|
|
1023
|
-
# -
|
|
1024
|
-
# -
|
|
1025
|
-
# - All
|
|
1104
|
+
# - unifi_execute (run any discovered tool)
|
|
1105
|
+
# - unifi_batch / unifi_batch_status (parallel operations)
|
|
1106
|
+
# - All 80+ UniFi tools (clients, devices, networks, etc.)
|
|
1026
1107
|
```
|
|
1027
1108
|
|
|
1028
1109
|
**4. Test with Python examples:**
|
|
@@ -29,7 +29,7 @@ A self-hosted [Model Context Protocol](https://github.com/modelcontextprotocol)
|
|
|
29
29
|
* [Overview](#overview)
|
|
30
30
|
* [Context Optimization](#context-optimization)
|
|
31
31
|
* [Tool Index](#tool-index)
|
|
32
|
-
* [
|
|
32
|
+
* [Tool Execution](#tool-execution)
|
|
33
33
|
* [Runtime Configuration](#runtime-configuration)
|
|
34
34
|
* [Diagnostics (Advanced Logging)](#diagnostics-advanced-logging)
|
|
35
35
|
* [Developer Console (Local Tool Tester)](#developer-console-local-tool-tester)
|
|
@@ -252,73 +252,73 @@ The server exposes a special `unifi_tool_index` tool that returns a complete lis
|
|
|
252
252
|
- Dynamic client configuration
|
|
253
253
|
- IDE autocomplete support
|
|
254
254
|
|
|
255
|
-
###
|
|
255
|
+
### Tool Execution
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
The server provides two execution modes for discovered tools:
|
|
258
258
|
|
|
259
|
-
**
|
|
259
|
+
**Single Tool Execution (synchronous):**
|
|
260
260
|
```json
|
|
261
261
|
{
|
|
262
|
-
"name": "
|
|
262
|
+
"name": "unifi_execute",
|
|
263
263
|
"arguments": {
|
|
264
|
-
"tool": "
|
|
265
|
-
"arguments": {
|
|
266
|
-
"mac_address": "aa:bb:cc:dd:ee:ff",
|
|
267
|
-
"confirm": true
|
|
268
|
-
}
|
|
264
|
+
"tool": "unifi_list_clients",
|
|
265
|
+
"arguments": {}
|
|
269
266
|
}
|
|
270
267
|
}
|
|
271
268
|
```
|
|
272
269
|
|
|
273
|
-
**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
"jobId": "af33b233cbdc860c"
|
|
277
|
-
}
|
|
278
|
-
```
|
|
270
|
+
**Batch Execution (parallel, async):**
|
|
271
|
+
|
|
272
|
+
For bulk operations or long-running tasks, use batch mode:
|
|
279
273
|
|
|
280
|
-
**Check job status:**
|
|
281
274
|
```json
|
|
282
275
|
{
|
|
283
|
-
"name": "
|
|
276
|
+
"name": "unifi_batch",
|
|
284
277
|
"arguments": {
|
|
285
|
-
"
|
|
278
|
+
"operations": [
|
|
279
|
+
{"tool": "unifi_get_client_details", "arguments": {"mac": "aa:bb:cc:dd:ee:ff"}},
|
|
280
|
+
{"tool": "unifi_get_client_details", "arguments": {"mac": "11:22:33:44:55:66"}}
|
|
281
|
+
]
|
|
286
282
|
}
|
|
287
283
|
}
|
|
288
284
|
```
|
|
289
285
|
|
|
290
|
-
**Response
|
|
286
|
+
**Response:**
|
|
291
287
|
```json
|
|
292
288
|
{
|
|
293
|
-
"
|
|
294
|
-
|
|
289
|
+
"jobs": [
|
|
290
|
+
{"index": 0, "tool": "unifi_get_client_details", "jobId": "af33b233cbdc860c"},
|
|
291
|
+
{"index": 1, "tool": "unifi_get_client_details", "jobId": "bf44c344dcde971d"}
|
|
292
|
+
],
|
|
293
|
+
"message": "Started 2 operation(s). Use unifi_batch_status to check progress."
|
|
295
294
|
}
|
|
296
295
|
```
|
|
297
296
|
|
|
298
|
-
**
|
|
297
|
+
**Check batch status:**
|
|
299
298
|
```json
|
|
300
299
|
{
|
|
301
|
-
"
|
|
302
|
-
"
|
|
303
|
-
|
|
304
|
-
|
|
300
|
+
"name": "unifi_batch_status",
|
|
301
|
+
"arguments": {
|
|
302
|
+
"jobIds": ["af33b233cbdc860c", "bf44c344dcde971d"]
|
|
303
|
+
}
|
|
305
304
|
}
|
|
306
305
|
```
|
|
307
306
|
|
|
308
|
-
**Response
|
|
307
|
+
**Response:**
|
|
309
308
|
```json
|
|
310
309
|
{
|
|
311
|
-
"
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
310
|
+
"jobs": [
|
|
311
|
+
{"jobId": "af33b233cbdc860c", "status": "done", "result": {...}},
|
|
312
|
+
{"jobId": "bf44c344dcde971d", "status": "done", "result": {...}}
|
|
313
|
+
]
|
|
315
314
|
}
|
|
316
315
|
```
|
|
317
316
|
|
|
318
317
|
**Notes:**
|
|
318
|
+
- Use `unifi_execute` for single operations (returns result directly)
|
|
319
|
+
- Use `unifi_batch` + `unifi_batch_status` for parallel/bulk operations
|
|
319
320
|
- Jobs are stored in-memory only (no persistence)
|
|
320
321
|
- Job IDs are unique per server session
|
|
321
|
-
- Failed jobs capture exception details in the `error` field
|
|
322
322
|
|
|
323
323
|
### Using with Claude Desktop
|
|
324
324
|
|
|
@@ -345,22 +345,32 @@ Practical examples showing programmatic usage:
|
|
|
345
345
|
```python
|
|
346
346
|
from mcp import ClientSession, stdio_client
|
|
347
347
|
|
|
348
|
-
#
|
|
349
|
-
|
|
348
|
+
# Discover tools
|
|
349
|
+
tools = await session.call_tool("unifi_tool_index", {})
|
|
350
|
+
|
|
351
|
+
# Execute a single tool (returns result directly)
|
|
352
|
+
result = await session.call_tool("unifi_execute", {
|
|
353
|
+
"tool": "unifi_list_clients",
|
|
354
|
+
"arguments": {}
|
|
355
|
+
})
|
|
350
356
|
|
|
351
|
-
#
|
|
352
|
-
|
|
353
|
-
"
|
|
354
|
-
|
|
357
|
+
# Batch execution for parallel operations
|
|
358
|
+
batch = await session.call_tool("unifi_batch", {
|
|
359
|
+
"operations": [
|
|
360
|
+
{"tool": "unifi_get_client_details", "arguments": {"mac": "..."}},
|
|
361
|
+
{"tool": "unifi_get_device_details", "arguments": {"mac": "..."}}
|
|
362
|
+
]
|
|
355
363
|
})
|
|
356
364
|
|
|
357
|
-
# Check
|
|
358
|
-
status = await session.call_tool("
|
|
365
|
+
# Check batch status
|
|
366
|
+
status = await session.call_tool("unifi_batch_status", {
|
|
367
|
+
"jobIds": [j["jobId"] for j in batch["jobs"]]
|
|
368
|
+
})
|
|
359
369
|
```
|
|
360
370
|
|
|
361
371
|
**Three complete examples:**
|
|
362
372
|
- `query_tool_index.py` - Discover available tools
|
|
363
|
-
- `use_async_jobs.py` -
|
|
373
|
+
- `use_async_jobs.py` - Batch operations and status checking
|
|
364
374
|
- `programmatic_client.py` - Build custom Python clients
|
|
365
375
|
|
|
366
376
|
See [`examples/python/README.md`](examples/python/README.md) for complete examples.
|
|
@@ -377,15 +387,18 @@ The server advertises its capabilities via an MCP identity file at [`.well-known
|
|
|
377
387
|
"capabilities": {
|
|
378
388
|
"tools": true,
|
|
379
389
|
"tool_index": true,
|
|
380
|
-
"
|
|
390
|
+
"batch_operations": true
|
|
381
391
|
},
|
|
382
392
|
"features": {
|
|
383
393
|
"tool_index": {
|
|
384
394
|
"tool": "unifi_tool_index"
|
|
385
395
|
},
|
|
386
|
-
"
|
|
387
|
-
"
|
|
388
|
-
|
|
396
|
+
"execution": {
|
|
397
|
+
"tool": "unifi_execute"
|
|
398
|
+
},
|
|
399
|
+
"batch_operations": {
|
|
400
|
+
"start_tool": "unifi_batch",
|
|
401
|
+
"status_tool": "unifi_batch_status"
|
|
389
402
|
}
|
|
390
403
|
}
|
|
391
404
|
}
|
|
@@ -506,6 +519,43 @@ The server merges settings from **environment variables**, an optional `.env` fi
|
|
|
506
519
|
| `UNIFI_CONTROLLER_TYPE` | Controller API path type: `auto` (detect), `proxy` (UniFi OS), `direct` (standalone). Default `auto` |
|
|
507
520
|
| `UNIFI_MCP_HTTP_ENABLED` | Set `true` to enable optional HTTP SSE server (default `false`) |
|
|
508
521
|
| `UNIFI_AUTO_CONFIRM` | Set `true` to auto-confirm all mutating operations (skips preview step). Ideal for workflow automation (n8n, Make, Zapier). Default `false` |
|
|
522
|
+
| `UNIFI_TOOL_REGISTRATION_MODE` | Tool loading mode: `lazy` (default), `eager`, or `meta_only`. See [Context Optimization](#context-optimization) |
|
|
523
|
+
| `UNIFI_ENABLED_CATEGORIES` | Comma-separated list of tool categories to load (eager mode). See table below |
|
|
524
|
+
| `UNIFI_ENABLED_TOOLS` | Comma-separated list of specific tool names to register (eager mode) |
|
|
525
|
+
|
|
526
|
+
### Tool Categories (for UNIFI_ENABLED_CATEGORIES)
|
|
527
|
+
|
|
528
|
+
When using eager mode with category filtering, these are the valid category names:
|
|
529
|
+
|
|
530
|
+
| Category | Description | Example Tools |
|
|
531
|
+
|----------|-------------|---------------|
|
|
532
|
+
| `clients` | Client listing, blocking, guest auth | `unifi_list_clients`, `unifi_block_client` |
|
|
533
|
+
| `config` | Configuration management | - |
|
|
534
|
+
| `devices` | Device listing, reboot, locate, upgrade | `unifi_list_devices`, `unifi_reboot_device` |
|
|
535
|
+
| `events` | Events and alarms | `unifi_list_events`, `unifi_list_alarms` |
|
|
536
|
+
| `firewall` | Firewall rules and groups | `unifi_list_firewall_rules`, `unifi_create_firewall_rule` |
|
|
537
|
+
| `hotspot` | Vouchers for guest network | `unifi_list_vouchers`, `unifi_create_voucher` |
|
|
538
|
+
| `network` | Network/VLAN management | `unifi_list_networks`, `unifi_create_network` |
|
|
539
|
+
| `port_forwards` | Port forwarding rules | `unifi_list_port_forwards` |
|
|
540
|
+
| `qos` | QoS/traffic shaping rules | `unifi_list_qos_rules`, `unifi_create_qos_rule` |
|
|
541
|
+
| `routing` | Static routes (V1 API) | `unifi_list_routes`, `unifi_create_route` |
|
|
542
|
+
| `stats` | Statistics and metrics | `unifi_get_client_stats`, `unifi_get_device_stats` |
|
|
543
|
+
| `system` | System info, health, settings | `unifi_get_system_info`, `unifi_get_network_health` |
|
|
544
|
+
| `traffic_routes` | Policy-based routing (V2 API) | `unifi_list_traffic_routes` |
|
|
545
|
+
| `usergroups` | Bandwidth profiles/user groups | `unifi_list_usergroups`, `unifi_create_usergroup` |
|
|
546
|
+
| `vpn` | VPN servers and clients | `unifi_list_vpn_servers`, `unifi_list_vpn_clients` |
|
|
547
|
+
|
|
548
|
+
**Example usage:**
|
|
549
|
+
```bash
|
|
550
|
+
# Load only client and system tools
|
|
551
|
+
export UNIFI_TOOL_REGISTRATION_MODE=eager
|
|
552
|
+
export UNIFI_ENABLED_CATEGORIES=clients,system
|
|
553
|
+
|
|
554
|
+
# Or load specific tools only
|
|
555
|
+
export UNIFI_ENABLED_TOOLS=unifi_list_clients,unifi_list_devices,unifi_get_system_info
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
**Note:** Tools may also be filtered by the `permissions` section in config.yaml (e.g., `clients.update: false` blocks mutating client tools).
|
|
509
559
|
|
|
510
560
|
### Controller Type Detection
|
|
511
561
|
|
|
@@ -828,6 +878,37 @@ See [docs/permissions.md](docs/permissions.md) for complete documentation includ
|
|
|
828
878
|
* `unifi_force_reconnect_client`
|
|
829
879
|
* `unifi_authorize_guest`
|
|
830
880
|
* `unifi_unauthorize_guest`
|
|
881
|
+
* `unifi_set_client_ip_settings`
|
|
882
|
+
|
|
883
|
+
### Events & Alarms
|
|
884
|
+
|
|
885
|
+
* `unifi_list_events`
|
|
886
|
+
* `unifi_list_alarms`
|
|
887
|
+
* `unifi_archive_alarm`
|
|
888
|
+
* `unifi_archive_all_alarms`
|
|
889
|
+
* `unifi_get_event_types`
|
|
890
|
+
|
|
891
|
+
### Routing (Static Routes)
|
|
892
|
+
|
|
893
|
+
* `unifi_list_routes`
|
|
894
|
+
* `unifi_get_route_details`
|
|
895
|
+
* `unifi_create_route`
|
|
896
|
+
* `unifi_update_route`
|
|
897
|
+
* `unifi_list_active_routes`
|
|
898
|
+
|
|
899
|
+
### Hotspot (Vouchers)
|
|
900
|
+
|
|
901
|
+
* `unifi_list_vouchers`
|
|
902
|
+
* `unifi_get_voucher_details`
|
|
903
|
+
* `unifi_create_voucher`
|
|
904
|
+
* `unifi_revoke_voucher`
|
|
905
|
+
|
|
906
|
+
### User Groups
|
|
907
|
+
|
|
908
|
+
* `unifi_list_usergroups`
|
|
909
|
+
* `unifi_get_usergroup_details`
|
|
910
|
+
* `unifi_create_usergroup`
|
|
911
|
+
* `unifi_update_usergroup`
|
|
831
912
|
|
|
832
913
|
### Statistics & Alerts
|
|
833
914
|
|
|
@@ -1004,9 +1085,9 @@ uv run python devtools/dev_console.py
|
|
|
1004
1085
|
|
|
1005
1086
|
# You'll see a menu of all tools including:
|
|
1006
1087
|
# - unifi_tool_index (list all tools with schemas)
|
|
1007
|
-
# -
|
|
1008
|
-
# -
|
|
1009
|
-
# - All
|
|
1088
|
+
# - unifi_execute (run any discovered tool)
|
|
1089
|
+
# - unifi_batch / unifi_batch_status (parallel operations)
|
|
1090
|
+
# - All 80+ UniFi tools (clients, devices, networks, etc.)
|
|
1010
1091
|
```
|
|
1011
1092
|
|
|
1012
1093
|
**4. Test with Python examples:**
|
|
@@ -12,13 +12,43 @@ server:
|
|
|
12
12
|
port: 3000
|
|
13
13
|
log_level: INFO
|
|
14
14
|
|
|
15
|
-
# Tool registration mode
|
|
15
|
+
# Tool registration mode
|
|
16
16
|
# Options: eager, lazy, meta_only
|
|
17
|
-
# - eager: Register all
|
|
18
|
-
# - lazy: Register
|
|
19
|
-
# - meta_only: Register only
|
|
17
|
+
# - eager: Register all tools immediately - Best for dev console, automation
|
|
18
|
+
# - lazy: Register meta-tools, load others on-demand - RECOMMENDED for LLMs
|
|
19
|
+
# - meta_only: Register only meta-tools, manual discovery - Maximum context savings
|
|
20
20
|
tool_registration_mode: ${oc.env:UNIFI_TOOL_REGISTRATION_MODE,lazy}
|
|
21
21
|
|
|
22
|
+
# Tool filtering (optional, for eager mode)
|
|
23
|
+
# Use these to limit which tools are registered for automation/n8n workflows
|
|
24
|
+
#
|
|
25
|
+
# enabled_categories: Only load tools from these categories (module names in src/tools/)
|
|
26
|
+
# Valid values:
|
|
27
|
+
# - clients # Client listing, blocking, guest auth
|
|
28
|
+
# - config # Configuration management
|
|
29
|
+
# - devices # Device listing, reboot, locate, upgrade
|
|
30
|
+
# - events # Events and alarms
|
|
31
|
+
# - firewall # Firewall rules and groups
|
|
32
|
+
# - hotspot # Vouchers for guest network
|
|
33
|
+
# - network # Network/VLAN management
|
|
34
|
+
# - port_forwards # Port forwarding rules
|
|
35
|
+
# - qos # QoS/traffic shaping rules
|
|
36
|
+
# - routing # Static routes (V1 API)
|
|
37
|
+
# - stats # Statistics and metrics
|
|
38
|
+
# - system # System info, health, settings
|
|
39
|
+
# - traffic_routes # Policy-based routing (V2 API)
|
|
40
|
+
# - usergroups # Bandwidth profiles/user groups
|
|
41
|
+
# - vpn # VPN servers and clients
|
|
42
|
+
# Example: "clients,devices,system" or ["clients", "devices", "system"]
|
|
43
|
+
#
|
|
44
|
+
# enabled_tools: Only register these specific tools (use with enabled_categories or alone)
|
|
45
|
+
# Example: "unifi_list_clients,unifi_list_devices" or ["unifi_list_clients", "unifi_list_devices"]
|
|
46
|
+
#
|
|
47
|
+
# Note: Tools may also be filtered by the permissions section below (e.g., update: false)
|
|
48
|
+
# If neither is set, all tools are registered (default behavior)
|
|
49
|
+
enabled_categories: ${oc.env:UNIFI_ENABLED_CATEGORIES,null}
|
|
50
|
+
enabled_tools: ${oc.env:UNIFI_ENABLED_TOOLS,null}
|
|
51
|
+
|
|
22
52
|
http:
|
|
23
53
|
enabled: ${oc.env:UNIFI_MCP_HTTP_ENABLED,false}
|
|
24
54
|
diagnostics:
|