@teamnetwork-nz/sonicwall-api-mcp-server 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +65 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -779,7 +779,7 @@ var import_zod3 = require("zod");
779
779
  function registerAddressGroupTools(server, registry) {
780
780
  server.tool(
781
781
  "list_address_groups",
782
- "List address groups on the appliance.",
782
+ "List address groups on the appliance. type: filter by 'ipv4', 'ipv6', or 'all' (default).",
783
783
  {
784
784
  type: import_zod3.z.enum(["ipv4", "ipv6", "all"]).optional().default("all"),
785
785
  device: import_zod3.z.string().optional()
@@ -1166,10 +1166,21 @@ function registerServiceGroupTools(server, registry) {
1166
1166
 
1167
1167
  // src/tools/access-rules.ts
1168
1168
  var import_zod6 = require("zod");
1169
+ function zoneName(v) {
1170
+ if (typeof v === "string") return v;
1171
+ if (v && typeof v === "object") {
1172
+ const z15 = v.zone;
1173
+ if (typeof z15 === "string") return z15;
1174
+ }
1175
+ return void 0;
1176
+ }
1177
+ function matchesZone(value, filter) {
1178
+ return value !== void 0 && value.toLowerCase() === filter.toLowerCase();
1179
+ }
1169
1180
  function registerAccessRuleTools(server, registry) {
1170
1181
  server.tool(
1171
1182
  "list_access_rules",
1172
- "List firewall access rules, optionally filtered by source and/or destination zone.",
1183
+ "List firewall access rules, optionally filtered by source and/or destination zone. Filtering is applied client-side (the SonicOS endpoint returns the full ruleset), so use from_zone/to_zone to keep responses small.",
1173
1184
  {
1174
1185
  ip_version: import_zod6.z.enum(["ipv4", "ipv6"]).optional().default("ipv4"),
1175
1186
  from_zone: import_zod6.z.string().optional(),
@@ -1179,10 +1190,19 @@ function registerAccessRuleTools(server, registry) {
1179
1190
  async ({ ip_version, from_zone, to_zone, device }) => {
1180
1191
  try {
1181
1192
  const client = await registry.getClient(device);
1182
- const params = {};
1183
- if (from_zone) params["from"] = from_zone;
1184
- if (to_zone) params["to"] = to_zone;
1185
- const result = await client.get(`access-rules/${ip_version}`, Object.keys(params).length ? params : void 0);
1193
+ const result = await client.get(`access-rules/${ip_version}`);
1194
+ if (from_zone || to_zone) {
1195
+ const all = result.access_rules ?? [];
1196
+ const filtered = all.filter((entry) => {
1197
+ const rule = entry[ip_version];
1198
+ if (!rule) return false;
1199
+ if (from_zone && !matchesZone(zoneName(rule.from), from_zone)) return false;
1200
+ if (to_zone && !matchesZone(zoneName(rule.to), to_zone)) return false;
1201
+ return true;
1202
+ });
1203
+ const out = { access_rules: filtered, matched: filtered.length, total: all.length };
1204
+ return { content: [{ type: "text", text: JSON.stringify(out, null, 2) }] };
1205
+ }
1186
1206
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
1187
1207
  } catch (e) {
1188
1208
  return { content: [{ type: "text", text: `Error: ${e.message}` }], isError: true };
@@ -1209,7 +1229,7 @@ function registerAccessRuleTools(server, registry) {
1209
1229
  );
1210
1230
  server.tool(
1211
1231
  "create_access_rule",
1212
- "Create a firewall access rule. source/destination/service: name of an existing address/service object or 'Any'. geo_ip_policy: optional name of a GeoIP policy to attach. Changes are STAGED; call commit_config to apply.",
1232
+ "Create a firewall access rule. source/destination/service: name of an existing address/service object or 'Any'. geo_ip_policy: name of a GeoIP policy that already exists on the appliance (GeoIP policies cannot be created or listed via this server \u2014 manage them in the appliance web UI). Changes are STAGED; call commit_config to apply.",
1213
1233
  {
1214
1234
  ip_version: import_zod6.z.enum(["ipv4", "ipv6"]),
1215
1235
  name: import_zod6.z.string(),
@@ -1254,7 +1274,7 @@ function registerAccessRuleTools(server, registry) {
1254
1274
  );
1255
1275
  server.tool(
1256
1276
  "update_access_rule",
1257
- "Update fields on an existing access rule (GET-then-PUT). Only provided fields are changed. Set geo_ip_policy to '' to remove it. Changes are STAGED; call commit_config to apply.",
1277
+ "Update fields on an existing access rule (GET-then-PUT). Only provided fields are changed. geo_ip_policy: name of an existing appliance GeoIP policy, or '' to remove it. Changes are STAGED; call commit_config to apply.",
1258
1278
  {
1259
1279
  rule_id: import_zod6.z.number(),
1260
1280
  ip_version: import_zod6.z.enum(["ipv4", "ipv6"]).optional().default("ipv4"),
@@ -1379,7 +1399,7 @@ function setNameField(obj, key, value) {
1379
1399
  function registerNatPolicyTools(server, registry) {
1380
1400
  server.tool(
1381
1401
  "list_nat_policies",
1382
- "List all NAT policies.",
1402
+ "List all NAT policies. ip_version: 'ipv4' (default) or 'ipv6'.",
1383
1403
  {
1384
1404
  ip_version: import_zod7.z.enum(["ipv4", "ipv6"]).optional().default("ipv4"),
1385
1405
  device: import_zod7.z.string().optional()
@@ -1520,18 +1540,43 @@ function registerNatPolicyTools(server, registry) {
1520
1540
 
1521
1541
  // src/tools/security-policies.ts
1522
1542
  var import_zod8 = require("zod");
1543
+ function zoneName2(v) {
1544
+ if (typeof v === "string") return v;
1545
+ if (v && typeof v === "object") {
1546
+ const z15 = v.zone;
1547
+ if (typeof z15 === "string") return z15;
1548
+ }
1549
+ return void 0;
1550
+ }
1551
+ function matchesZone2(value, filter) {
1552
+ return value !== void 0 && value.toLowerCase() === filter.toLowerCase();
1553
+ }
1523
1554
  function registerSecurityPolicyTools(server, registry) {
1524
1555
  server.tool(
1525
1556
  "list_security_policies",
1526
- "List all security policies.",
1557
+ "List security policies, optionally filtered by source and/or destination zone. Filtering is applied client-side (the SonicOS endpoint returns the full ruleset), so use from_zone/to_zone to keep responses small.",
1527
1558
  {
1528
1559
  ip_version: import_zod8.z.enum(["ipv4", "ipv6"]).optional().default("ipv4"),
1560
+ from_zone: import_zod8.z.string().optional(),
1561
+ to_zone: import_zod8.z.string().optional(),
1529
1562
  device: import_zod8.z.string().optional()
1530
1563
  },
1531
- async ({ ip_version, device }) => {
1564
+ async ({ ip_version, from_zone, to_zone, device }) => {
1532
1565
  try {
1533
1566
  const client = await registry.getClient(device);
1534
1567
  const result = await client.get(`security-policies/${ip_version}`);
1568
+ if (from_zone || to_zone) {
1569
+ const all = result.security_policies ?? [];
1570
+ const filtered = all.filter((entry) => {
1571
+ const policy = entry[ip_version];
1572
+ if (!policy) return false;
1573
+ if (from_zone && !matchesZone2(zoneName2(policy.from), from_zone)) return false;
1574
+ if (to_zone && !matchesZone2(zoneName2(policy.to), to_zone)) return false;
1575
+ return true;
1576
+ });
1577
+ const out = { security_policies: filtered, matched: filtered.length, total: all.length };
1578
+ return { content: [{ type: "text", text: JSON.stringify(out, null, 2) }] };
1579
+ }
1535
1580
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
1536
1581
  } catch (e) {
1537
1582
  return { content: [{ type: "text", text: `Error: ${e.message}` }], isError: true };
@@ -1840,7 +1885,7 @@ function registerLogTools(server, registry) {
1840
1885
  );
1841
1886
  server.tool(
1842
1887
  "get_threat_logs",
1843
- "Retrieve IPS and threat-detection log events. severity: 'critical', 'high', 'medium', or 'low'.",
1888
+ "Retrieve IPS and threat-detection log events (filters by IPS category). severity maps to SonicOS priority levels: 'critical'\u2192critical, 'high'\u2192error, 'medium'\u2192warning, 'low'\u2192notice.",
1844
1889
  {
1845
1890
  count: import_zod10.z.number().optional().default(50),
1846
1891
  severity: import_zod10.z.enum(["critical", "high", "medium", "low"]).optional(),
@@ -1851,8 +1896,14 @@ function registerLogTools(server, registry) {
1851
1896
  async ({ count, severity, start_time, end_time, device }) => {
1852
1897
  try {
1853
1898
  const client = await registry.getClient(device);
1899
+ const severityToPriority = {
1900
+ critical: "critical",
1901
+ high: "error",
1902
+ medium: "warning",
1903
+ low: "notice"
1904
+ };
1854
1905
  const params = { count, category: "IPS" };
1855
- if (severity) params.severity = severity;
1906
+ if (severity) params.priority = severityToPriority[severity];
1856
1907
  if (start_time) params.start_time = start_time;
1857
1908
  if (end_time) params.end_time = end_time;
1858
1909
  const result = await getLogsWithFallback(client, EVENT_LOG_PATHS, params);
@@ -2004,7 +2055,7 @@ async function main() {
2004
2055
  const registry = new DeviceRegistry(config.profiles);
2005
2056
  const server = new import_mcp.McpServer({
2006
2057
  name: "sonicwall-mcp-server",
2007
- version: "0.5.0",
2058
+ version: "0.5.1",
2008
2059
  instructions: `SonicWall NSA MCP server \u2014 full read/write access to SonicWall firewalls via the SonicOS REST API.
2009
2060
 
2010
2061
  ## Device targeting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnetwork-nz/sonicwall-api-mcp-server",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "MCP server for SonicWall NSA appliance API — logs, CRUD objects, rules, NAT, GeoIP",
5
5
  "keywords": [
6
6
  "mcp",