ui-network-mcp 0.1.0__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.
- ui_network_mcp-0.1.0/LICENSE +21 -0
- ui_network_mcp-0.1.0/PKG-INFO +263 -0
- ui_network_mcp-0.1.0/README.md +239 -0
- ui_network_mcp-0.1.0/pyproject.toml +66 -0
- ui_network_mcp-0.1.0/pyproject.toml.orig +48 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/__init__.py +19 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/client/__init__.py +5 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/client/errors.py +49 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/client/json_types.py +3 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/client/redaction.py +29 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/client/unifi_client.py +120 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/config.py +50 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/models/__init__.py +5 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/models/api_model.py +27 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/models/firewall/__init__.py +21 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/models/firewall/action.py +32 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/models/firewall/matching.py +137 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/models/firewall/policy.py +26 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/models/firewall/protocol.py +150 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/models/firewall/schedule.py +57 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/models/firewall/traffic_filters.py +132 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/__init__.py +31 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/client_search.py +39 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/client_summary.py +65 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/device_health.py +47 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/device_summary.py +6 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/firewall_overview.py +124 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/network_map.py +64 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/site_health.py +72 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/switch_ports.py +77 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/topology.py +46 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/unused_objects.py +78 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/voucher_summary.py +67 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/reports/wifi_overview.py +113 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/__init__.py +3 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/app.py +53 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/parameters.py +55 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/sites.py +48 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/__init__.py +44 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/acl.py +37 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/audit.py +46 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/clients.py +137 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/console.py +23 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/devices.py +152 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/dns.py +31 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/dpi.py +33 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/firewall.py +134 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/firewall_writes.py +220 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/health.py +49 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/hotspot.py +158 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/networks.py +77 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/switching.py +100 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/topology.py +26 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/vpn.py +39 -0
- ui_network_mcp-0.1.0/src/ui_network_mcp/server/tools/wifi.py +60 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Henrik Panhans
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ui-network-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for the UniFi Network API
|
|
5
|
+
Keywords: unifi,ubiquiti,mcp,model-context-protocol,network,firewall
|
|
6
|
+
Author: Henrik Panhans
|
|
7
|
+
Author-email: Henrik Panhans <henrik@panhans.dev>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Intended Audience :: System Administrators
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Topic :: System :: Networking
|
|
16
|
+
Requires-Dist: fastmcp>=4.0.10
|
|
17
|
+
Requires-Dist: httpx>=0.28.1
|
|
18
|
+
Requires-Dist: pydantic-settings>=2.15.0
|
|
19
|
+
Requires-Python: >=3.14, <3.15
|
|
20
|
+
Project-URL: Homepage, https://github.com/henrik-dmg/ui-network-mcp
|
|
21
|
+
Project-URL: Repository, https://github.com/henrik-dmg/ui-network-mcp
|
|
22
|
+
Project-URL: Issues, https://github.com/henrik-dmg/ui-network-mcp/issues
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# ui-network-mcp
|
|
26
|
+
|
|
27
|
+
An MCP server for the UniFi Network API (integration API, version 11.0.97). The server uses [FastMCP](https://gofastmcp.com).
|
|
28
|
+
The package on PyPI is [`ui-network-mcp`](https://pypi.org/project/ui-network-mcp/). Ubiquiti publishes the [API specification](https://developer.ui.com/network/v11.0.97/openapi.json).
|
|
29
|
+
|
|
30
|
+
This is not an official Ubiquiti project.
|
|
31
|
+
|
|
32
|
+
## Comparison with sirkirby/unifi-mcp
|
|
33
|
+
|
|
34
|
+
[sirkirby/unifi-mcp](https://github.com/sirkirby/unifi-mcp) is a larger MCP project for UniFi, with servers for UniFi Network, Protect, and Access.
|
|
35
|
+
The two projects use different APIs and different credentials. Thus each project is useful for different tasks.
|
|
36
|
+
The data about sirkirby/unifi-mcp is from November 2026.
|
|
37
|
+
|
|
38
|
+
| | This server | sirkirby/unifi-mcp |
|
|
39
|
+
|-|-|-|
|
|
40
|
+
| UniFi applications | Network | Network, Protect, and Access |
|
|
41
|
+
| API | Only the official integration API | Mostly the private controller API, and the integration API for some tools |
|
|
42
|
+
| Credentials | An API key, which can be read-only | The username and password of a local admin account without MFA. An API key alone gives only some read tools. |
|
|
43
|
+
| Network tools | Almost all read endpoints of the integration API, and combined report tools | 210 tools, and many of them use endpoints that the integration API does not have |
|
|
44
|
+
| Changes | Firewall policies, device and port actions, guest access, and Hotspot vouchers. The write tools are hidden until you set `UNIFI_ALLOW_WRITES` to `true`. | Most configuration areas. Each change shows a preview before the server applies it. |
|
|
45
|
+
| Secrets | WiFi passphrases are redacted | WiFi passphrases, VPN keys, and other secrets are redacted |
|
|
46
|
+
| Remote access | The UniFi cloud connector, with `UNIFI_CONSOLE_ID` | A Cloudflare Worker and a relay on the local network |
|
|
47
|
+
| Claude Code plugin | One plugin with 4 skills | One plugin for each UniFi application, with skills |
|
|
48
|
+
| Size | One small Python package | A monorepo with MCP servers, a REST and GraphQL server, a relay, and plugins |
|
|
49
|
+
|
|
50
|
+
Use this server if:
|
|
51
|
+
|
|
52
|
+
- You want to give the agent an API key, not an admin password. You can revoke an API key at any time, and a read-only key cannot change the network.
|
|
53
|
+
- You want a documented API. Ubiquiti publishes a specification for each version of the integration API. The private API has no public documentation and can change with a firmware update.
|
|
54
|
+
- You want remote access through the UniFi cloud connector, without a relay or another service.
|
|
55
|
+
- You want a server that is small enough to read and examine in full.
|
|
56
|
+
- You ask more questions about the network than you make changes to it.
|
|
57
|
+
|
|
58
|
+
Use sirkirby/unifi-mcp if:
|
|
59
|
+
|
|
60
|
+
- You use UniFi Protect or UniFi Access.
|
|
61
|
+
- You must change settings that the integration API does not have, for example port forwards, static routes, NAT rules, QoS rules, or VPN clients.
|
|
62
|
+
- You need history data, for example events, alarms, traffic statistics, DPI traffic, or traffic flows.
|
|
63
|
+
|
|
64
|
+
You can use both servers in the same MCP client. Give each server a different name in the MCP configuration.
|
|
65
|
+
|
|
66
|
+
## Tools
|
|
67
|
+
|
|
68
|
+
Most tools are read-only. The server adds the [write tools](#write-tools) only if `UNIFI_ALLOW_WRITES` is `true`.
|
|
69
|
+
|
|
70
|
+
| Tool | Endpoint |
|
|
71
|
+
|-|-|
|
|
72
|
+
| `get_application_info` | `GET /v1/info` |
|
|
73
|
+
| `list_sites` | `GET /v1/sites` |
|
|
74
|
+
| `list_devices`, `get_device` | `GET /v1/sites/{siteId}/devices[/{deviceId}]` |
|
|
75
|
+
| `get_device_statistics` | `GET /v1/sites/{siteId}/devices/{deviceId}/statistics/latest` |
|
|
76
|
+
| `list_pending_devices` | `GET /v1/pending-devices` |
|
|
77
|
+
| `list_clients`, `get_client` | `GET /v1/sites/{siteId}/clients[/{clientId}]` |
|
|
78
|
+
| `list_networks`, `get_network` | `GET /v1/sites/{siteId}/networks[/{networkId}]` |
|
|
79
|
+
| `get_network_references` | `GET /v1/sites/{siteId}/networks/{networkId}/references` |
|
|
80
|
+
| `list_wifi_broadcasts`, `get_wifi_broadcast` | `GET /v1/sites/{siteId}/wifi/broadcasts[/{wifiBroadcastId}]` |
|
|
81
|
+
| `list_wans` | `GET /v1/sites/{siteId}/wans` |
|
|
82
|
+
| `list_vpn_servers` | `GET /v1/sites/{siteId}/vpn/servers` |
|
|
83
|
+
| `list_site_to_site_tunnels` | `GET /v1/sites/{siteId}/vpn/site-to-site-tunnels` |
|
|
84
|
+
| `list_radius_profiles` | `GET /v1/sites/{siteId}/radius/profiles` |
|
|
85
|
+
| `list_device_tags` | `GET /v1/sites/{siteId}/device-tags` |
|
|
86
|
+
| `list_lags`, `get_lag` | `GET /v1/sites/{siteId}/switching/lags[/{lagId}]` |
|
|
87
|
+
| `list_mc_lag_domains`, `get_mc_lag_domain` | `GET /v1/sites/{siteId}/switching/mc-lag-domains[/{mcLagDomainId}]` |
|
|
88
|
+
| `list_switch_stacks`, `get_switch_stack` | `GET /v1/sites/{siteId}/switching/switch-stacks[/{switchStackId}]` |
|
|
89
|
+
| `list_vouchers`, `get_voucher` | `GET /v1/sites/{siteId}/hotspot/vouchers[/{voucherId}]` |
|
|
90
|
+
| `list_firewall_zones`, `get_firewall_zone` | `GET /v1/sites/{siteId}/firewall/zones[/{firewallZoneId}]` |
|
|
91
|
+
| `list_firewall_policies`, `get_firewall_policy` | `GET /v1/sites/{siteId}/firewall/policies[/{firewallPolicyId}]` |
|
|
92
|
+
| `get_firewall_policy_ordering` | `GET /v1/sites/{siteId}/firewall/policies/ordering` |
|
|
93
|
+
| `list_acl_rules`, `get_acl_rule` | `GET /v1/sites/{siteId}/acl-rules[/{aclRuleId}]` |
|
|
94
|
+
| `get_acl_rule_ordering` | `GET /v1/sites/{siteId}/acl-rules/ordering` |
|
|
95
|
+
| `list_dns_policies`, `get_dns_policy` | `GET /v1/sites/{siteId}/dns/policies[/{dnsPolicyId}]` |
|
|
96
|
+
| `list_traffic_matching_lists`, `get_traffic_matching_list` | `GET /v1/sites/{siteId}/traffic-matching-lists[/{trafficMatchingListId}]` |
|
|
97
|
+
| `list_dpi_applications` | `GET /v1/dpi/applications` |
|
|
98
|
+
| `list_dpi_categories` | `GET /v1/dpi/categories` |
|
|
99
|
+
| `get_topology` | Devices, device details, and clients, combined into one device tree |
|
|
100
|
+
| `get_firewall_overview` | Firewall zones and policies, grouped by zone pair, with the names of the referenced resources |
|
|
101
|
+
| `get_site_health` | Devices, clients, pending devices, and WAN interfaces, combined into one health summary with a list of issues |
|
|
102
|
+
| `get_device_health` | The latest statistics of all devices, with the device that needs most attention first |
|
|
103
|
+
| `get_wifi_overview` | WiFi broadcasts, the radios of each access point, and the wireless clients, with channel conflicts and radios with many retries |
|
|
104
|
+
| `get_switch_port_report` | The ports of each device with ports: speed, PoE state, and wired clients, with slow ports and limited PoE power |
|
|
105
|
+
| `get_network_map` | All networks by VLAN ID, with the subnet, the DHCP mode, the firewall zone, and the WiFi broadcasts of each network |
|
|
106
|
+
| `get_client_summary` | The clients by type, by access type, and by uplink device, and the newest clients |
|
|
107
|
+
| `find_client` | The clients whose name, IP address, or MAC address contains a search text |
|
|
108
|
+
| `get_voucher_summary` | The Hotspot vouchers by status, the vouchers that expire soon, and the fully used vouchers, without the codes |
|
|
109
|
+
| `find_unused_objects` | Unused traffic matching lists, networks, firewall zones, and device tags, and the disabled objects |
|
|
110
|
+
|
|
111
|
+
If a tool call does not include `site_id`, the server uses `UNIFI_DEFAULT_SITE_ID`.
|
|
112
|
+
If that variable is not set and the console has exactly one site, the server uses that site.
|
|
113
|
+
|
|
114
|
+
The results do not show the WiFi passphrases. The server replaces each passphrase with `***REDACTED***`, so that the passphrases do not get to the agent.
|
|
115
|
+
The server does not hide the voucher codes, because you must give these codes to the guests.
|
|
116
|
+
|
|
117
|
+
### Write tools
|
|
118
|
+
|
|
119
|
+
| Tool | Endpoint |
|
|
120
|
+
|-|-|
|
|
121
|
+
| `create_firewall_policy` | `POST /v1/sites/{siteId}/firewall/policies` |
|
|
122
|
+
| `update_firewall_policy` | `PATCH` or `GET` and `PUT /v1/sites/{siteId}/firewall/policies/{firewallPolicyId}` |
|
|
123
|
+
| `delete_firewall_policy` | `DELETE /v1/sites/{siteId}/firewall/policies/{firewallPolicyId}` |
|
|
124
|
+
| `reorder_firewall_policies` | `PUT /v1/sites/{siteId}/firewall/policies/ordering` |
|
|
125
|
+
| `adopt_device` | `POST /v1/sites/{siteId}/devices` |
|
|
126
|
+
| `remove_device` | `DELETE /v1/sites/{siteId}/devices/{deviceId}` |
|
|
127
|
+
| `restart_device` | `POST /v1/sites/{siteId}/devices/{deviceId}/actions` |
|
|
128
|
+
| `power_cycle_port` | `POST /v1/sites/{siteId}/devices/{deviceId}/interfaces/ports/{portIdx}/actions` |
|
|
129
|
+
| `authorize_guest`, `unauthorize_guest` | `POST /v1/sites/{siteId}/clients/{clientId}/actions` |
|
|
130
|
+
| `create_vouchers` | `POST /v1/sites/{siteId}/hotspot/vouchers` |
|
|
131
|
+
| `delete_voucher` | `DELETE /v1/sites/{siteId}/hotspot/vouchers/{voucherId}` |
|
|
132
|
+
| `delete_vouchers` | `DELETE /v1/sites/{siteId}/hotspot/vouchers` with a filter |
|
|
133
|
+
|
|
134
|
+
`update_firewall_policy` changes only the given fields. If the only changes are `logging_enabled` or `report_flow_enabled`, it sends a `PATCH` request. For all other changes, it reads the policy and sends the full policy with the changes.
|
|
135
|
+
The server checks each policy body against typed models before it sends the request.
|
|
136
|
+
The server does not send a request body that contains `***REDACTED***`, because that body would replace a secret with the placeholder.
|
|
137
|
+
|
|
138
|
+
Caution: Examine each write tool call before you approve it. A wrong firewall policy can block the access to the console. `remove_device` resets an online device to the factory settings.
|
|
139
|
+
|
|
140
|
+
## Configuration
|
|
141
|
+
|
|
142
|
+
Create an API key in UniFi Network, in **Settings > Control Plane > Integrations**.
|
|
143
|
+
The server reads its settings from these environment variables:
|
|
144
|
+
|
|
145
|
+
| Variable | Description |
|
|
146
|
+
|-|-|
|
|
147
|
+
| `UNIFI_API_KEY` | Required. The API key. |
|
|
148
|
+
| `UNIFI_HOST` | The IP address or hostname of a local console. |
|
|
149
|
+
| `UNIFI_CONSOLE_ID` | The console ID from unifi.ui.com. The server then uses the cloud connector. |
|
|
150
|
+
| `UNIFI_BASE_URL` | Any other URL that ends in `/proxy/network/integration`. |
|
|
151
|
+
| `UNIFI_VERIFY_TLS` | Optional, default `true`. Local consoles usually use a self-signed certificate. Set this to `false` only on a network that you trust. |
|
|
152
|
+
| `UNIFI_TIMEOUT` | Optional, default `30`. The request timeout in seconds. |
|
|
153
|
+
| `UNIFI_DEFAULT_SITE_ID` | Optional. The site to use when a tool call does not include `site_id`. |
|
|
154
|
+
| `UNIFI_ALLOW_WRITES` | Optional, default `false`. Set this to `true` to add the write tools. The API key must have write access. |
|
|
155
|
+
|
|
156
|
+
Set exactly one of `UNIFI_HOST`, `UNIFI_CONSOLE_ID`, or `UNIFI_BASE_URL`.
|
|
157
|
+
|
|
158
|
+
## Install the Claude Code plugin
|
|
159
|
+
|
|
160
|
+
The plugin adds the MCP server and four skills to Claude Code. The plugin needs [uv](https://docs.astral.sh/uv/).
|
|
161
|
+
In Claude Code 2.1.275 or later, install the plugin with one command:
|
|
162
|
+
|
|
163
|
+
```text
|
|
164
|
+
/plugin install unifi --marketplace henrik-dmg/ui-network-mcp
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
In an earlier version, add the marketplace first, and then install the plugin:
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
/plugin marketplace add henrik-dmg/ui-network-mcp
|
|
171
|
+
/plugin install unifi@ui-network-mcp
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Claude Code then asks for the plugin options. The options are the same as the [environment variables](#configuration): the API key, one of the console host, the console ID, or the base URL, and the optional settings. Claude Code keeps the API key in the system keychain.
|
|
175
|
+
To change the options later, run `/plugin configure unifi@ui-network-mcp`.
|
|
176
|
+
|
|
177
|
+
If you added the server before with `claude mcp add unifi`, remove that server with `claude mcp remove unifi`. Otherwise Claude Code has each tool two times.
|
|
178
|
+
|
|
179
|
+
### Skills
|
|
180
|
+
|
|
181
|
+
| Skill | What it does |
|
|
182
|
+
|-|-|
|
|
183
|
+
| `/unifi:health-check` | Makes a ranked list of the problems of a site: offline devices, high CPU or memory, WiFi channel conflicts, slow ports, and firmware updates. |
|
|
184
|
+
| `/unifi:firewall-audit` | Examines each user-defined firewall policy for shadowed, too broad, and duplicate policies, missing logging, and unused objects. |
|
|
185
|
+
| `/unifi:client-troubleshooting` | Finds the probable cause when one client is slow or has no connection. It examines each device from the client to the gateway. |
|
|
186
|
+
| `/unifi:firewall-change` | Changes the firewall in four phases: intent, plan, apply, and check. It writes nothing before you approve the plan. It needs the option "Allow changes". |
|
|
187
|
+
|
|
188
|
+
Claude also uses a skill when your question matches it, for example "Is my network healthy?".
|
|
189
|
+
|
|
190
|
+
## Add the server to Claude Code
|
|
191
|
+
|
|
192
|
+
If you do not want the plugin, you can add only the MCP server.
|
|
193
|
+
You do not have to clone the repository. `uvx` installs the server from PyPI and starts it:
|
|
194
|
+
|
|
195
|
+
```sh
|
|
196
|
+
claude mcp add unifi \
|
|
197
|
+
-e UNIFI_API_KEY=your-api-key \
|
|
198
|
+
-e UNIFI_HOST=192.168.1.1 \
|
|
199
|
+
-- uvx ui-network-mcp
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
For Claude Desktop and other MCP hosts, add this entry to the MCP configuration file:
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"mcpServers": {
|
|
207
|
+
"unifi": {
|
|
208
|
+
"command": "uvx",
|
|
209
|
+
"args": ["ui-network-mcp"],
|
|
210
|
+
"env": {
|
|
211
|
+
"UNIFI_API_KEY": "your-api-key",
|
|
212
|
+
"UNIFI_HOST": "192.168.1.1"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
To get a new version of the server, run `uvx --refresh ui-network-mcp` one time.
|
|
220
|
+
|
|
221
|
+
### Run from a clone
|
|
222
|
+
|
|
223
|
+
To use a local clone, give its path to `uv run --project`:
|
|
224
|
+
|
|
225
|
+
```sh
|
|
226
|
+
claude mcp add unifi \
|
|
227
|
+
-e UNIFI_API_KEY=your-api-key \
|
|
228
|
+
-e UNIFI_HOST=192.168.1.1 \
|
|
229
|
+
-- uv run --project /path/to/ui-network-mcp ui-network-mcp
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`uv run` installs the clone in editable mode. Thus the server uses your changes to the code when it starts again, and you do not have to reinstall it.
|
|
233
|
+
|
|
234
|
+
## Development
|
|
235
|
+
|
|
236
|
+
The project needs Python 3.14 and [uv](https://docs.astral.sh/uv/).
|
|
237
|
+
|
|
238
|
+
```sh
|
|
239
|
+
uv run pytest
|
|
240
|
+
uv run ruff check && uv run ruff format
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
The API specification is not in the repository. Before you add a tool, download the specification into the repository root. Git ignores this file.
|
|
244
|
+
|
|
245
|
+
```sh
|
|
246
|
+
curl -o network_v11.0.97_openapi.json https://developer.ui.com/network/v11.0.97/openapi.json
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
The CI workflow runs the lint, the tests, the build, and the plugin checks for each push to `main` and each pull request.
|
|
250
|
+
|
|
251
|
+
### Release
|
|
252
|
+
|
|
253
|
+
1. Run `uv version <version>`, for example `uv version 0.2.0`. This command changes `pyproject.toml` and `uv.lock`.
|
|
254
|
+
2. Set the same version in `.claude-plugin/plugin.json`.
|
|
255
|
+
3. Commit the change and push it to `main`.
|
|
256
|
+
4. Publish a GitHub release with the tag `v<version>`, for example `gh release create v0.2.0 --generate-notes`.
|
|
257
|
+
|
|
258
|
+
The release workflow then builds the package and publishes it to PyPI.
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
This project uses the MIT license. See [LICENSE](LICENSE).
|
|
263
|
+
UniFi and Ubiquiti are trademarks of Ubiquiti Inc.
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# ui-network-mcp
|
|
2
|
+
|
|
3
|
+
An MCP server for the UniFi Network API (integration API, version 11.0.97). The server uses [FastMCP](https://gofastmcp.com).
|
|
4
|
+
The package on PyPI is [`ui-network-mcp`](https://pypi.org/project/ui-network-mcp/). Ubiquiti publishes the [API specification](https://developer.ui.com/network/v11.0.97/openapi.json).
|
|
5
|
+
|
|
6
|
+
This is not an official Ubiquiti project.
|
|
7
|
+
|
|
8
|
+
## Comparison with sirkirby/unifi-mcp
|
|
9
|
+
|
|
10
|
+
[sirkirby/unifi-mcp](https://github.com/sirkirby/unifi-mcp) is a larger MCP project for UniFi, with servers for UniFi Network, Protect, and Access.
|
|
11
|
+
The two projects use different APIs and different credentials. Thus each project is useful for different tasks.
|
|
12
|
+
The data about sirkirby/unifi-mcp is from November 2026.
|
|
13
|
+
|
|
14
|
+
| | This server | sirkirby/unifi-mcp |
|
|
15
|
+
|-|-|-|
|
|
16
|
+
| UniFi applications | Network | Network, Protect, and Access |
|
|
17
|
+
| API | Only the official integration API | Mostly the private controller API, and the integration API for some tools |
|
|
18
|
+
| Credentials | An API key, which can be read-only | The username and password of a local admin account without MFA. An API key alone gives only some read tools. |
|
|
19
|
+
| Network tools | Almost all read endpoints of the integration API, and combined report tools | 210 tools, and many of them use endpoints that the integration API does not have |
|
|
20
|
+
| Changes | Firewall policies, device and port actions, guest access, and Hotspot vouchers. The write tools are hidden until you set `UNIFI_ALLOW_WRITES` to `true`. | Most configuration areas. Each change shows a preview before the server applies it. |
|
|
21
|
+
| Secrets | WiFi passphrases are redacted | WiFi passphrases, VPN keys, and other secrets are redacted |
|
|
22
|
+
| Remote access | The UniFi cloud connector, with `UNIFI_CONSOLE_ID` | A Cloudflare Worker and a relay on the local network |
|
|
23
|
+
| Claude Code plugin | One plugin with 4 skills | One plugin for each UniFi application, with skills |
|
|
24
|
+
| Size | One small Python package | A monorepo with MCP servers, a REST and GraphQL server, a relay, and plugins |
|
|
25
|
+
|
|
26
|
+
Use this server if:
|
|
27
|
+
|
|
28
|
+
- You want to give the agent an API key, not an admin password. You can revoke an API key at any time, and a read-only key cannot change the network.
|
|
29
|
+
- You want a documented API. Ubiquiti publishes a specification for each version of the integration API. The private API has no public documentation and can change with a firmware update.
|
|
30
|
+
- You want remote access through the UniFi cloud connector, without a relay or another service.
|
|
31
|
+
- You want a server that is small enough to read and examine in full.
|
|
32
|
+
- You ask more questions about the network than you make changes to it.
|
|
33
|
+
|
|
34
|
+
Use sirkirby/unifi-mcp if:
|
|
35
|
+
|
|
36
|
+
- You use UniFi Protect or UniFi Access.
|
|
37
|
+
- You must change settings that the integration API does not have, for example port forwards, static routes, NAT rules, QoS rules, or VPN clients.
|
|
38
|
+
- You need history data, for example events, alarms, traffic statistics, DPI traffic, or traffic flows.
|
|
39
|
+
|
|
40
|
+
You can use both servers in the same MCP client. Give each server a different name in the MCP configuration.
|
|
41
|
+
|
|
42
|
+
## Tools
|
|
43
|
+
|
|
44
|
+
Most tools are read-only. The server adds the [write tools](#write-tools) only if `UNIFI_ALLOW_WRITES` is `true`.
|
|
45
|
+
|
|
46
|
+
| Tool | Endpoint |
|
|
47
|
+
|-|-|
|
|
48
|
+
| `get_application_info` | `GET /v1/info` |
|
|
49
|
+
| `list_sites` | `GET /v1/sites` |
|
|
50
|
+
| `list_devices`, `get_device` | `GET /v1/sites/{siteId}/devices[/{deviceId}]` |
|
|
51
|
+
| `get_device_statistics` | `GET /v1/sites/{siteId}/devices/{deviceId}/statistics/latest` |
|
|
52
|
+
| `list_pending_devices` | `GET /v1/pending-devices` |
|
|
53
|
+
| `list_clients`, `get_client` | `GET /v1/sites/{siteId}/clients[/{clientId}]` |
|
|
54
|
+
| `list_networks`, `get_network` | `GET /v1/sites/{siteId}/networks[/{networkId}]` |
|
|
55
|
+
| `get_network_references` | `GET /v1/sites/{siteId}/networks/{networkId}/references` |
|
|
56
|
+
| `list_wifi_broadcasts`, `get_wifi_broadcast` | `GET /v1/sites/{siteId}/wifi/broadcasts[/{wifiBroadcastId}]` |
|
|
57
|
+
| `list_wans` | `GET /v1/sites/{siteId}/wans` |
|
|
58
|
+
| `list_vpn_servers` | `GET /v1/sites/{siteId}/vpn/servers` |
|
|
59
|
+
| `list_site_to_site_tunnels` | `GET /v1/sites/{siteId}/vpn/site-to-site-tunnels` |
|
|
60
|
+
| `list_radius_profiles` | `GET /v1/sites/{siteId}/radius/profiles` |
|
|
61
|
+
| `list_device_tags` | `GET /v1/sites/{siteId}/device-tags` |
|
|
62
|
+
| `list_lags`, `get_lag` | `GET /v1/sites/{siteId}/switching/lags[/{lagId}]` |
|
|
63
|
+
| `list_mc_lag_domains`, `get_mc_lag_domain` | `GET /v1/sites/{siteId}/switching/mc-lag-domains[/{mcLagDomainId}]` |
|
|
64
|
+
| `list_switch_stacks`, `get_switch_stack` | `GET /v1/sites/{siteId}/switching/switch-stacks[/{switchStackId}]` |
|
|
65
|
+
| `list_vouchers`, `get_voucher` | `GET /v1/sites/{siteId}/hotspot/vouchers[/{voucherId}]` |
|
|
66
|
+
| `list_firewall_zones`, `get_firewall_zone` | `GET /v1/sites/{siteId}/firewall/zones[/{firewallZoneId}]` |
|
|
67
|
+
| `list_firewall_policies`, `get_firewall_policy` | `GET /v1/sites/{siteId}/firewall/policies[/{firewallPolicyId}]` |
|
|
68
|
+
| `get_firewall_policy_ordering` | `GET /v1/sites/{siteId}/firewall/policies/ordering` |
|
|
69
|
+
| `list_acl_rules`, `get_acl_rule` | `GET /v1/sites/{siteId}/acl-rules[/{aclRuleId}]` |
|
|
70
|
+
| `get_acl_rule_ordering` | `GET /v1/sites/{siteId}/acl-rules/ordering` |
|
|
71
|
+
| `list_dns_policies`, `get_dns_policy` | `GET /v1/sites/{siteId}/dns/policies[/{dnsPolicyId}]` |
|
|
72
|
+
| `list_traffic_matching_lists`, `get_traffic_matching_list` | `GET /v1/sites/{siteId}/traffic-matching-lists[/{trafficMatchingListId}]` |
|
|
73
|
+
| `list_dpi_applications` | `GET /v1/dpi/applications` |
|
|
74
|
+
| `list_dpi_categories` | `GET /v1/dpi/categories` |
|
|
75
|
+
| `get_topology` | Devices, device details, and clients, combined into one device tree |
|
|
76
|
+
| `get_firewall_overview` | Firewall zones and policies, grouped by zone pair, with the names of the referenced resources |
|
|
77
|
+
| `get_site_health` | Devices, clients, pending devices, and WAN interfaces, combined into one health summary with a list of issues |
|
|
78
|
+
| `get_device_health` | The latest statistics of all devices, with the device that needs most attention first |
|
|
79
|
+
| `get_wifi_overview` | WiFi broadcasts, the radios of each access point, and the wireless clients, with channel conflicts and radios with many retries |
|
|
80
|
+
| `get_switch_port_report` | The ports of each device with ports: speed, PoE state, and wired clients, with slow ports and limited PoE power |
|
|
81
|
+
| `get_network_map` | All networks by VLAN ID, with the subnet, the DHCP mode, the firewall zone, and the WiFi broadcasts of each network |
|
|
82
|
+
| `get_client_summary` | The clients by type, by access type, and by uplink device, and the newest clients |
|
|
83
|
+
| `find_client` | The clients whose name, IP address, or MAC address contains a search text |
|
|
84
|
+
| `get_voucher_summary` | The Hotspot vouchers by status, the vouchers that expire soon, and the fully used vouchers, without the codes |
|
|
85
|
+
| `find_unused_objects` | Unused traffic matching lists, networks, firewall zones, and device tags, and the disabled objects |
|
|
86
|
+
|
|
87
|
+
If a tool call does not include `site_id`, the server uses `UNIFI_DEFAULT_SITE_ID`.
|
|
88
|
+
If that variable is not set and the console has exactly one site, the server uses that site.
|
|
89
|
+
|
|
90
|
+
The results do not show the WiFi passphrases. The server replaces each passphrase with `***REDACTED***`, so that the passphrases do not get to the agent.
|
|
91
|
+
The server does not hide the voucher codes, because you must give these codes to the guests.
|
|
92
|
+
|
|
93
|
+
### Write tools
|
|
94
|
+
|
|
95
|
+
| Tool | Endpoint |
|
|
96
|
+
|-|-|
|
|
97
|
+
| `create_firewall_policy` | `POST /v1/sites/{siteId}/firewall/policies` |
|
|
98
|
+
| `update_firewall_policy` | `PATCH` or `GET` and `PUT /v1/sites/{siteId}/firewall/policies/{firewallPolicyId}` |
|
|
99
|
+
| `delete_firewall_policy` | `DELETE /v1/sites/{siteId}/firewall/policies/{firewallPolicyId}` |
|
|
100
|
+
| `reorder_firewall_policies` | `PUT /v1/sites/{siteId}/firewall/policies/ordering` |
|
|
101
|
+
| `adopt_device` | `POST /v1/sites/{siteId}/devices` |
|
|
102
|
+
| `remove_device` | `DELETE /v1/sites/{siteId}/devices/{deviceId}` |
|
|
103
|
+
| `restart_device` | `POST /v1/sites/{siteId}/devices/{deviceId}/actions` |
|
|
104
|
+
| `power_cycle_port` | `POST /v1/sites/{siteId}/devices/{deviceId}/interfaces/ports/{portIdx}/actions` |
|
|
105
|
+
| `authorize_guest`, `unauthorize_guest` | `POST /v1/sites/{siteId}/clients/{clientId}/actions` |
|
|
106
|
+
| `create_vouchers` | `POST /v1/sites/{siteId}/hotspot/vouchers` |
|
|
107
|
+
| `delete_voucher` | `DELETE /v1/sites/{siteId}/hotspot/vouchers/{voucherId}` |
|
|
108
|
+
| `delete_vouchers` | `DELETE /v1/sites/{siteId}/hotspot/vouchers` with a filter |
|
|
109
|
+
|
|
110
|
+
`update_firewall_policy` changes only the given fields. If the only changes are `logging_enabled` or `report_flow_enabled`, it sends a `PATCH` request. For all other changes, it reads the policy and sends the full policy with the changes.
|
|
111
|
+
The server checks each policy body against typed models before it sends the request.
|
|
112
|
+
The server does not send a request body that contains `***REDACTED***`, because that body would replace a secret with the placeholder.
|
|
113
|
+
|
|
114
|
+
Caution: Examine each write tool call before you approve it. A wrong firewall policy can block the access to the console. `remove_device` resets an online device to the factory settings.
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
117
|
+
|
|
118
|
+
Create an API key in UniFi Network, in **Settings > Control Plane > Integrations**.
|
|
119
|
+
The server reads its settings from these environment variables:
|
|
120
|
+
|
|
121
|
+
| Variable | Description |
|
|
122
|
+
|-|-|
|
|
123
|
+
| `UNIFI_API_KEY` | Required. The API key. |
|
|
124
|
+
| `UNIFI_HOST` | The IP address or hostname of a local console. |
|
|
125
|
+
| `UNIFI_CONSOLE_ID` | The console ID from unifi.ui.com. The server then uses the cloud connector. |
|
|
126
|
+
| `UNIFI_BASE_URL` | Any other URL that ends in `/proxy/network/integration`. |
|
|
127
|
+
| `UNIFI_VERIFY_TLS` | Optional, default `true`. Local consoles usually use a self-signed certificate. Set this to `false` only on a network that you trust. |
|
|
128
|
+
| `UNIFI_TIMEOUT` | Optional, default `30`. The request timeout in seconds. |
|
|
129
|
+
| `UNIFI_DEFAULT_SITE_ID` | Optional. The site to use when a tool call does not include `site_id`. |
|
|
130
|
+
| `UNIFI_ALLOW_WRITES` | Optional, default `false`. Set this to `true` to add the write tools. The API key must have write access. |
|
|
131
|
+
|
|
132
|
+
Set exactly one of `UNIFI_HOST`, `UNIFI_CONSOLE_ID`, or `UNIFI_BASE_URL`.
|
|
133
|
+
|
|
134
|
+
## Install the Claude Code plugin
|
|
135
|
+
|
|
136
|
+
The plugin adds the MCP server and four skills to Claude Code. The plugin needs [uv](https://docs.astral.sh/uv/).
|
|
137
|
+
In Claude Code 2.1.275 or later, install the plugin with one command:
|
|
138
|
+
|
|
139
|
+
```text
|
|
140
|
+
/plugin install unifi --marketplace henrik-dmg/ui-network-mcp
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
In an earlier version, add the marketplace first, and then install the plugin:
|
|
144
|
+
|
|
145
|
+
```text
|
|
146
|
+
/plugin marketplace add henrik-dmg/ui-network-mcp
|
|
147
|
+
/plugin install unifi@ui-network-mcp
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Claude Code then asks for the plugin options. The options are the same as the [environment variables](#configuration): the API key, one of the console host, the console ID, or the base URL, and the optional settings. Claude Code keeps the API key in the system keychain.
|
|
151
|
+
To change the options later, run `/plugin configure unifi@ui-network-mcp`.
|
|
152
|
+
|
|
153
|
+
If you added the server before with `claude mcp add unifi`, remove that server with `claude mcp remove unifi`. Otherwise Claude Code has each tool two times.
|
|
154
|
+
|
|
155
|
+
### Skills
|
|
156
|
+
|
|
157
|
+
| Skill | What it does |
|
|
158
|
+
|-|-|
|
|
159
|
+
| `/unifi:health-check` | Makes a ranked list of the problems of a site: offline devices, high CPU or memory, WiFi channel conflicts, slow ports, and firmware updates. |
|
|
160
|
+
| `/unifi:firewall-audit` | Examines each user-defined firewall policy for shadowed, too broad, and duplicate policies, missing logging, and unused objects. |
|
|
161
|
+
| `/unifi:client-troubleshooting` | Finds the probable cause when one client is slow or has no connection. It examines each device from the client to the gateway. |
|
|
162
|
+
| `/unifi:firewall-change` | Changes the firewall in four phases: intent, plan, apply, and check. It writes nothing before you approve the plan. It needs the option "Allow changes". |
|
|
163
|
+
|
|
164
|
+
Claude also uses a skill when your question matches it, for example "Is my network healthy?".
|
|
165
|
+
|
|
166
|
+
## Add the server to Claude Code
|
|
167
|
+
|
|
168
|
+
If you do not want the plugin, you can add only the MCP server.
|
|
169
|
+
You do not have to clone the repository. `uvx` installs the server from PyPI and starts it:
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
claude mcp add unifi \
|
|
173
|
+
-e UNIFI_API_KEY=your-api-key \
|
|
174
|
+
-e UNIFI_HOST=192.168.1.1 \
|
|
175
|
+
-- uvx ui-network-mcp
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
For Claude Desktop and other MCP hosts, add this entry to the MCP configuration file:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"mcpServers": {
|
|
183
|
+
"unifi": {
|
|
184
|
+
"command": "uvx",
|
|
185
|
+
"args": ["ui-network-mcp"],
|
|
186
|
+
"env": {
|
|
187
|
+
"UNIFI_API_KEY": "your-api-key",
|
|
188
|
+
"UNIFI_HOST": "192.168.1.1"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
To get a new version of the server, run `uvx --refresh ui-network-mcp` one time.
|
|
196
|
+
|
|
197
|
+
### Run from a clone
|
|
198
|
+
|
|
199
|
+
To use a local clone, give its path to `uv run --project`:
|
|
200
|
+
|
|
201
|
+
```sh
|
|
202
|
+
claude mcp add unifi \
|
|
203
|
+
-e UNIFI_API_KEY=your-api-key \
|
|
204
|
+
-e UNIFI_HOST=192.168.1.1 \
|
|
205
|
+
-- uv run --project /path/to/ui-network-mcp ui-network-mcp
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
`uv run` installs the clone in editable mode. Thus the server uses your changes to the code when it starts again, and you do not have to reinstall it.
|
|
209
|
+
|
|
210
|
+
## Development
|
|
211
|
+
|
|
212
|
+
The project needs Python 3.14 and [uv](https://docs.astral.sh/uv/).
|
|
213
|
+
|
|
214
|
+
```sh
|
|
215
|
+
uv run pytest
|
|
216
|
+
uv run ruff check && uv run ruff format
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
The API specification is not in the repository. Before you add a tool, download the specification into the repository root. Git ignores this file.
|
|
220
|
+
|
|
221
|
+
```sh
|
|
222
|
+
curl -o network_v11.0.97_openapi.json https://developer.ui.com/network/v11.0.97/openapi.json
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
The CI workflow runs the lint, the tests, the build, and the plugin checks for each push to `main` and each pull request.
|
|
226
|
+
|
|
227
|
+
### Release
|
|
228
|
+
|
|
229
|
+
1. Run `uv version <version>`, for example `uv version 0.2.0`. This command changes `pyproject.toml` and `uv.lock`.
|
|
230
|
+
2. Set the same version in `.claude-plugin/plugin.json`.
|
|
231
|
+
3. Commit the change and push it to `main`.
|
|
232
|
+
4. Publish a GitHub release with the tag `v<version>`, for example `gh release create v0.2.0 --generate-notes`.
|
|
233
|
+
|
|
234
|
+
The release workflow then builds the package and publishes it to PyPI.
|
|
235
|
+
|
|
236
|
+
## License
|
|
237
|
+
|
|
238
|
+
This project uses the MIT license. See [LICENSE](LICENSE).
|
|
239
|
+
UniFi and Ubiquiti are trademarks of Ubiquiti Inc.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ui-network-mcp"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "MCP server for the UniFi Network API"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
keywords = [
|
|
9
|
+
"unifi",
|
|
10
|
+
"ubiquiti",
|
|
11
|
+
"mcp",
|
|
12
|
+
"model-context-protocol",
|
|
13
|
+
"network",
|
|
14
|
+
"firewall",
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Intended Audience :: System Administrators",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Programming Language :: Python :: 3.14",
|
|
22
|
+
"Topic :: System :: Networking",
|
|
23
|
+
]
|
|
24
|
+
requires-python = ">=3.14,<3.15"
|
|
25
|
+
dependencies = [
|
|
26
|
+
"fastmcp>=4.0.10",
|
|
27
|
+
"httpx>=0.28.1",
|
|
28
|
+
"pydantic-settings>=2.15.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[[project.authors]]
|
|
32
|
+
name = "Henrik Panhans"
|
|
33
|
+
email = "henrik@panhans.dev"
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/henrik-dmg/ui-network-mcp"
|
|
37
|
+
Repository = "https://github.com/henrik-dmg/ui-network-mcp"
|
|
38
|
+
Issues = "https://github.com/henrik-dmg/ui-network-mcp/issues"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
ui-network-mcp = "ui_network_mcp:main"
|
|
42
|
+
|
|
43
|
+
[build-system]
|
|
44
|
+
requires = ["uv_build>=0.9.27,<0.10.0"]
|
|
45
|
+
build-backend = "uv_build"
|
|
46
|
+
|
|
47
|
+
[dependency-groups]
|
|
48
|
+
dev = [
|
|
49
|
+
"pytest>=9.1.1",
|
|
50
|
+
"pytest-asyncio>=1.4.0",
|
|
51
|
+
"respx>=0.23.1",
|
|
52
|
+
"ruff>=0.16.9",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[tool.pytest.ini_options]
|
|
56
|
+
asyncio_mode = "auto"
|
|
57
|
+
|
|
58
|
+
[tool.ruff.lint]
|
|
59
|
+
select = [
|
|
60
|
+
"E",
|
|
61
|
+
"F",
|
|
62
|
+
"I",
|
|
63
|
+
"UP",
|
|
64
|
+
"B",
|
|
65
|
+
]
|
|
66
|
+
ignore = ["E501"]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ui-network-mcp"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "MCP server for the UniFi Network API"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Henrik Panhans", email = "henrik@panhans.dev" }]
|
|
9
|
+
keywords = ["unifi", "ubiquiti", "mcp", "model-context-protocol", "network", "firewall"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: System Administrators",
|
|
12
|
+
"Operating System :: OS Independent",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
15
|
+
"Programming Language :: Python :: 3.14",
|
|
16
|
+
"Topic :: System :: Networking",
|
|
17
|
+
]
|
|
18
|
+
# pyyaml, a dependency of fastmcp, does not build on Python 3.15 yet.
|
|
19
|
+
requires-python = ">=3.14,<3.15"
|
|
20
|
+
dependencies = ["fastmcp>=4.0.10", "httpx>=0.28.1", "pydantic-settings>=2.15.0"]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/henrik-dmg/ui-network-mcp"
|
|
24
|
+
Repository = "https://github.com/henrik-dmg/ui-network-mcp"
|
|
25
|
+
Issues = "https://github.com/henrik-dmg/ui-network-mcp/issues"
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
ui-network-mcp = "ui_network_mcp:main"
|
|
29
|
+
|
|
30
|
+
[build-system]
|
|
31
|
+
requires = ["uv_build>=0.9.27,<0.10.0"]
|
|
32
|
+
build-backend = "uv_build"
|
|
33
|
+
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
dev = [
|
|
36
|
+
"pytest>=9.1.1",
|
|
37
|
+
"pytest-asyncio>=1.4.0",
|
|
38
|
+
"respx>=0.23.1",
|
|
39
|
+
"ruff>=0.16.9",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
asyncio_mode = "auto"
|
|
44
|
+
|
|
45
|
+
[tool.ruff.lint]
|
|
46
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
47
|
+
# The formatter controls the line length.
|
|
48
|
+
ignore = ["E501"]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def main() -> None:
|
|
5
|
+
from pydantic import ValidationError
|
|
6
|
+
|
|
7
|
+
from ui_network_mcp.server import create_server
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
server = create_server()
|
|
11
|
+
except ValidationError as error:
|
|
12
|
+
problems = "; ".join(
|
|
13
|
+
f"{'.'.join(map(str, e['loc'])) or 'settings'}: {e['msg']}"
|
|
14
|
+
for e in error.errors()
|
|
15
|
+
)
|
|
16
|
+
sys.exit(
|
|
17
|
+
f"ui-network-mcp: invalid configuration ({problems}). Set the UNIFI_* environment variables."
|
|
18
|
+
)
|
|
19
|
+
server.run()
|