@chkp/policy-insights-mcp 0.3.2 → 0.3.4
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/README.md +37 -0
- package/dist/index.js +206 -71
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/package.json.bak +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,9 @@ Together they give you the full picture: combine actual rule content with insigh
|
|
|
29
29
|
- Get when new insights are planned to be generated
|
|
30
30
|
- Retrieve detailed information when you can't see insights
|
|
31
31
|
|
|
32
|
+
## Management API Version
|
|
33
|
+
|
|
34
|
+
This server supports **Management API v2.1 (R82.10+)**. It is generally compatible with earlier versions; some parameters may not be available on older management servers.
|
|
32
35
|
|
|
33
36
|
## Example Use Cases
|
|
34
37
|
|
|
@@ -248,6 +251,40 @@ Add the configuration as Claude Desktop App.
|
|
|
248
251
|
|
|
249
252
|
---
|
|
250
253
|
|
|
254
|
+
## HTTP Transport
|
|
255
|
+
|
|
256
|
+
By default, this server uses **stdio** transport, which is the standard mode for MCP clients like Claude Desktop and Cursor. For hosted or multi-user deployments, an **HTTP transport** (MCP Streamable HTTP) is also available.
|
|
257
|
+
|
|
258
|
+
> **Security notice before you continue:** The HTTP server has no built-in authentication and no TLS. Any client that can reach the port can establish a session, and credentials travel in cleartext. Only use HTTP transport behind an authenticated reverse proxy (nginx, Caddy, a cloud load balancer) that terminates TLS and enforces authentication. If you are running the server on the same machine as your MCP client, use the default stdio transport — it has none of these concerns.
|
|
259
|
+
|
|
260
|
+
### Starting the server in HTTP mode
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
MCP_TRANSPORT_TYPE=http MCP_TRANSPORT_PORT=3000 npx @chkp/policy-insights-mcp
|
|
264
|
+
# or
|
|
265
|
+
npx @chkp/policy-insights-mcp --transport http --transport-port 3000
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
The server exposes:
|
|
269
|
+
- `POST/GET/DELETE /mcp` — MCP protocol endpoint
|
|
270
|
+
- `GET /health` — server status (active session count, version)
|
|
271
|
+
|
|
272
|
+
### Connecting an MCP client
|
|
273
|
+
|
|
274
|
+
Point your MCP client at `http://<host>:3000/mcp`. Example for Claude Desktop (`claude_desktop_config.json`):
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"mcpServers": {
|
|
279
|
+
"policy-insights": {
|
|
280
|
+
"url": "http://localhost:3000/mcp"
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
251
288
|
## Development
|
|
252
289
|
|
|
253
290
|
### Prerequisites
|
package/dist/index.js
CHANGED
|
@@ -994,6 +994,7 @@ var APIClientBase = class {
|
|
|
994
994
|
this.sessionTimeout = null;
|
|
995
995
|
this.sessionStart = null;
|
|
996
996
|
this.isMDS = false;
|
|
997
|
+
this._externalSid = false;
|
|
997
998
|
}
|
|
998
999
|
/**
|
|
999
1000
|
* Create an API client instance - generic method for creating clients
|
|
@@ -1031,9 +1032,22 @@ var APIClientBase = class {
|
|
|
1031
1032
|
this._debug = value;
|
|
1032
1033
|
}
|
|
1033
1034
|
/**
|
|
1034
|
-
*
|
|
1035
|
+
* Set a pre-authenticated session ID provided externally (e.g. via X-chkp-sid header).
|
|
1036
|
+
* When set, the client will skip login and use this SID directly for all requests.
|
|
1035
1037
|
*/
|
|
1038
|
+
setExternalSid(sid) {
|
|
1039
|
+
this.sid = sid;
|
|
1040
|
+
this._externalSid = true;
|
|
1041
|
+
this.sessionStart = Date.now();
|
|
1042
|
+
this.sessionTimeout = Number.MAX_SAFE_INTEGER / 1e3;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Check if this client needs to perform login before making API calls
|
|
1046
|
+
*/
|
|
1036
1047
|
needsLogin() {
|
|
1048
|
+
if (this._externalSid) {
|
|
1049
|
+
return false;
|
|
1050
|
+
}
|
|
1037
1051
|
return true;
|
|
1038
1052
|
}
|
|
1039
1053
|
/**
|
|
@@ -1092,6 +1106,9 @@ var APIClientBase = class {
|
|
|
1092
1106
|
return await this.makeRequest(this.getHost(), method, uri, data, this.getHeaders(), params, httpsAgent);
|
|
1093
1107
|
} catch (error) {
|
|
1094
1108
|
if ((error.message?.includes("401") || error.response?.status === 401) && error.message?.toLowerCase().includes("session")) {
|
|
1109
|
+
if (this._externalSid) {
|
|
1110
|
+
throw new Error("Pre-authenticated session (X-chkp-sid) has expired. Provide a new session ID.");
|
|
1111
|
+
}
|
|
1095
1112
|
console.error("Session expired (401), resetting session and retrying...");
|
|
1096
1113
|
this.sid = null;
|
|
1097
1114
|
this.sessionStart = null;
|
|
@@ -1126,6 +1143,11 @@ var APIClientBase = class {
|
|
|
1126
1143
|
* Login to the API using the API key
|
|
1127
1144
|
*/
|
|
1128
1145
|
async login() {
|
|
1146
|
+
if (this._externalSid) {
|
|
1147
|
+
if (!this.sid)
|
|
1148
|
+
throw new Error("External SID has expired");
|
|
1149
|
+
return this.sid;
|
|
1150
|
+
}
|
|
1129
1151
|
const apiTokenHeader = this.tokenType === TokenType.API_KEY ? "api-key" : "ci-token";
|
|
1130
1152
|
const loginResp = await this.makeRequest(this.getHost(), "POST", "login", { [apiTokenHeader]: this.authToken }, this.getHeadersForLogin());
|
|
1131
1153
|
if (loginResp.status !== 200 || !loginResp.response || !loginResp.response.sid) {
|
|
@@ -1217,10 +1239,11 @@ var SmartOneCloudAPIClient = class extends APIClientBase {
|
|
|
1217
1239
|
}
|
|
1218
1240
|
};
|
|
1219
1241
|
var OnPremAPIClient = class extends APIClientBase {
|
|
1220
|
-
constructor(apiKey, managementHost, managementPort = "443", username, password) {
|
|
1242
|
+
constructor(apiKey, managementHost, managementPort = "443", username, password, domain) {
|
|
1221
1243
|
super(apiKey || "");
|
|
1222
1244
|
this.managementHost = managementHost;
|
|
1223
1245
|
this.managementPort = managementPort;
|
|
1246
|
+
this.domain = domain;
|
|
1224
1247
|
this.username = username;
|
|
1225
1248
|
this.password = password;
|
|
1226
1249
|
}
|
|
@@ -1234,6 +1257,11 @@ var OnPremAPIClient = class extends APIClientBase {
|
|
|
1234
1257
|
* and allow self-signed certificates
|
|
1235
1258
|
*/
|
|
1236
1259
|
async login() {
|
|
1260
|
+
if (this._externalSid) {
|
|
1261
|
+
if (!this.sid)
|
|
1262
|
+
throw new Error("External SID has expired");
|
|
1263
|
+
return this.sid;
|
|
1264
|
+
}
|
|
1237
1265
|
const isUsingApiKey = !!this.authToken;
|
|
1238
1266
|
const isUsingCredentials = !!(this.username && this.password);
|
|
1239
1267
|
if (!isUsingApiKey && !isUsingCredentials) {
|
|
@@ -1241,6 +1269,9 @@ var OnPremAPIClient = class extends APIClientBase {
|
|
|
1241
1269
|
}
|
|
1242
1270
|
const httpsAgent = new https.Agent({ rejectUnauthorized: false });
|
|
1243
1271
|
const loginPayload = isUsingApiKey ? { "api-key": this.authToken } : { "user": this.username, "password": this.password };
|
|
1272
|
+
if (this.domain) {
|
|
1273
|
+
loginPayload["domain"] = this.domain;
|
|
1274
|
+
}
|
|
1244
1275
|
const loginResp = await this.makeRequest(this.getHost(), "POST", "login", loginPayload, { "Content-Type": "application/json" }, null, httpsAgent);
|
|
1245
1276
|
if (loginResp.status !== 200 || !loginResp.response || !loginResp.response.sid) {
|
|
1246
1277
|
throw loginResp;
|
|
@@ -2422,6 +2453,7 @@ var APIManagerBase = class {
|
|
|
2422
2453
|
this.domainClients = /* @__PURE__ */ new Map();
|
|
2423
2454
|
this.gatewayDomainMap = /* @__PURE__ */ new Map();
|
|
2424
2455
|
this.domains = null;
|
|
2456
|
+
this.mdsServers = null;
|
|
2425
2457
|
}
|
|
2426
2458
|
/**
|
|
2427
2459
|
* Set debug mode for the API client
|
|
@@ -2445,7 +2477,7 @@ var APIManagerBase = class {
|
|
|
2445
2477
|
*/
|
|
2446
2478
|
async callApi(method, uri, data, domain) {
|
|
2447
2479
|
const sanitizedData = sanitizeData(data);
|
|
2448
|
-
const apiClient = domain ? await this.getDomainApiClientByDomain(domain) : this.client;
|
|
2480
|
+
const apiClient = domain && !data["domains-to-process"] ? await this.getDomainApiClientByDomain(domain) : this.client;
|
|
2449
2481
|
const clientResponse = await apiClient.callApi(method, uri, sanitizedData, void 0);
|
|
2450
2482
|
return clientResponse.response;
|
|
2451
2483
|
}
|
|
@@ -2486,23 +2518,35 @@ var APIManagerBase = class {
|
|
|
2486
2518
|
if (this.domains !== null) {
|
|
2487
2519
|
return this.domains;
|
|
2488
2520
|
}
|
|
2489
|
-
const
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2521
|
+
const allDomains = [];
|
|
2522
|
+
const limit = 50;
|
|
2523
|
+
let offset = 0;
|
|
2524
|
+
let total = Infinity;
|
|
2525
|
+
while (offset < total) {
|
|
2526
|
+
const response = await this.callApi("post", "show-domains", {
|
|
2527
|
+
"details-level": "full",
|
|
2528
|
+
"limit": limit,
|
|
2529
|
+
"offset": offset
|
|
2530
|
+
});
|
|
2531
|
+
if (response.objects) {
|
|
2532
|
+
for (const obj of response.objects) {
|
|
2533
|
+
if (obj.name && obj.type) {
|
|
2534
|
+
allDomains.push({
|
|
2535
|
+
name: obj.name,
|
|
2536
|
+
type: obj.type,
|
|
2537
|
+
servers: obj.servers || []
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
2501
2540
|
}
|
|
2502
2541
|
}
|
|
2542
|
+
total = typeof response.total === "number" ? response.total : allDomains.length;
|
|
2543
|
+
offset += limit;
|
|
2544
|
+
if (!response.objects || response.objects.length === 0) {
|
|
2545
|
+
break;
|
|
2546
|
+
}
|
|
2503
2547
|
}
|
|
2504
|
-
this.domains =
|
|
2505
|
-
return domains;
|
|
2548
|
+
this.domains = allDomains;
|
|
2549
|
+
return this.domains;
|
|
2506
2550
|
}
|
|
2507
2551
|
/**
|
|
2508
2552
|
* Create an API manager instance
|
|
@@ -2546,9 +2590,18 @@ var APIManagerBase = class {
|
|
|
2546
2590
|
return domainClient;
|
|
2547
2591
|
}
|
|
2548
2592
|
/**
|
|
2549
|
-
* Get the appropriate API client for a specific domain, handling MDS domain routing
|
|
2550
|
-
*
|
|
2551
|
-
*
|
|
2593
|
+
* Get the appropriate API client for a specific domain, handling MDS domain routing.
|
|
2594
|
+
* Uses login -d (credential-based domain login) as the primary path.
|
|
2595
|
+
*
|
|
2596
|
+
* Flow:
|
|
2597
|
+
* 1. login -d on current MDS root (works for both local and standby domains)
|
|
2598
|
+
* 2. Cross-MDS: find target MDS root IP via show-mdss, then login -d there
|
|
2599
|
+
* 3. Last resort: login directly to the active DMS virtual IP
|
|
2600
|
+
*
|
|
2601
|
+
* NOTE: This server currently exposes read-only APIs only. For reads, landing on a
|
|
2602
|
+
* standby DMS is acceptable — the data is replicated. If write operations are added
|
|
2603
|
+
* in the future, step 1 must be changed to enforce routing to the ACTIVE DMS server
|
|
2604
|
+
* (use getMDSServerForDomain which selects the active server from show-domains).
|
|
2552
2605
|
*/
|
|
2553
2606
|
async getDomainApiClientByDomain(domainName) {
|
|
2554
2607
|
const isMDS = await this.client.isMDSEnvironment();
|
|
@@ -2559,35 +2612,40 @@ var APIManagerBase = class {
|
|
|
2559
2612
|
if (existingDomainClient && existingDomainClient.hasValidSession()) {
|
|
2560
2613
|
return existingDomainClient;
|
|
2561
2614
|
}
|
|
2562
|
-
const isOnCurrentMDS = await this.isDomainOnCurrentMDS(domainName);
|
|
2563
|
-
if (isOnCurrentMDS) {
|
|
2564
|
-
const domainSid2 = await this.loginToDomain(domainName);
|
|
2565
|
-
const domainClient2 = this.createClientWithSid(domainSid2);
|
|
2566
|
-
this.domainClients.set(domainName, domainClient2);
|
|
2567
|
-
return domainClient2;
|
|
2568
|
-
}
|
|
2569
|
-
const targetMDSIP = await this.getMDSServerForDomain(domainName);
|
|
2570
|
-
if (!targetMDSIP) {
|
|
2571
|
-
throw new Error(`Domain '${domainName}' not found or has no available MDS servers. Make sure the domain exists and you have access to it.`);
|
|
2572
|
-
}
|
|
2573
2615
|
const currentHost = this.client.getHost();
|
|
2574
2616
|
const portMatch = currentHost.match(/:(\d+)/);
|
|
2575
2617
|
const port = portMatch ? portMatch[1] : "443";
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2618
|
+
try {
|
|
2619
|
+
const domainClient = this.createClientForMDS(this.client.managementHost, port, domainName);
|
|
2620
|
+
if ("debug" in domainClient)
|
|
2621
|
+
domainClient.debug = this._debug;
|
|
2622
|
+
await domainClient.login();
|
|
2623
|
+
this.domainClients.set(domainName, domainClient);
|
|
2624
|
+
return domainClient;
|
|
2625
|
+
} catch {
|
|
2579
2626
|
}
|
|
2580
|
-
await
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2627
|
+
const targetMDSIP = await this.getMDSRootForDomain(domainName);
|
|
2628
|
+
if (targetMDSIP) {
|
|
2629
|
+
try {
|
|
2630
|
+
const crossMDSClient = this.createClientForMDS(targetMDSIP, port, domainName);
|
|
2631
|
+
if ("debug" in crossMDSClient)
|
|
2632
|
+
crossMDSClient.debug = this._debug;
|
|
2633
|
+
await crossMDSClient.login();
|
|
2634
|
+
this.domainClients.set(domainName, crossMDSClient);
|
|
2635
|
+
return crossMDSClient;
|
|
2636
|
+
} catch {
|
|
2637
|
+
}
|
|
2586
2638
|
}
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2639
|
+
const dmsIP = await this.getMDSServerForDomain(domainName);
|
|
2640
|
+
if (!dmsIP) {
|
|
2641
|
+
throw new Error(`Domain '${domainName}' not found or has no available servers. Make sure the domain exists and you have access to it.`);
|
|
2642
|
+
}
|
|
2643
|
+
const targetClient = this.createClientForMDS(dmsIP, port);
|
|
2644
|
+
if ("debug" in targetClient)
|
|
2645
|
+
targetClient.debug = this._debug;
|
|
2646
|
+
await targetClient.login();
|
|
2647
|
+
this.domainClients.set(domainName, targetClient);
|
|
2648
|
+
return targetClient;
|
|
2591
2649
|
}
|
|
2592
2650
|
/**
|
|
2593
2651
|
* Get gateway information from show-gateways-and-servers
|
|
@@ -2626,20 +2684,53 @@ var APIManagerBase = class {
|
|
|
2626
2684
|
}
|
|
2627
2685
|
}
|
|
2628
2686
|
/**
|
|
2629
|
-
*
|
|
2687
|
+
* Get MDS server list from show-mdss with caching
|
|
2630
2688
|
*/
|
|
2631
|
-
async
|
|
2689
|
+
async getMDSServers() {
|
|
2690
|
+
if (this.mdsServers !== null) {
|
|
2691
|
+
return this.mdsServers;
|
|
2692
|
+
}
|
|
2693
|
+
try {
|
|
2694
|
+
const response = await this.callApi("post", "show-mdss", {
|
|
2695
|
+
"details-level": "full",
|
|
2696
|
+
"limit": 500
|
|
2697
|
+
});
|
|
2698
|
+
const servers = [];
|
|
2699
|
+
if (response.objects) {
|
|
2700
|
+
for (const obj of response.objects) {
|
|
2701
|
+
if (obj.name) {
|
|
2702
|
+
servers.push({
|
|
2703
|
+
name: obj.name,
|
|
2704
|
+
"ipv4-address": obj["ipv4-address"],
|
|
2705
|
+
"ipv6-address": obj["ipv6-address"]
|
|
2706
|
+
});
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
this.mdsServers = servers;
|
|
2711
|
+
} catch {
|
|
2712
|
+
this.mdsServers = [];
|
|
2713
|
+
}
|
|
2714
|
+
return this.mdsServers;
|
|
2715
|
+
}
|
|
2716
|
+
/**
|
|
2717
|
+
* Return the MDS root IP for the domain's active server.
|
|
2718
|
+
* Maps the domain's `multi-domain-server` name (from show-domains) to an MDS
|
|
2719
|
+
* root IP (from show-mdss). Returns null if the domain is not found or the MDS
|
|
2720
|
+
* root IP cannot be determined.
|
|
2721
|
+
*/
|
|
2722
|
+
async getMDSRootForDomain(domainName) {
|
|
2632
2723
|
const domains = await this.getDomains();
|
|
2633
2724
|
const domain = domains.find((d) => d.name === domainName);
|
|
2634
|
-
if (!domain?.servers
|
|
2635
|
-
return
|
|
2636
|
-
|
|
2637
|
-
const
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2725
|
+
if (!domain?.servers?.length)
|
|
2726
|
+
return null;
|
|
2727
|
+
const activeServer = domain.servers.find((s) => s.active === true) ?? domain.servers[0];
|
|
2728
|
+
const targetMDSName = activeServer?.["multi-domain-server"];
|
|
2729
|
+
if (!targetMDSName)
|
|
2730
|
+
return null;
|
|
2731
|
+
const mdsServers = await this.getMDSServers();
|
|
2732
|
+
const mdsServer = mdsServers.find((m) => m.name === targetMDSName);
|
|
2733
|
+
return mdsServer?.["ipv4-address"] ?? mdsServer?.["ipv6-address"] ?? null;
|
|
2643
2734
|
}
|
|
2644
2735
|
/**
|
|
2645
2736
|
* Get the appropriate MDS server IP for a domain
|
|
@@ -2669,15 +2760,16 @@ var APIManagerBase = class {
|
|
|
2669
2760
|
return ipv6Server?.["ipv6-address"] || null;
|
|
2670
2761
|
}
|
|
2671
2762
|
/**
|
|
2672
|
-
* Create a new API client
|
|
2673
|
-
*
|
|
2674
|
-
*
|
|
2763
|
+
* Create a new API client targeting a specific host (MDS root or DMS IP).
|
|
2764
|
+
* When `domain` is provided it is included in the login payload, causing the
|
|
2765
|
+
* server to return a domain-scoped session (equivalent to login -d).
|
|
2766
|
+
* Handles both IPv4 and IPv6 addresses.
|
|
2675
2767
|
*/
|
|
2676
|
-
createClientForMDS(mdsIP, port = "443") {
|
|
2768
|
+
createClientForMDS(mdsIP, port = "443", domain) {
|
|
2677
2769
|
if (this.client instanceof OnPremAPIClient) {
|
|
2678
2770
|
const currentClient = this.client;
|
|
2679
2771
|
const formattedHost = mdsIP.includes(":") && !mdsIP.startsWith("[") ? `[${mdsIP}]` : mdsIP;
|
|
2680
|
-
return new OnPremAPIClient(currentClient.authToken || void 0, formattedHost, port, currentClient.username, currentClient.password);
|
|
2772
|
+
return new OnPremAPIClient(currentClient.authToken || void 0, formattedHost, port, currentClient.username, currentClient.password, domain);
|
|
2681
2773
|
} else if (this.client instanceof SmartOneCloudAPIClient) {
|
|
2682
2774
|
throw new Error("Multi-MDS routing is not supported for SmartOneCloud environments");
|
|
2683
2775
|
} else {
|
|
@@ -2744,10 +2836,11 @@ var APIManagerForAPIKey = class extends APIManagerBase {
|
|
|
2744
2836
|
managementHost: args.managementHost,
|
|
2745
2837
|
managementPort: args.managementPort,
|
|
2746
2838
|
s1cUrl: args.s1cUrl,
|
|
2747
|
-
cloudInfraToken: args.cloudInfraToken ? "***" : void 0
|
|
2839
|
+
cloudInfraToken: args.cloudInfraToken ? "***" : void 0,
|
|
2840
|
+
sid: args.sid ? "***" : void 0
|
|
2748
2841
|
});
|
|
2749
2842
|
}
|
|
2750
|
-
const hasAnyValue = args.apiKey || args.username || args.password || args.s1cUrl || args.managementHost || args.cloudInfraToken;
|
|
2843
|
+
const hasAnyValue = args.apiKey || args.username || args.password || args.s1cUrl || args.managementHost || args.cloudInfraToken || args.sid;
|
|
2751
2844
|
if (!hasAnyValue) {
|
|
2752
2845
|
if (verbose) {
|
|
2753
2846
|
console.error("[APIManagerForAPIKey.create] Verbose: ERROR - Args object is effectively empty, no values provided");
|
|
@@ -2760,6 +2853,12 @@ var APIManagerForAPIKey = class extends APIManagerBase {
|
|
|
2760
2853
|
console.error("[APIManagerForAPIKey.create] Verbose: Using on-prem management with host:", args.managementHost);
|
|
2761
2854
|
}
|
|
2762
2855
|
const onPremClient = new OnPremAPIClient(args.apiKey, args.managementHost, args.managementPort || "443", args.username, args.password);
|
|
2856
|
+
if (args.sid) {
|
|
2857
|
+
if (verbose) {
|
|
2858
|
+
console.error("[APIManagerForAPIKey.create] Verbose: Setting external SID on on-prem client (skipping login)");
|
|
2859
|
+
}
|
|
2860
|
+
onPremClient.setExternalSid(args.sid);
|
|
2861
|
+
}
|
|
2763
2862
|
return new this(onPremClient);
|
|
2764
2863
|
}
|
|
2765
2864
|
if (verbose) {
|
|
@@ -2788,13 +2887,26 @@ var APIManagerForAPIKey = class extends APIManagerBase {
|
|
|
2788
2887
|
}
|
|
2789
2888
|
keyType = TokenType.API_KEY;
|
|
2790
2889
|
key = args.apiKey;
|
|
2890
|
+
} else if (args.sid) {
|
|
2891
|
+
if (verbose) {
|
|
2892
|
+
console.error("[APIManagerForAPIKey.create] Verbose: Using external SID with S1C (no auth token needed)");
|
|
2893
|
+
}
|
|
2894
|
+
keyType = TokenType.API_KEY;
|
|
2895
|
+
key = "";
|
|
2791
2896
|
} else {
|
|
2792
2897
|
if (verbose) {
|
|
2793
2898
|
console.error("[APIManagerForAPIKey.create] Verbose: ERROR - No API key or cloud infra token provided");
|
|
2794
2899
|
}
|
|
2795
2900
|
throw new Error("API key or cloud infrastructure token is required");
|
|
2796
2901
|
}
|
|
2797
|
-
|
|
2902
|
+
const s1cClient = SmartOneCloudAPIClient.create(key, keyType, args.s1cUrl, !!args.cloudConnected);
|
|
2903
|
+
if (args.sid) {
|
|
2904
|
+
if (verbose) {
|
|
2905
|
+
console.error("[APIManagerForAPIKey.create] Verbose: Setting external SID on S1C client (skipping login)");
|
|
2906
|
+
}
|
|
2907
|
+
s1cClient.setExternalSid(args.sid);
|
|
2908
|
+
}
|
|
2909
|
+
return new this(s1cClient);
|
|
2798
2910
|
}
|
|
2799
2911
|
};
|
|
2800
2912
|
|
|
@@ -2833,7 +2945,7 @@ var Settings = class _Settings {
|
|
|
2833
2945
|
return "STG";
|
|
2834
2946
|
return void 0;
|
|
2835
2947
|
}
|
|
2836
|
-
constructor({ apiKey = process.env.API_KEY, username = process.env.USERNAME, password = process.env.PASSWORD, s1cUrl = process.env.S1C_URL, managementHost = process.env.MANAGEMENT_HOST, managementPort = process.env.MANAGEMENT_PORT || "443", cloudInfraToken = process.env.CLOUD_INFRA_TOKEN, cloudConnected = process.env.CLOUD_CONNECTED === "true", clientId = process.env.CLIENT_ID, secretKey = process.env.SECRET_KEY, region = process.env.REGION || "EU", devPort = process.env.DEV_PORT || "8006", gatewayUrl } = {}) {
|
|
2948
|
+
constructor({ apiKey = process.env.API_KEY, username = process.env.USERNAME, password = process.env.PASSWORD, s1cUrl = process.env.S1C_URL, managementHost = process.env.MANAGEMENT_HOST, managementPort = process.env.MANAGEMENT_PORT || "443", cloudInfraToken = process.env.CLOUD_INFRA_TOKEN, cloudConnected = process.env.CLOUD_CONNECTED === "true", sid, clientId = process.env.CLIENT_ID, secretKey = process.env.SECRET_KEY, region = process.env.REGION || "EU", devPort = process.env.DEV_PORT || "8006", gatewayUrl } = {}) {
|
|
2837
2949
|
this.region = "EU";
|
|
2838
2950
|
this.devPort = "8006";
|
|
2839
2951
|
this.gatewayUrl = "";
|
|
@@ -2861,6 +2973,7 @@ var Settings = class _Settings {
|
|
|
2861
2973
|
this.managementPort = managementPort;
|
|
2862
2974
|
this.cloudInfraToken = cloudInfraToken;
|
|
2863
2975
|
this.cloudConnected = cloudConnected;
|
|
2976
|
+
this.sid = sid;
|
|
2864
2977
|
this.clientId = clientId;
|
|
2865
2978
|
this.secretKey = secretKey;
|
|
2866
2979
|
this.region = this.normalizeRegion(region) || "EU";
|
|
@@ -2934,6 +3047,7 @@ var Settings = class _Settings {
|
|
|
2934
3047
|
const verbose = SettingsManager.globalDebugState;
|
|
2935
3048
|
if (verbose) {
|
|
2936
3049
|
console.error("[Settings] Verbose: Validating settings...");
|
|
3050
|
+
console.error("[Settings] Verbose: sid:", this.sid ? "***" : "(empty)");
|
|
2937
3051
|
console.error("[Settings] Verbose: s1cUrl:", this.s1cUrl || "(empty)");
|
|
2938
3052
|
console.error("[Settings] Verbose: managementHost:", this.managementHost || "(empty)");
|
|
2939
3053
|
console.error("[Settings] Verbose: apiKey:", this.apiKey ? "***" : "(empty)");
|
|
@@ -2941,17 +3055,35 @@ var Settings = class _Settings {
|
|
|
2941
3055
|
console.error("[Settings] Verbose: username:", this.username ? "***" : "(empty)");
|
|
2942
3056
|
console.error("[Settings] Verbose: password:", this.password ? "***" : "(empty)");
|
|
2943
3057
|
}
|
|
2944
|
-
if (!nullOrEmpty(this.
|
|
3058
|
+
if (!nullOrEmpty(this.sid)) {
|
|
2945
3059
|
if (verbose) {
|
|
2946
|
-
console.error("[Settings] Verbose:
|
|
3060
|
+
console.error("[Settings] Verbose: Pre-authenticated SID provided, skipping credential validation");
|
|
3061
|
+
}
|
|
3062
|
+
return;
|
|
3063
|
+
}
|
|
3064
|
+
if (!nullOrEmpty(this.s1cUrl) && nullOrEmpty(this.apiKey) && nullOrEmpty(this.cloudInfraToken)) {
|
|
3065
|
+
if (process.env.MCP_TRANSPORT_TYPE?.toLowerCase() === "http") {
|
|
3066
|
+
if (verbose) {
|
|
3067
|
+
console.error("[Settings] Verbose: S1C URL provided without credentials, but HTTP transport mode allows per-request auth via headers");
|
|
3068
|
+
}
|
|
3069
|
+
} else {
|
|
3070
|
+
if (verbose) {
|
|
3071
|
+
console.error("[Settings] Verbose: Validation FAILED - S1C URL provided but no API key or CI token");
|
|
3072
|
+
}
|
|
3073
|
+
throw new Error("API key or CI Token is required for S1C (via --api-key or API_KEY env var)");
|
|
2947
3074
|
}
|
|
2948
|
-
throw new Error("API key or CI Token is required for S1C (via --api-key or API_KEY env var)");
|
|
2949
3075
|
}
|
|
2950
3076
|
if (!nullOrEmpty(this.managementHost) && nullOrEmpty(this.apiKey) && (nullOrEmpty(this.username) || nullOrEmpty(this.password))) {
|
|
2951
|
-
if (
|
|
2952
|
-
|
|
3077
|
+
if (process.env.MCP_TRANSPORT_TYPE?.toLowerCase() === "http") {
|
|
3078
|
+
if (verbose) {
|
|
3079
|
+
console.error("[Settings] Verbose: Management host provided without credentials, but HTTP transport mode allows per-request auth via headers");
|
|
3080
|
+
}
|
|
3081
|
+
} else {
|
|
3082
|
+
if (verbose) {
|
|
3083
|
+
console.error("[Settings] Verbose: Validation FAILED - Management host provided but no API key or credentials");
|
|
3084
|
+
}
|
|
3085
|
+
throw new Error("Either API key or username/password are required for on-prem management (via CLI args or env vars)");
|
|
2953
3086
|
}
|
|
2954
|
-
throw new Error("Either API key or username/password are required for on-prem management (via CLI args or env vars)");
|
|
2955
3087
|
}
|
|
2956
3088
|
if (nullOrEmpty(this.s1cUrl) && nullOrEmpty(this.managementHost)) {
|
|
2957
3089
|
if (verbose) {
|
|
@@ -3020,6 +3152,7 @@ var Settings = class _Settings {
|
|
|
3020
3152
|
managementPort: getHeaderValue(headers, "MANAGEMENT-PORT"),
|
|
3021
3153
|
cloudInfraToken: getHeaderValue(headers, "CLOUD-INFRA-TOKEN"),
|
|
3022
3154
|
cloudConnected: getHeaderValue(headers, "CLOUD-CONNECTED"),
|
|
3155
|
+
sid: getHeaderValue(headers, "X-chkp-sid"),
|
|
3023
3156
|
clientId: getHeaderValue(headers, "CLIENT-ID"),
|
|
3024
3157
|
secretKey: getHeaderValue(headers, "SECRET-KEY"),
|
|
3025
3158
|
region: getHeaderValue(headers, "REGION"),
|
|
@@ -3053,6 +3186,7 @@ var Settings = class _Settings {
|
|
|
3053
3186
|
managementPort: extractedValues.managementPort,
|
|
3054
3187
|
cloudInfraToken: extractedValues.cloudInfraToken,
|
|
3055
3188
|
cloudConnected: extractedValues.cloudConnected === "true",
|
|
3189
|
+
sid: extractedValues.sid,
|
|
3056
3190
|
clientId: extractedValues.clientId,
|
|
3057
3191
|
secretKey: extractedValues.secretKey,
|
|
3058
3192
|
region: extractedValues.region?.toUpperCase(),
|
|
@@ -3170,7 +3304,8 @@ async function executeApiTool(toolName, definition, validatedArgs, extra) {
|
|
|
3170
3304
|
}
|
|
3171
3305
|
const requestBody = validatedArgs?.["requestBody"] || {};
|
|
3172
3306
|
if (validatedArgs.domains_to_process) {
|
|
3173
|
-
requestBody["domains-to-process"] =
|
|
3307
|
+
requestBody["domains-to-process"] = [validatedArgs.domains_to_process];
|
|
3308
|
+
requestBody["ignore-warnings"] = true;
|
|
3174
3309
|
}
|
|
3175
3310
|
const resp = await runApi("POST", urlPath, requestBody, extra, domain);
|
|
3176
3311
|
console.error(`=== DEBUG: Response received ===`);
|
package/dist/package.json
CHANGED
package/package.json
CHANGED