|
| 1 | +# Claude Desktop Integration |
| 2 | + |
| 3 | +Control your UniFi network using natural language through Claude Desktop. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +UI-CLI includes an MCP (Model Context Protocol) server that enables Claude Desktop to manage your UniFi infrastructure. Ask questions like: |
| 8 | + |
| 9 | +- "How many devices are connected to my network?" |
| 10 | +- "What's my network health status?" |
| 11 | +- "Block the kids iPad" |
| 12 | +- "Restart the garage access point" |
| 13 | + |
| 14 | +## Architecture |
| 15 | + |
| 16 | +``` |
| 17 | +┌─────────────────┐ |
| 18 | +│ Claude Desktop │ |
| 19 | +└────────┬────────┘ |
| 20 | + │ MCP Protocol (stdio) |
| 21 | + ▼ |
| 22 | +┌─────────────────┐ |
| 23 | +│ MCP Server │ ← 16 AI-optimized tools |
| 24 | +│ (ui_mcp) │ |
| 25 | +└────────┬────────┘ |
| 26 | + │ subprocess |
| 27 | + ▼ |
| 28 | +┌─────────────────┐ |
| 29 | +│ UI CLI │ ← All business logic |
| 30 | +│ (ui_cli) │ |
| 31 | +└─────────────────┘ |
| 32 | +``` |
| 33 | + |
| 34 | +## Installation |
| 35 | + |
| 36 | +### Prerequisites |
| 37 | + |
| 38 | +- Python 3.11+ with conda environment `ui-cli` |
| 39 | +- Claude Desktop installed |
| 40 | +- UniFi credentials configured in `.env` |
| 41 | + |
| 42 | +### Setup |
| 43 | + |
| 44 | +```bash |
| 45 | +# Install MCP server to Claude Desktop |
| 46 | +./ui mcp install |
| 47 | + |
| 48 | +# Verify installation |
| 49 | +./ui mcp check |
| 50 | + |
| 51 | +# View current config |
| 52 | +./ui mcp show |
| 53 | +``` |
| 54 | + |
| 55 | +After installation, restart Claude Desktop to load the new tools. |
| 56 | + |
| 57 | +## Available Tools |
| 58 | + |
| 59 | +### Status & Health |
| 60 | + |
| 61 | +| Tool | Description | Example Prompt | |
| 62 | +|------|-------------|----------------| |
| 63 | +| `network_status` | Check API connectivity | "Is my network API working?" | |
| 64 | +| `network_health` | Site health summary | "What's my network health?" | |
| 65 | +| `internet_speed` | Last speed test result | "What's my internet speed?" | |
| 66 | +| `run_speedtest` | Run new speed test | "Run a speed test" | |
| 67 | +| `isp_performance` | ISP metrics over time | "How's my ISP been performing?" | |
| 68 | + |
| 69 | +### Counts & Lists |
| 70 | + |
| 71 | +| Tool | Description | Example Prompt | |
| 72 | +|------|-------------|----------------| |
| 73 | +| `client_count` | Count clients by category | "How many devices are connected?" | |
| 74 | +| `device_list` | List UniFi devices | "What UniFi devices do I have?" | |
| 75 | +| `network_list` | List networks/VLANs | "Show my networks" | |
| 76 | + |
| 77 | +### Lookups |
| 78 | + |
| 79 | +| Tool | Description | Example Prompt | |
| 80 | +|------|-------------|----------------| |
| 81 | +| `find_client` | Find client by name/MAC | "Find my iPhone" | |
| 82 | +| `find_device` | Find device by name/MAC/IP | "Show the living room AP" | |
| 83 | +| `client_status` | Check if client is online/blocked | "Is the TV online?" | |
| 84 | + |
| 85 | +### Actions |
| 86 | + |
| 87 | +| Tool | Description | Example Prompt | |
| 88 | +|------|-------------|----------------| |
| 89 | +| `block_client` | Block from network | "Block the kids iPad" | |
| 90 | +| `unblock_client` | Restore access | "Unblock the kids iPad" | |
| 91 | +| `kick_client` | Force disconnect | "Disconnect my laptop" | |
| 92 | +| `restart_device` | Reboot device | "Restart the garage AP" | |
| 93 | +| `create_voucher` | Create guest WiFi code | "Create a guest WiFi voucher" | |
| 94 | + |
| 95 | +## Example Conversations |
| 96 | + |
| 97 | +### Checking Network Status |
| 98 | + |
| 99 | +> **You:** How many devices are connected to my network? |
| 100 | +> |
| 101 | +> **Claude:** You have 87 devices connected: |
| 102 | +> - 17 wired clients |
| 103 | +> - 70 wireless clients |
| 104 | +> - 52 on WiFi 6, 18 on WiFi 5 |
| 105 | +
|
| 106 | +### Managing Clients |
| 107 | + |
| 108 | +> **You:** Block the kids iPad |
| 109 | +> |
| 110 | +> **Claude:** I'll block that device. Looking for "kids iPad"... |
| 111 | +> |
| 112 | +> Found: Kids-iPad (MAC: aa:bb:cc:dd:ee:ff) |
| 113 | +> |
| 114 | +> Done! Kids-iPad has been blocked from the network. |
| 115 | +
|
| 116 | +### Device Management |
| 117 | + |
| 118 | +> **You:** Restart the garage access point |
| 119 | +> |
| 120 | +> **Claude:** I'll restart that device. Looking for "garage"... |
| 121 | +> |
| 122 | +> Found: Garage-AP (U6-Lite) |
| 123 | +> |
| 124 | +> Restart initiated. The access point will be back online in about 2 minutes. |
| 125 | +
|
| 126 | +## Troubleshooting |
| 127 | + |
| 128 | +### Tools Not Appearing |
| 129 | + |
| 130 | +1. Restart Claude Desktop after running `./ui mcp install` |
| 131 | +2. Check that `.env` file exists with credentials |
| 132 | +3. Run `./ui mcp check` to verify setup |
| 133 | + |
| 134 | +### "Conda environment not found" |
| 135 | + |
| 136 | +Ensure the conda environment is activated when installing: |
| 137 | + |
| 138 | +```bash |
| 139 | +conda activate ui-cli |
| 140 | +./ui mcp install |
| 141 | +``` |
| 142 | + |
| 143 | +### Timeout Errors |
| 144 | + |
| 145 | +Some operations like speed tests take longer. Claude will wait up to 60 seconds for these operations. |
| 146 | + |
| 147 | +### View Logs |
| 148 | + |
| 149 | +Check MCP server logs in Claude Desktop: |
| 150 | + |
| 151 | +- **macOS:** `~/Library/Logs/Claude/mcp*.log` |
| 152 | + |
| 153 | +## Configuration |
| 154 | + |
| 155 | +The installer adds this to Claude Desktop's config (`~/Library/Application Support/Claude/claude_desktop_config.json`): |
| 156 | + |
| 157 | +```json |
| 158 | +{ |
| 159 | + "mcpServers": { |
| 160 | + "ui-cli": { |
| 161 | + "command": "/path/to/ui-cmd/scripts/mcp-server.sh", |
| 162 | + "args": [], |
| 163 | + "env": { |
| 164 | + "PYTHON_PATH": "/path/to/conda/envs/ui-cli/bin/python" |
| 165 | + } |
| 166 | + } |
| 167 | + } |
| 168 | +} |
| 169 | +``` |
| 170 | + |
| 171 | +## Security Notes |
| 172 | + |
| 173 | +- Credentials are stored in `.env` file (not in Claude Desktop config) |
| 174 | +- Claude will ask for confirmation before performing destructive actions |
| 175 | +- All operations are logged |
| 176 | + |
| 177 | +## Version |
| 178 | + |
| 179 | +Current MCP Server version: **0.2.0** (Tools Layer Architecture) |
0 commit comments