@owine/unifi-network-mcp 2.14.2 → 3.0.0
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.
- package/LICENSE +21 -0
- package/README.md +235 -80
- package/dist/client.d.ts +13 -1
- package/dist/client.js +142 -16
- package/dist/config.d.ts +11 -0
- package/dist/config.js +102 -3
- package/dist/guard.d.ts +46 -0
- package/dist/guard.js +171 -0
- package/dist/index.js +15 -4
- package/dist/instructions.d.ts +9 -0
- package/dist/instructions.js +32 -0
- package/dist/tls.d.ts +14 -0
- package/dist/tls.js +58 -0
- package/dist/tools/acl.js +126 -53
- package/dist/tools/client-history.js +20 -10
- package/dist/tools/clients.js +14 -13
- package/dist/tools/devices.js +30 -29
- package/dist/tools/dns-policies.js +116 -69
- package/dist/tools/firewall.d.ts +2 -1
- package/dist/tools/firewall.js +245 -80
- package/dist/tools/hotspot.js +35 -28
- package/dist/tools/index.d.ts +13 -1
- package/dist/tools/index.js +63 -4
- package/dist/tools/networks.d.ts +2 -1
- package/dist/tools/networks.js +152 -58
- package/dist/tools/sites.js +3 -3
- package/dist/tools/supporting.js +31 -30
- package/dist/tools/switching.js +22 -21
- package/dist/tools/system.js +1 -1
- package/dist/tools/traffic-matching.d.ts +2 -1
- package/dist/tools/traffic-matching.js +31 -28
- package/dist/tools/wifi.js +228 -311
- package/dist/utils/full-put.d.ts +32 -0
- package/dist/utils/full-put.js +74 -0
- package/dist/utils/output-schemas.d.ts +77 -9
- package/dist/utils/output-schemas.js +106 -54
- package/dist/utils/params.d.ts +7 -0
- package/dist/utils/params.js +12 -0
- package/dist/utils/responses.d.ts +2 -0
- package/dist/utils/responses.js +28 -2
- package/dist/utils/safety.d.ts +35 -1
- package/dist/utils/safety.js +53 -3
- package/dist/utils/secrets.d.ts +24 -0
- package/dist/utils/secrets.js +92 -0
- package/dist/utils/wan-exposure.d.ts +69 -0
- package/dist/utils/wan-exposure.js +245 -0
- package/dist/write-log.d.ts +52 -0
- package/dist/write-log.js +178 -0
- package/dist/write-tools.d.ts +27 -0
- package/dist/write-tools.js +50 -0
- package/package.json +19 -15
package/dist/tools/supporting.js
CHANGED
|
@@ -6,24 +6,25 @@ const responses_js_1 = require("../utils/responses.js");
|
|
|
6
6
|
const query_js_1 = require("../utils/query.js");
|
|
7
7
|
const safety_js_1 = require("../utils/safety.js");
|
|
8
8
|
const output_schemas_js_1 = require("../utils/output-schemas.js");
|
|
9
|
+
const params_js_1 = require("../utils/params.js");
|
|
9
10
|
function registerSupportingTools(server, client) {
|
|
10
11
|
server.registerTool("unifi_list_wans", {
|
|
11
|
-
description: "List WAN interface definitions at a site. Returns: id, name only (verified against
|
|
12
|
+
description: "List WAN interface definitions at a site. Returns: id, name only (verified against 11.0.83 — the Integration API exposes no live link status or throughput rates here). Use for: WAN inventory, multi-WAN topology.",
|
|
12
13
|
inputSchema: {
|
|
13
|
-
siteId:
|
|
14
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
14
15
|
offset: zod_1.z
|
|
15
16
|
.number()
|
|
16
17
|
.int()
|
|
17
18
|
.nonnegative()
|
|
18
19
|
.optional()
|
|
19
|
-
.describe("Number of records to skip
|
|
20
|
+
.describe("Number of records to skip"),
|
|
20
21
|
limit: zod_1.z
|
|
21
22
|
.number()
|
|
22
23
|
.int()
|
|
23
24
|
.min(0)
|
|
24
25
|
.max(200)
|
|
25
26
|
.optional()
|
|
26
|
-
.describe("Number of records to return (default: 25
|
|
27
|
+
.describe("Number of records to return (API default: 25)"),
|
|
27
28
|
},
|
|
28
29
|
outputSchema: output_schemas_js_1.listWansOutputSchema,
|
|
29
30
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -38,26 +39,26 @@ function registerSupportingTools(server, client) {
|
|
|
38
39
|
}
|
|
39
40
|
});
|
|
40
41
|
server.registerTool("unifi_list_vpn_tunnels", {
|
|
41
|
-
description: "List site-to-site VPN tunnels (IPsec, WireGuard, OpenVPN site-to-site) at a site. Returns: tunnel definitions per row (per-row schema not rendered in
|
|
42
|
+
description: "List site-to-site VPN tunnels (IPsec, WireGuard, OpenVPN site-to-site) at a site. Returns: tunnel definitions per row (per-row schema not rendered in 11.0.83 docs and no tunnels to sample live; the older 10.4.57 spec lists id, type (IPSEC/OPENVPN/WIREGUARD), name, metadata.origin/source — call to inspect). For roaming client VPN servers, see unifi_list_vpn_servers.",
|
|
42
43
|
inputSchema: {
|
|
43
|
-
siteId:
|
|
44
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
44
45
|
offset: zod_1.z
|
|
45
46
|
.number()
|
|
46
47
|
.int()
|
|
47
48
|
.nonnegative()
|
|
48
49
|
.optional()
|
|
49
|
-
.describe("Number of records to skip
|
|
50
|
+
.describe("Number of records to skip"),
|
|
50
51
|
limit: zod_1.z
|
|
51
52
|
.number()
|
|
52
53
|
.int()
|
|
53
54
|
.min(0)
|
|
54
55
|
.max(200)
|
|
55
56
|
.optional()
|
|
56
|
-
.describe("Number of records to return (default: 25
|
|
57
|
+
.describe("Number of records to return (API default: 25)"),
|
|
57
58
|
filter: zod_1.z
|
|
58
59
|
.string()
|
|
59
60
|
.optional()
|
|
60
|
-
.describe("Filter expression"),
|
|
61
|
+
.describe("Filter expression, e.g. metadata.source.isNull()"),
|
|
61
62
|
},
|
|
62
63
|
outputSchema: output_schemas_js_1.listVpnTunnelsOutputSchema,
|
|
63
64
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -72,26 +73,26 @@ function registerSupportingTools(server, client) {
|
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
75
|
server.registerTool("unifi_list_vpn_servers", {
|
|
75
|
-
description: "List VPN servers (roaming/client-access VPNs
|
|
76
|
+
description: "List VPN servers (roaming/client-access VPNs) at a site. Returns: id, type (L2TP, OPENVPN, PPTP, UID, WIREGUARD), name, enabled, metadata.origin.",
|
|
76
77
|
inputSchema: {
|
|
77
|
-
siteId:
|
|
78
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
78
79
|
offset: zod_1.z
|
|
79
80
|
.number()
|
|
80
81
|
.int()
|
|
81
82
|
.nonnegative()
|
|
82
83
|
.optional()
|
|
83
|
-
.describe("Number of records to skip
|
|
84
|
+
.describe("Number of records to skip"),
|
|
84
85
|
limit: zod_1.z
|
|
85
86
|
.number()
|
|
86
87
|
.int()
|
|
87
88
|
.min(0)
|
|
88
89
|
.max(200)
|
|
89
90
|
.optional()
|
|
90
|
-
.describe("Number of records to return (default: 25
|
|
91
|
+
.describe("Number of records to return (API default: 25)"),
|
|
91
92
|
filter: zod_1.z
|
|
92
93
|
.string()
|
|
93
94
|
.optional()
|
|
94
|
-
.describe("Filter expression"),
|
|
95
|
+
.describe("Filter expression, e.g. type.eq('WIREGUARD')"),
|
|
95
96
|
},
|
|
96
97
|
outputSchema: output_schemas_js_1.listVpnServersOutputSchema,
|
|
97
98
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -108,24 +109,24 @@ function registerSupportingTools(server, client) {
|
|
|
108
109
|
server.registerTool("unifi_list_radius_profiles", {
|
|
109
110
|
description: "List RADIUS profiles (auth/accounting server configurations referenced by WiFi WPA-Enterprise, switch 802.1X port auth, VPN). Returns: id, name, metadata (origin, configurable).",
|
|
110
111
|
inputSchema: {
|
|
111
|
-
siteId:
|
|
112
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
112
113
|
offset: zod_1.z
|
|
113
114
|
.number()
|
|
114
115
|
.int()
|
|
115
116
|
.nonnegative()
|
|
116
117
|
.optional()
|
|
117
|
-
.describe("Number of records to skip
|
|
118
|
+
.describe("Number of records to skip"),
|
|
118
119
|
limit: zod_1.z
|
|
119
120
|
.number()
|
|
120
121
|
.int()
|
|
121
122
|
.min(0)
|
|
122
123
|
.max(200)
|
|
123
124
|
.optional()
|
|
124
|
-
.describe("Number of records to return (default: 25
|
|
125
|
+
.describe("Number of records to return (API default: 25)"),
|
|
125
126
|
filter: zod_1.z
|
|
126
127
|
.string()
|
|
127
128
|
.optional()
|
|
128
|
-
.describe("Filter expression"),
|
|
129
|
+
.describe("Filter expression, e.g. name.eq('Default')"),
|
|
129
130
|
},
|
|
130
131
|
outputSchema: output_schemas_js_1.listRadiusProfilesOutputSchema,
|
|
131
132
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -140,22 +141,22 @@ function registerSupportingTools(server, client) {
|
|
|
140
141
|
}
|
|
141
142
|
});
|
|
142
143
|
server.registerTool("unifi_list_device_tags", {
|
|
143
|
-
description: "List device tags at a site. Tags group APs/switches for selective WiFi broadcast (via broadcastingDeviceFilter on a WiFi network). Returns: id, name, deviceIds[].",
|
|
144
|
+
description: "List device tags at a site. Tags group APs/switches for selective WiFi broadcast (via broadcastingDeviceFilter on a WiFi network). Returns: id, name, deviceIds[], metadata.",
|
|
144
145
|
inputSchema: {
|
|
145
|
-
siteId:
|
|
146
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
146
147
|
offset: zod_1.z
|
|
147
148
|
.number()
|
|
148
149
|
.int()
|
|
149
150
|
.nonnegative()
|
|
150
151
|
.optional()
|
|
151
|
-
.describe("Number of records to skip
|
|
152
|
+
.describe("Number of records to skip"),
|
|
152
153
|
limit: zod_1.z
|
|
153
154
|
.number()
|
|
154
155
|
.int()
|
|
155
156
|
.min(0)
|
|
156
157
|
.max(200)
|
|
157
158
|
.optional()
|
|
158
|
-
.describe("Number of records to return (default: 25
|
|
159
|
+
.describe("Number of records to return (API default: 25)"),
|
|
159
160
|
filter: zod_1.z
|
|
160
161
|
.string()
|
|
161
162
|
.optional()
|
|
@@ -181,18 +182,18 @@ function registerSupportingTools(server, client) {
|
|
|
181
182
|
.int()
|
|
182
183
|
.nonnegative()
|
|
183
184
|
.optional()
|
|
184
|
-
.describe("Number of records to skip
|
|
185
|
+
.describe("Number of records to skip"),
|
|
185
186
|
limit: zod_1.z
|
|
186
187
|
.number()
|
|
187
188
|
.int()
|
|
188
189
|
.min(0)
|
|
189
190
|
.max(200)
|
|
190
191
|
.optional()
|
|
191
|
-
.describe("Number of records to return (default: 25
|
|
192
|
+
.describe("Number of records to return (API default: 25)"),
|
|
192
193
|
filter: zod_1.z
|
|
193
194
|
.string()
|
|
194
195
|
.optional()
|
|
195
|
-
.describe("Filter expression"),
|
|
196
|
+
.describe("Filter expression, e.g. name.like('Stream*') or id.eq(3). NOTE: totalCount ignores the filter here — page by count"),
|
|
196
197
|
},
|
|
197
198
|
outputSchema: output_schemas_js_1.listDpiCategoriesOutputSchema,
|
|
198
199
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -214,18 +215,18 @@ function registerSupportingTools(server, client) {
|
|
|
214
215
|
.int()
|
|
215
216
|
.nonnegative()
|
|
216
217
|
.optional()
|
|
217
|
-
.describe("Number of records to skip
|
|
218
|
+
.describe("Number of records to skip"),
|
|
218
219
|
limit: zod_1.z
|
|
219
220
|
.number()
|
|
220
221
|
.int()
|
|
221
222
|
.min(0)
|
|
222
223
|
.max(200)
|
|
223
224
|
.optional()
|
|
224
|
-
.describe("Number of records to return (default: 25
|
|
225
|
+
.describe("Number of records to return (API default: 25)"),
|
|
225
226
|
filter: zod_1.z
|
|
226
227
|
.string()
|
|
227
228
|
.optional()
|
|
228
|
-
.describe("Filter expression"),
|
|
229
|
+
.describe("Filter expression, e.g. name.like('Net*') or id.eq(3). NOTE: totalCount ignores the filter here — page by count"),
|
|
229
230
|
},
|
|
230
231
|
outputSchema: output_schemas_js_1.listDpiApplicationsOutputSchema,
|
|
231
232
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -247,14 +248,14 @@ function registerSupportingTools(server, client) {
|
|
|
247
248
|
.int()
|
|
248
249
|
.nonnegative()
|
|
249
250
|
.optional()
|
|
250
|
-
.describe("Number of records to skip
|
|
251
|
+
.describe("Number of records to skip"),
|
|
251
252
|
limit: zod_1.z
|
|
252
253
|
.number()
|
|
253
254
|
.int()
|
|
254
255
|
.min(0)
|
|
255
256
|
.max(200)
|
|
256
257
|
.optional()
|
|
257
|
-
.describe("Number of records to return (default: 25
|
|
258
|
+
.describe("Number of records to return (API default: 25)"),
|
|
258
259
|
filter: zod_1.z
|
|
259
260
|
.string()
|
|
260
261
|
.optional()
|
package/dist/tools/switching.js
CHANGED
|
@@ -6,28 +6,29 @@ const responses_js_1 = require("../utils/responses.js");
|
|
|
6
6
|
const query_js_1 = require("../utils/query.js");
|
|
7
7
|
const safety_js_1 = require("../utils/safety.js");
|
|
8
8
|
const output_schemas_js_1 = require("../utils/output-schemas.js");
|
|
9
|
+
const params_js_1 = require("../utils/params.js");
|
|
9
10
|
function registerSwitchingTools(server, client) {
|
|
10
11
|
server.registerTool("unifi_list_switch_stacks", {
|
|
11
|
-
description: "List Switch Stacks (multiple physical switches managed as one logical unit) at a site. Returns: id, deviceId (the stack's primary device), name, units[] (the stacked switches — named `members` on consoles older than 10.6.106), lags[] (LAGs spanning the stack), metadata.origin. Per-unit schema is not rendered in the
|
|
12
|
+
description: "List Switch Stacks (multiple physical switches managed as one logical unit) at a site. Returns: id, deviceId (the stack's primary device), name, units[] (the stacked switches — named `members` on consoles older than 10.6.106), lags[] (LAGs spanning the stack), metadata.origin. Per-unit schema is not rendered in the 11.0.83 docs — call unifi_get_switch_stack to inspect. Use for: identifying stacked switches; individual member configs/stats still come from unifi_get_device.",
|
|
12
13
|
inputSchema: {
|
|
13
|
-
siteId:
|
|
14
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
14
15
|
offset: zod_1.z
|
|
15
16
|
.number()
|
|
16
17
|
.int()
|
|
17
18
|
.nonnegative()
|
|
18
19
|
.optional()
|
|
19
|
-
.describe("Number of records to skip
|
|
20
|
+
.describe("Number of records to skip"),
|
|
20
21
|
limit: zod_1.z
|
|
21
22
|
.number()
|
|
22
23
|
.int()
|
|
23
24
|
.min(0)
|
|
24
25
|
.max(200)
|
|
25
26
|
.optional()
|
|
26
|
-
.describe("Number of records to return (default: 25
|
|
27
|
+
.describe("Number of records to return (API default: 25)"),
|
|
27
28
|
filter: zod_1.z
|
|
28
29
|
.string()
|
|
29
30
|
.optional()
|
|
30
|
-
.describe("Filter expression"),
|
|
31
|
+
.describe("Filter expression, e.g. name.like('Core*') or metadata.origin.eq('USER_DEFINED'). Device filters (members.deviceId, units.deviceId) are rejected on 11.0.83"),
|
|
31
32
|
},
|
|
32
33
|
outputSchema: output_schemas_js_1.listSwitchStacksOutputSchema,
|
|
33
34
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -44,8 +45,8 @@ function registerSwitchingTools(server, client) {
|
|
|
44
45
|
server.registerTool("unifi_get_switch_stack", {
|
|
45
46
|
description: "Get full details of a Switch Stack including all units and stacking topology. Returns the same fields as the list response but for a single stack: id, deviceId, name, units[] (named `members` before 10.6.106), lags[], metadata.origin.",
|
|
46
47
|
inputSchema: {
|
|
47
|
-
siteId:
|
|
48
|
-
switchStackId:
|
|
48
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
49
|
+
switchStackId: (0, params_js_1.resourceId)().describe("Switch Stack ID"),
|
|
49
50
|
},
|
|
50
51
|
outputSchema: output_schemas_js_1.switchStackOutputSchema,
|
|
51
52
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -59,26 +60,26 @@ function registerSwitchingTools(server, client) {
|
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
server.registerTool("unifi_list_mc_lag_domains", {
|
|
62
|
-
description: "List MC-LAG (Multi-Chassis Link Aggregation) Domains — pairs of switches presenting as one for LAG redundancy. Returns: id, name, peers[], lags[] (LAGs spanning the domain), metadata.origin.",
|
|
63
|
+
description: "List MC-LAG (Multi-Chassis Link Aggregation) Domains — pairs of switches presenting as one for LAG redundancy. Returns: id, name, peers[] (per the older 10.4.57 spec: {deviceId, linkPortIdxs[], role TOP|BOTTOM}; not live-verified), lags[] (LAGs spanning the domain), metadata.origin.",
|
|
63
64
|
inputSchema: {
|
|
64
|
-
siteId:
|
|
65
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
65
66
|
offset: zod_1.z
|
|
66
67
|
.number()
|
|
67
68
|
.int()
|
|
68
69
|
.nonnegative()
|
|
69
70
|
.optional()
|
|
70
|
-
.describe("Number of records to skip
|
|
71
|
+
.describe("Number of records to skip"),
|
|
71
72
|
limit: zod_1.z
|
|
72
73
|
.number()
|
|
73
74
|
.int()
|
|
74
75
|
.min(0)
|
|
75
76
|
.max(200)
|
|
76
77
|
.optional()
|
|
77
|
-
.describe("Number of records to return (default: 25
|
|
78
|
+
.describe("Number of records to return (API default: 25)"),
|
|
78
79
|
filter: zod_1.z
|
|
79
80
|
.string()
|
|
80
81
|
.optional()
|
|
81
|
-
.describe("Filter expression"),
|
|
82
|
+
.describe("Filter expression, e.g. peers.deviceId.contains('<deviceId>')"),
|
|
82
83
|
},
|
|
83
84
|
outputSchema: output_schemas_js_1.listMcLagDomainsOutputSchema,
|
|
84
85
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -95,8 +96,8 @@ function registerSwitchingTools(server, client) {
|
|
|
95
96
|
server.registerTool("unifi_get_mc_lag_domain", {
|
|
96
97
|
description: "Get full details of an MC-LAG Domain (peer switches and member LAGs).",
|
|
97
98
|
inputSchema: {
|
|
98
|
-
siteId:
|
|
99
|
-
mcLagDomainId:
|
|
99
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
100
|
+
mcLagDomainId: (0, params_js_1.resourceId)().describe("MC-LAG Domain ID"),
|
|
100
101
|
},
|
|
101
102
|
outputSchema: output_schemas_js_1.mcLagDomainOutputSchema,
|
|
102
103
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -110,26 +111,26 @@ function registerSwitchingTools(server, client) {
|
|
|
110
111
|
}
|
|
111
112
|
});
|
|
112
113
|
server.registerTool("unifi_list_lags", {
|
|
113
|
-
description: "List LAGs (Link Aggregation Groups — bonded switch ports) at a site. Returns: id, type (LOCAL/SWITCH_STACK/MULTI_CHASSIS), members[], metadata.origin.",
|
|
114
|
+
description: "List LAGs (Link Aggregation Groups — bonded switch ports) at a site. Returns: id, type (LOCAL/SWITCH_STACK/MULTI_CHASSIS), members[] ({deviceId, portIdxs[]}), switchStackId (SWITCH_STACK) or mcLagDomainId (MULTI_CHASSIS), metadata.origin.",
|
|
114
115
|
inputSchema: {
|
|
115
|
-
siteId:
|
|
116
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
116
117
|
offset: zod_1.z
|
|
117
118
|
.number()
|
|
118
119
|
.int()
|
|
119
120
|
.nonnegative()
|
|
120
121
|
.optional()
|
|
121
|
-
.describe("Number of records to skip
|
|
122
|
+
.describe("Number of records to skip"),
|
|
122
123
|
limit: zod_1.z
|
|
123
124
|
.number()
|
|
124
125
|
.int()
|
|
125
126
|
.min(0)
|
|
126
127
|
.max(200)
|
|
127
128
|
.optional()
|
|
128
|
-
.describe("Number of records to return (default: 25
|
|
129
|
+
.describe("Number of records to return (API default: 25)"),
|
|
129
130
|
filter: zod_1.z
|
|
130
131
|
.string()
|
|
131
132
|
.optional()
|
|
132
|
-
.describe("Filter expression"),
|
|
133
|
+
.describe("Filter expression, e.g. type.eq('LOCAL'), members.deviceId.contains('<deviceId>'), switchStackId.isNull()"),
|
|
133
134
|
},
|
|
134
135
|
outputSchema: output_schemas_js_1.listLagsOutputSchema,
|
|
135
136
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -146,8 +147,8 @@ function registerSwitchingTools(server, client) {
|
|
|
146
147
|
server.registerTool("unifi_get_lag", {
|
|
147
148
|
description: "Get full details of a LAG including its type (LOCAL/SWITCH_STACK/MULTI_CHASSIS) and member ports.",
|
|
148
149
|
inputSchema: {
|
|
149
|
-
siteId:
|
|
150
|
-
lagId:
|
|
150
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
151
|
+
lagId: (0, params_js_1.resourceId)().describe("LAG ID"),
|
|
151
152
|
},
|
|
152
153
|
outputSchema: output_schemas_js_1.lagOutputSchema,
|
|
153
154
|
annotations: safety_js_1.READ_ONLY,
|
package/dist/tools/system.js
CHANGED
|
@@ -6,7 +6,7 @@ const safety_js_1 = require("../utils/safety.js");
|
|
|
6
6
|
const output_schemas_js_1 = require("../utils/output-schemas.js");
|
|
7
7
|
function registerSystemTools(server, client) {
|
|
8
8
|
server.registerTool("unifi_get_info", {
|
|
9
|
-
description: "Get UniFi Network application info. Returns: applicationVersion
|
|
9
|
+
description: "Get UniFi Network application info. Returns: applicationVersion only — the Integration API returns no isUniFiOSConsole or other field here. Use for: checking the Network version when a tool's description notes version-specific behaviour.",
|
|
10
10
|
inputSchema: {},
|
|
11
11
|
outputSchema: output_schemas_js_1.getInfoOutputSchema,
|
|
12
12
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { NetworkClient } from "../client.js";
|
|
3
|
-
|
|
3
|
+
import { type WanPolicy } from "../utils/wan-exposure.js";
|
|
4
|
+
export declare function registerTrafficMatchingTools(server: McpServer, client: NetworkClient, readOnly?: boolean, wan?: WanPolicy): void;
|
|
@@ -6,28 +6,34 @@ const responses_js_1 = require("../utils/responses.js");
|
|
|
6
6
|
const query_js_1 = require("../utils/query.js");
|
|
7
7
|
const safety_js_1 = require("../utils/safety.js");
|
|
8
8
|
const output_schemas_js_1 = require("../utils/output-schemas.js");
|
|
9
|
-
|
|
9
|
+
const params_js_1 = require("../utils/params.js");
|
|
10
|
+
const wan_exposure_js_1 = require("../utils/wan-exposure.js");
|
|
11
|
+
const matchingItems = zod_1.z
|
|
12
|
+
.array(zod_1.z.object({ type: zod_1.z.string().describe("Item type, e.g. PORT_NUMBER, IP_ADDRESS, SUBNET") }).loose())
|
|
13
|
+
.min(1)
|
|
14
|
+
.describe("Non-empty array of tagged item objects, e.g. [{type:'PORT_NUMBER', value:443}]");
|
|
15
|
+
function registerTrafficMatchingTools(server, client, readOnly = false, wan = wan_exposure_js_1.DEFAULT_WAN_POLICY) {
|
|
10
16
|
server.registerTool("unifi_list_traffic_matching_lists", {
|
|
11
|
-
description: "List traffic matching lists at a site — named collections of ports or IPs reused in firewall/ACL rules. Returns: id, type (PORTS/IPV4_ADDRESSES/IPV6_ADDRESSES), name, items[]. Use for: finding the matching-list ID to reference from a firewall policy.",
|
|
17
|
+
description: "List traffic matching lists at a site — named collections of ports or IPs reused in firewall/ACL rules. Returns: id, type (PORTS/IPV4_ADDRESSES/IPV6_ADDRESSES), name, items[] (tagged objects such as {type:'PORT_NUMBER', value:22} or {type:'SUBNET', value:'<cidr>'}). Use for: finding the matching-list ID to reference from a firewall policy.",
|
|
12
18
|
inputSchema: {
|
|
13
|
-
siteId:
|
|
19
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
14
20
|
offset: zod_1.z
|
|
15
21
|
.number()
|
|
16
22
|
.int()
|
|
17
23
|
.nonnegative()
|
|
18
24
|
.optional()
|
|
19
|
-
.describe("Number of records to skip
|
|
25
|
+
.describe("Number of records to skip"),
|
|
20
26
|
limit: zod_1.z
|
|
21
27
|
.number()
|
|
22
28
|
.int()
|
|
23
29
|
.min(0)
|
|
24
30
|
.max(200)
|
|
25
31
|
.optional()
|
|
26
|
-
.describe("Number of records to return (default: 25
|
|
32
|
+
.describe("Number of records to return (API default: 25)"),
|
|
27
33
|
filter: zod_1.z
|
|
28
34
|
.string()
|
|
29
35
|
.optional()
|
|
30
|
-
.describe("Filter expression"),
|
|
36
|
+
.describe("Filter expression. Only id and name are filterable (type is rejected with HTTP 400). Example: name.like('Web*'). NOTE: totalCount ignores the filter here — page by count"),
|
|
31
37
|
},
|
|
32
38
|
outputSchema: output_schemas_js_1.listTrafficMatchingListsOutputSchema,
|
|
33
39
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -44,8 +50,8 @@ function registerTrafficMatchingTools(server, client, readOnly = false) {
|
|
|
44
50
|
server.registerTool("unifi_get_traffic_matching_list", {
|
|
45
51
|
description: "Get a specific traffic matching list by ID (full items array).",
|
|
46
52
|
inputSchema: {
|
|
47
|
-
siteId:
|
|
48
|
-
trafficMatchingListId:
|
|
53
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
54
|
+
trafficMatchingListId: (0, params_js_1.resourceId)().describe("Traffic matching list ID"),
|
|
49
55
|
},
|
|
50
56
|
outputSchema: output_schemas_js_1.trafficMatchingListOutputSchema,
|
|
51
57
|
annotations: safety_js_1.READ_ONLY,
|
|
@@ -61,23 +67,20 @@ function registerTrafficMatchingTools(server, client, readOnly = false) {
|
|
|
61
67
|
if (readOnly)
|
|
62
68
|
return;
|
|
63
69
|
server.registerTool("unifi_create_traffic_matching_list", {
|
|
64
|
-
description: "Create a new traffic matching list",
|
|
70
|
+
description: "Create a new traffic matching list. Items are tagged objects, not strings (live-verified 11.0.83): PORTS lists take {type:'PORT_NUMBER', value:443} (the older 10.4.57 spec also lists {type:'PORT_NUMBER_RANGE', start, stop}); IPV4_ADDRESSES lists take {type:'IP_ADDRESS', value:'192.0.2.1'} or {type:'SUBNET', value:'192.0.2.0/24'} (spec also: IP_ADDRESS_RANGE {start, stop}); IPV6_ADDRESSES lists take IP_ADDRESS or SUBNET. Idempotency: not safe to retry — re-running creates a duplicate list.",
|
|
65
71
|
inputSchema: {
|
|
66
|
-
siteId:
|
|
72
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
67
73
|
type: zod_1.z
|
|
68
74
|
.enum(["PORTS", "IPV4_ADDRESSES", "IPV6_ADDRESSES"])
|
|
69
75
|
.describe("List type"),
|
|
70
76
|
name: zod_1.z.string().min(1).describe("List name"),
|
|
71
|
-
items:
|
|
72
|
-
.array(zod_1.z.unknown())
|
|
73
|
-
.min(1)
|
|
74
|
-
.describe("List items (ports or IP addresses)"),
|
|
77
|
+
items: matchingItems,
|
|
75
78
|
dryRun: zod_1.z
|
|
76
79
|
.boolean()
|
|
77
80
|
.optional()
|
|
78
81
|
.describe("Preview this action without executing it"),
|
|
79
82
|
},
|
|
80
|
-
outputSchema: output_schemas_js_1.trafficMatchingListOutputSchema,
|
|
83
|
+
outputSchema: (0, output_schemas_js_1.writeResult)(output_schemas_js_1.trafficMatchingListOutputSchema),
|
|
81
84
|
annotations: safety_js_1.WRITE_NOT_IDEMPOTENT,
|
|
82
85
|
}, async ({ siteId, type, name, items, dryRun }) => {
|
|
83
86
|
try {
|
|
@@ -92,25 +95,28 @@ function registerTrafficMatchingTools(server, client, readOnly = false) {
|
|
|
92
95
|
}
|
|
93
96
|
});
|
|
94
97
|
server.registerTool("unifi_update_traffic_matching_list", {
|
|
95
|
-
description: "
|
|
98
|
+
description: "Replace a traffic matching list (full PUT — type, name and the complete items array are all required; read the current list with unifi_get_traffic_matching_list first). Items are tagged objects, not strings (live-verified 11.0.83): PORTS lists take {type:'PORT_NUMBER', value:443} (the older 10.4.57 spec also lists {type:'PORT_NUMBER_RANGE', start, stop}); IPV4_ADDRESSES lists take {type:'IP_ADDRESS', value:'192.0.2.1'} or {type:'SUBNET', value:'192.0.2.0/24'} (spec also: IP_ADDRESS_RANGE {start, stop}); IPV6_ADDRESSES lists take IP_ADDRESS or SUBNET.",
|
|
96
99
|
inputSchema: {
|
|
97
|
-
siteId:
|
|
98
|
-
trafficMatchingListId:
|
|
100
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
101
|
+
trafficMatchingListId: (0, params_js_1.resourceId)().describe("Traffic matching list ID"),
|
|
99
102
|
type: zod_1.z
|
|
100
103
|
.enum(["PORTS", "IPV4_ADDRESSES", "IPV6_ADDRESSES"])
|
|
101
104
|
.describe("List type"),
|
|
102
105
|
name: zod_1.z.string().min(1).describe("List name"),
|
|
103
|
-
items:
|
|
106
|
+
items: matchingItems,
|
|
104
107
|
dryRun: zod_1.z
|
|
105
108
|
.boolean()
|
|
106
109
|
.optional()
|
|
107
110
|
.describe("Preview this action without executing it"),
|
|
108
111
|
},
|
|
109
|
-
outputSchema: output_schemas_js_1.trafficMatchingListOutputSchema,
|
|
112
|
+
outputSchema: (0, output_schemas_js_1.writeResult)(output_schemas_js_1.trafficMatchingListOutputSchema),
|
|
110
113
|
annotations: safety_js_1.WRITE,
|
|
111
114
|
}, async ({ siteId, trafficMatchingListId, type, name, items, dryRun }) => {
|
|
112
115
|
try {
|
|
113
116
|
const body = { type, name, items };
|
|
117
|
+
const exposure = await new wan_exposure_js_1.WanExposure(client, wan, siteId).matchingList(trafficMatchingListId);
|
|
118
|
+
if (exposure)
|
|
119
|
+
return (0, wan_exposure_js_1.wanRefusal)(exposure, "PUT", `/sites/${siteId}/traffic-matching-lists/${trafficMatchingListId}`);
|
|
114
120
|
if (dryRun)
|
|
115
121
|
return (0, safety_js_1.formatDryRun)("PUT", `/sites/${siteId}/traffic-matching-lists/${trafficMatchingListId}`, body);
|
|
116
122
|
const data = await client.put(`/sites/${siteId}/traffic-matching-lists/${trafficMatchingListId}`, body);
|
|
@@ -123,12 +129,9 @@ function registerTrafficMatchingTools(server, client, readOnly = false) {
|
|
|
123
129
|
server.registerTool("unifi_delete_traffic_matching_list", {
|
|
124
130
|
description: "DESTRUCTIVE: Delete a traffic matching list",
|
|
125
131
|
inputSchema: {
|
|
126
|
-
siteId:
|
|
127
|
-
trafficMatchingListId:
|
|
128
|
-
confirm:
|
|
129
|
-
.boolean()
|
|
130
|
-
.optional()
|
|
131
|
-
.describe("Must be true to execute this destructive action"),
|
|
132
|
+
siteId: (0, params_js_1.resourceId)().describe("Site ID"),
|
|
133
|
+
trafficMatchingListId: (0, params_js_1.resourceId)().describe("Traffic matching list ID"),
|
|
134
|
+
confirm: (0, safety_js_1.confirmDestructive)(),
|
|
132
135
|
dryRun: zod_1.z
|
|
133
136
|
.boolean()
|
|
134
137
|
.optional()
|
|
@@ -136,12 +139,12 @@ function registerTrafficMatchingTools(server, client, readOnly = false) {
|
|
|
136
139
|
},
|
|
137
140
|
annotations: safety_js_1.DESTRUCTIVE,
|
|
138
141
|
}, async ({ siteId, trafficMatchingListId, confirm, dryRun }) => {
|
|
139
|
-
const guard = (0, safety_js_1.requireConfirmation)(confirm, "This will delete the traffic matching list");
|
|
142
|
+
const guard = dryRun ? null : (0, safety_js_1.requireConfirmation)(confirm, "This will delete the traffic matching list");
|
|
140
143
|
if (guard)
|
|
141
144
|
return guard;
|
|
142
145
|
try {
|
|
143
146
|
if (dryRun)
|
|
144
|
-
return (0, safety_js_1.formatDryRun)("DELETE", `/sites/${siteId}/traffic-matching-lists/${trafficMatchingListId}
|
|
147
|
+
return (0, safety_js_1.formatDryRun)("DELETE", `/sites/${siteId}/traffic-matching-lists/${trafficMatchingListId}`);
|
|
145
148
|
const data = await client.delete(`/sites/${siteId}/traffic-matching-lists/${trafficMatchingListId}`);
|
|
146
149
|
return (0, responses_js_1.formatSuccess)(data);
|
|
147
150
|
}
|