@onlyflows/servicenow-mcp 2.2.0-dev.6 → 2.2.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.
- package/.env.example +6 -3
- package/CHANGELOG.md +404 -0
- package/README.md +580 -104
- package/dist/atf-form.d.ts +3 -15
- package/dist/atf-form.d.ts.map +1 -1
- package/dist/atf-policy.d.ts +1 -1
- package/dist/atf-policy.d.ts.map +1 -1
- package/dist/atf-policy.js +2 -0
- package/dist/atf-policy.js.map +1 -1
- package/dist/atf-result-cache.d.ts +23 -59
- package/dist/atf-result-cache.d.ts.map +1 -1
- package/dist/auth.d.ts +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +17 -0
- package/dist/auth.js.map +1 -1
- package/dist/batch-limits.d.ts +18 -0
- package/dist/batch-limits.d.ts.map +1 -0
- package/dist/batch-limits.js +21 -0
- package/dist/batch-limits.js.map +1 -0
- package/dist/bounded-input.d.ts +49 -0
- package/dist/bounded-input.d.ts.map +1 -0
- package/dist/bounded-input.js +81 -0
- package/dist/bounded-input.js.map +1 -0
- package/dist/client.d.ts +25 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +92 -18
- package/dist/client.js.map +1 -1
- package/dist/credential-tables.d.ts +32 -0
- package/dist/credential-tables.d.ts.map +1 -0
- package/dist/credential-tables.js +58 -0
- package/dist/credential-tables.js.map +1 -0
- package/dist/encoded-query-policy.d.ts +11 -0
- package/dist/encoded-query-policy.d.ts.map +1 -1
- package/dist/encoded-query-policy.js +18 -2
- package/dist/encoded-query-policy.js.map +1 -1
- package/dist/execution-context.d.ts +14 -0
- package/dist/execution-context.d.ts.map +1 -1
- package/dist/execution-context.js +8 -0
- package/dist/execution-context.js.map +1 -1
- package/dist/field-policy.d.ts +115 -3
- package/dist/field-policy.d.ts.map +1 -1
- package/dist/field-policy.js +909 -97
- package/dist/field-policy.js.map +1 -1
- package/dist/hidden-values.d.ts +225 -0
- package/dist/hidden-values.d.ts.map +1 -0
- package/dist/hidden-values.js +748 -0
- package/dist/hidden-values.js.map +1 -0
- package/dist/html-response.d.ts +34 -0
- package/dist/html-response.d.ts.map +1 -0
- package/dist/html-response.js +72 -0
- package/dist/html-response.js.map +1 -0
- package/dist/http-entrypoint.d.ts.map +1 -1
- package/dist/http-entrypoint.js +7 -0
- package/dist/http-entrypoint.js.map +1 -1
- package/dist/http-runtime.d.ts.map +1 -1
- package/dist/http-runtime.js +8 -0
- package/dist/http-runtime.js.map +1 -1
- package/dist/incident-journal-policy.d.ts +27 -5
- package/dist/incident-journal-policy.d.ts.map +1 -1
- package/dist/incident-journal-policy.js +34 -21
- package/dist/incident-journal-policy.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/json-shape-limits.d.ts +71 -0
- package/dist/json-shape-limits.d.ts.map +1 -0
- package/dist/json-shape-limits.js +131 -0
- package/dist/json-shape-limits.js.map +1 -0
- package/dist/metadata-cache.d.ts +84 -21
- package/dist/metadata-cache.d.ts.map +1 -1
- package/dist/metadata-cache.js +316 -196
- package/dist/metadata-cache.js.map +1 -1
- package/dist/policy-card.d.ts +146 -0
- package/dist/policy-card.d.ts.map +1 -0
- package/dist/policy-card.js +420 -0
- package/dist/policy-card.js.map +1 -0
- package/dist/profile-manager.d.ts +19 -3
- package/dist/profile-manager.d.ts.map +1 -1
- package/dist/profile-manager.js +89 -4
- package/dist/profile-manager.js.map +1 -1
- package/dist/record-identifier-policy.d.ts +2 -8
- package/dist/record-identifier-policy.d.ts.map +1 -1
- package/dist/risky-grants.d.ts +25 -0
- package/dist/risky-grants.d.ts.map +1 -0
- package/dist/risky-grants.js +77 -0
- package/dist/risky-grants.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +26 -5
- package/dist/server.js.map +1 -1
- package/dist/setup-prompts.js +1 -0
- package/dist/setup-prompts.js.map +1 -1
- package/dist/setup.d.ts +1 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +305 -59
- package/dist/setup.js.map +1 -1
- package/dist/stdio-runtime.d.ts +15 -0
- package/dist/stdio-runtime.d.ts.map +1 -1
- package/dist/stdio-runtime.js +60 -0
- package/dist/stdio-runtime.js.map +1 -1
- package/dist/structured-query.d.ts +100 -115
- package/dist/structured-query.d.ts.map +1 -1
- package/dist/structured-query.js +138 -17
- package/dist/structured-query.js.map +1 -1
- package/dist/table-policy.d.ts +41 -4
- package/dist/table-policy.d.ts.map +1 -1
- package/dist/table-policy.js +82 -10
- package/dist/table-policy.js.map +1 -1
- package/dist/tool-error.d.ts +34 -0
- package/dist/tool-error.d.ts.map +1 -1
- package/dist/tool-error.js +109 -1
- package/dist/tool-error.js.map +1 -1
- package/dist/tool-table-access.d.ts.map +1 -1
- package/dist/tool-table-access.js +35 -5
- package/dist/tool-table-access.js.map +1 -1
- package/dist/tools/aggregate.d.ts +13 -19
- package/dist/tools/aggregate.d.ts.map +1 -1
- package/dist/tools/aggregate.js +4 -5
- package/dist/tools/aggregate.js.map +1 -1
- package/dist/tools/all-fields-cap.d.ts.map +1 -1
- package/dist/tools/all-fields-cap.js +32 -45
- package/dist/tools/all-fields-cap.js.map +1 -1
- package/dist/tools/atf-author-module.d.ts +29 -14
- package/dist/tools/atf-author-module.d.ts.map +1 -1
- package/dist/tools/atf-author-module.js +11 -5
- package/dist/tools/atf-author-module.js.map +1 -1
- package/dist/tools/atf-contracts.d.ts +135 -829
- package/dist/tools/atf-contracts.d.ts.map +1 -1
- package/dist/tools/atf-shared.js +2 -2
- package/dist/tools/atf-shared.js.map +1 -1
- package/dist/tools/atf-step-catalog.d.ts +16 -15
- package/dist/tools/atf-step-catalog.d.ts.map +1 -1
- package/dist/tools/atf-step-catalog.js +181 -10
- package/dist/tools/atf-step-catalog.js.map +1 -1
- package/dist/tools/atf.d.ts +8 -24
- package/dist/tools/atf.d.ts.map +1 -1
- package/dist/tools/atf.js +2 -2
- package/dist/tools/atf.js.map +1 -1
- package/dist/tools/attach.d.ts +6 -22
- package/dist/tools/attach.d.ts.map +1 -1
- package/dist/tools/batch.d.ts +18 -71
- package/dist/tools/batch.d.ts.map +1 -1
- package/dist/tools/batch.js +566 -100
- package/dist/tools/batch.js.map +1 -1
- package/dist/tools/catalog.d.ts +2 -2
- package/dist/tools/catalog.d.ts.map +1 -1
- package/dist/tools/catalog.js +7 -1
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/codesearch.d.ts +1 -13
- package/dist/tools/codesearch.d.ts.map +1 -1
- package/dist/tools/create-module.d.ts +9 -14
- package/dist/tools/create-module.d.ts.map +1 -1
- package/dist/tools/create-module.js +4 -8
- package/dist/tools/create-module.js.map +1 -1
- package/dist/tools/delete.d.ts +1 -9
- package/dist/tools/delete.d.ts.map +1 -1
- package/dist/tools/delete.js +2 -3
- package/dist/tools/delete.js.map +1 -1
- package/dist/tools/discover.d.ts +6 -14
- package/dist/tools/discover.d.ts.map +1 -1
- package/dist/tools/flow-view-contracts.d.ts +1023 -0
- package/dist/tools/flow-view-contracts.d.ts.map +1 -0
- package/dist/tools/flow-view-contracts.js +570 -0
- package/dist/tools/flow-view-contracts.js.map +1 -0
- package/dist/tools/flow-view-graph.d.ts +86 -0
- package/dist/tools/flow-view-graph.d.ts.map +1 -0
- package/dist/tools/flow-view-graph.js +993 -0
- package/dist/tools/flow-view-graph.js.map +1 -0
- package/dist/tools/flow-view-gzip.d.ts +52 -0
- package/dist/tools/flow-view-gzip.d.ts.map +1 -0
- package/dist/tools/flow-view-gzip.js +179 -0
- package/dist/tools/flow-view-gzip.js.map +1 -0
- package/dist/tools/flow-view-mermaid.d.ts +37 -0
- package/dist/tools/flow-view-mermaid.d.ts.map +1 -0
- package/dist/tools/flow-view-mermaid.js +337 -0
- package/dist/tools/flow-view-mermaid.js.map +1 -0
- package/dist/tools/flow-view-module.d.ts +61 -0
- package/dist/tools/flow-view-module.d.ts.map +1 -0
- package/dist/tools/flow-view-module.js +378 -0
- package/dist/tools/flow-view-module.js.map +1 -0
- package/dist/tools/flow-view-policy.d.ts +106 -0
- package/dist/tools/flow-view-policy.d.ts.map +1 -0
- package/dist/tools/flow-view-policy.js +462 -0
- package/dist/tools/flow-view-policy.js.map +1 -0
- package/dist/tools/flow-view-renderers.d.ts +68 -0
- package/dist/tools/flow-view-renderers.d.ts.map +1 -0
- package/dist/tools/flow-view-renderers.js +513 -0
- package/dist/tools/flow-view-renderers.js.map +1 -0
- package/dist/tools/flow-view-table.d.ts +115 -0
- package/dist/tools/flow-view-table.d.ts.map +1 -0
- package/dist/tools/flow-view-table.js +1002 -0
- package/dist/tools/flow-view-table.js.map +1 -0
- package/dist/tools/get-module.d.ts +36 -42
- package/dist/tools/get-module.d.ts.map +1 -1
- package/dist/tools/health.d.ts +9 -6
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/incident-journal-module.d.ts +8 -7
- package/dist/tools/incident-journal-module.d.ts.map +1 -1
- package/dist/tools/index.d.ts +4 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +118 -18
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/markdown.d.ts +27 -0
- package/dist/tools/markdown.d.ts.map +1 -1
- package/dist/tools/markdown.js +104 -1
- package/dist/tools/markdown.js.map +1 -1
- package/dist/tools/nl.d.ts +1 -11
- package/dist/tools/nl.d.ts.map +1 -1
- package/dist/tools/profile.d.ts +1 -1
- package/dist/tools/profile.d.ts.map +1 -1
- package/dist/tools/profile.js +20 -1
- package/dist/tools/profile.js.map +1 -1
- package/dist/tools/query-module.d.ts +59 -71
- package/dist/tools/query-module.d.ts.map +1 -1
- package/dist/tools/query-module.js +28 -7
- package/dist/tools/query-module.js.map +1 -1
- package/dist/tools/record-write-shared.d.ts.map +1 -1
- package/dist/tools/record-write-shared.js +20 -2
- package/dist/tools/record-write-shared.js.map +1 -1
- package/dist/tools/relationships.d.ts +6 -22
- package/dist/tools/relationships.d.ts.map +1 -1
- package/dist/tools/result-envelope.d.ts +2255 -1357
- package/dist/tools/result-envelope.d.ts.map +1 -1
- package/dist/tools/result-envelope.js +24 -2
- package/dist/tools/result-envelope.js.map +1 -1
- package/dist/tools/schema-module.d.ts +36 -21
- package/dist/tools/schema-module.d.ts.map +1 -1
- package/dist/tools/schema-module.js +106 -65
- package/dist/tools/schema-module.js.map +1 -1
- package/dist/tools/script.d.ts +1 -11
- package/dist/tools/script.d.ts.map +1 -1
- package/dist/tools/syslog.d.ts +11 -18
- package/dist/tools/syslog.d.ts.map +1 -1
- package/dist/tools/syslog.js +2 -3
- package/dist/tools/syslog.js.map +1 -1
- package/dist/tools/table-hierarchy.d.ts +35 -0
- package/dist/tools/table-hierarchy.d.ts.map +1 -0
- package/dist/tools/table-hierarchy.js +74 -0
- package/dist/tools/table-hierarchy.js.map +1 -0
- package/dist/tools/tool-module.d.ts +40 -15
- package/dist/tools/tool-module.d.ts.map +1 -1
- package/dist/tools/tool-module.js +755 -205
- package/dist/tools/tool-module.js.map +1 -1
- package/dist/tools/update-module.d.ts +11 -17
- package/dist/tools/update-module.d.ts.map +1 -1
- package/dist/tools/update-module.js +10 -12
- package/dist/tools/update-module.js.map +1 -1
- package/dist/unknown-filter-fields.d.ts +52 -0
- package/dist/unknown-filter-fields.d.ts.map +1 -0
- package/dist/unknown-filter-fields.js +87 -0
- package/dist/unknown-filter-fields.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/write-value-policy.d.ts +20 -12
- package/dist/write-value-policy.d.ts.map +1 -1
- package/dist/write-value-policy.js +179 -67
- package/dist/write-value-policy.js.map +1 -1
- package/docs/ADDING-TOOLS.md +22 -13
- package/docs/CLIENT-SETUP.md +110 -52
- package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +2 -2
- package/docs/FLOW-VIEW.md +214 -0
- package/docs/PRODUCTION-SECURITY.md +218 -25
- package/docs/RELEASE-VALIDATION.md +2 -2
- package/docs/TESTING-OAUTH.md +1 -1
- package/docs/V2-MIGRATION.md +404 -30
- package/package.json +20 -6
- package/scripts/release-validate.mjs +56 -0
- package/server.json +22 -0
- package/tools/inspector/package-lock.json +163 -201
package/dist/setup.js
CHANGED
|
@@ -40,8 +40,14 @@ const command_resolution_js_1 = require("./command-resolution.js");
|
|
|
40
40
|
const profile_admin_js_1 = require("./profile-admin.js");
|
|
41
41
|
const profile_credentials_js_1 = require("./profile-credentials.js");
|
|
42
42
|
const profile_manager_js_1 = require("./profile-manager.js");
|
|
43
|
+
const policy_card_js_1 = require("./policy-card.js");
|
|
44
|
+
const hidden_values_js_1 = require("./hidden-values.js");
|
|
45
|
+
const risky_grants_js_1 = require("./risky-grants.js");
|
|
43
46
|
const tool_error_js_1 = require("./tool-error.js");
|
|
44
47
|
const table_policy_js_1 = require("./table-policy.js");
|
|
48
|
+
const encoded_query_policy_js_1 = require("./encoded-query-policy.js");
|
|
49
|
+
const flow_view_contracts_js_1 = require("./tools/flow-view-contracts.js");
|
|
50
|
+
const table_hierarchy_js_1 = require("./tools/table-hierarchy.js");
|
|
45
51
|
/** Raised when the operator aborts; nothing has been written to the profile. */
|
|
46
52
|
class WizardAbort extends Error {
|
|
47
53
|
constructor() {
|
|
@@ -125,6 +131,16 @@ const DEFAULT_WRITE_TOOLS = Object.freeze([
|
|
|
125
131
|
"sn_create",
|
|
126
132
|
"sn_update",
|
|
127
133
|
]);
|
|
134
|
+
/**
|
|
135
|
+
* Added to the `incident` target by a write grant when `--tools` is not given.
|
|
136
|
+
* These tools append to comments and work_notes and are authorized as incident
|
|
137
|
+
* writes, so an incident target that omitted them would deny them on a profile
|
|
138
|
+
* that can otherwise write incident.
|
|
139
|
+
*/
|
|
140
|
+
const INCIDENT_JOURNAL_TOOLS = Object.freeze([
|
|
141
|
+
"sn_incident_add_comment",
|
|
142
|
+
"sn_incident_add_work_note",
|
|
143
|
+
]);
|
|
128
144
|
async function runSetupCli(dependencies = {}) {
|
|
129
145
|
const env = dependencies.env ?? process.env;
|
|
130
146
|
const argv = normalizeArgv(dependencies.argv ?? process.argv.slice(2));
|
|
@@ -139,6 +155,9 @@ async function runSetupCli(dependencies = {}) {
|
|
|
139
155
|
case "grant":
|
|
140
156
|
runGrant(parseGrantArguments(args), home, dependencies, out);
|
|
141
157
|
return;
|
|
158
|
+
case "policy":
|
|
159
|
+
runPolicy(parsePolicyArguments(args), home, env, dependencies, out);
|
|
160
|
+
return;
|
|
142
161
|
case "doctor":
|
|
143
162
|
await runDoctor(parseDoctorArguments(args), home, env, dependencies, out);
|
|
144
163
|
return;
|
|
@@ -275,6 +294,11 @@ async function runWizard(options, home, env, dependencies, out) {
|
|
|
275
294
|
}
|
|
276
295
|
// 5. Table access. A profile without rules denies every call.
|
|
277
296
|
const tableAccess = await askTableAccess(prompter, config, dependencies);
|
|
297
|
+
// Allowed, never blocked: privilege-sensitive tables are controlled by the
|
|
298
|
+
// profile's own configuration. The operator just has to see it said.
|
|
299
|
+
const riskWarning = (0, risky_grants_js_1.riskyGrantWarning)(tableAccess.writeTables ?? [], name);
|
|
300
|
+
if (riskWarning !== undefined)
|
|
301
|
+
prompter.note(`\n${riskWarning}`);
|
|
278
302
|
// 6. One write, with the rules already attached — never a rules-less window.
|
|
279
303
|
//
|
|
280
304
|
// Retryable without re-prompting: everything needed is already in memory,
|
|
@@ -434,7 +458,19 @@ function wizardConfig(profile, captured, mode, env) {
|
|
|
434
458
|
* accepts it.
|
|
435
459
|
*/
|
|
436
460
|
async function verifyCredentialAgainstInstance(config) {
|
|
437
|
-
|
|
461
|
+
let client;
|
|
462
|
+
try {
|
|
463
|
+
client = new client_js_1.ServiceNowClient(config, { maxRetries: 0 });
|
|
464
|
+
}
|
|
465
|
+
catch {
|
|
466
|
+
// Construction failed (for example an OAuth profile with no client
|
|
467
|
+
// secret): no request was sent, so this is not an HTTP 401.
|
|
468
|
+
return Object.freeze({
|
|
469
|
+
ok: false,
|
|
470
|
+
detail: `${safeHost(config.instance)}: the profile's credentials are incomplete, so no request was sent.`,
|
|
471
|
+
remedy: "Re-enter them with servicenow-mcp-setup.",
|
|
472
|
+
});
|
|
473
|
+
}
|
|
438
474
|
try {
|
|
439
475
|
await client.get(`/api/now/table/${WIZARD_PROBE_TABLE}`, {
|
|
440
476
|
sysparm_limit: "1",
|
|
@@ -453,6 +489,34 @@ async function verifyCredentialAgainstInstance(config) {
|
|
|
453
489
|
function classifyVerificationFailure(error, config) {
|
|
454
490
|
const descriptor = (0, tool_error_js_1.trustedToolErrorDescriptor)(error);
|
|
455
491
|
const host = safeHost(config.instance);
|
|
492
|
+
if (descriptor?.reason === "instance_hibernating") {
|
|
493
|
+
return Object.freeze({
|
|
494
|
+
ok: false,
|
|
495
|
+
detail: `Instance hibernating: ${host} answered with a hibernation page instead of the API.`,
|
|
496
|
+
remedy: "Developer instances sleep when idle. Wake it at https://developer.servicenow.com, wait a few minutes, then retry.",
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
if (descriptor?.reason === "html_response") {
|
|
500
|
+
return Object.freeze({
|
|
501
|
+
ok: false,
|
|
502
|
+
detail: `${host} returned an HTML page instead of an API response.`,
|
|
503
|
+
remedy: "The instance may be asleep, behind single sign-on, or under maintenance. Check that the instance URL is reachable in a browser.",
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
if (descriptor?.reason === "redirected") {
|
|
507
|
+
return Object.freeze({
|
|
508
|
+
ok: false,
|
|
509
|
+
detail: `${host} redirected the request to another location.`,
|
|
510
|
+
remedy: "Check that the profile's instance URL is the instance's canonical URL.",
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
if (descriptor?.reason === "invalid_response") {
|
|
514
|
+
return Object.freeze({
|
|
515
|
+
ok: false,
|
|
516
|
+
detail: `${host} returned a response that is not valid JSON.`,
|
|
517
|
+
remedy: "Check that the instance URL is correct and reachable in a browser.",
|
|
518
|
+
});
|
|
519
|
+
}
|
|
456
520
|
if (descriptor?.category === "authentication") {
|
|
457
521
|
return Object.freeze({
|
|
458
522
|
ok: false,
|
|
@@ -515,7 +579,8 @@ function classifyVerificationFailure(error, config) {
|
|
|
515
579
|
}
|
|
516
580
|
return Object.freeze({
|
|
517
581
|
ok: false,
|
|
518
|
-
|
|
582
|
+
// Fixed text only: the underlying message can quote response bytes.
|
|
583
|
+
detail: `${host} could not be reached.`,
|
|
519
584
|
remedy: "Check the instance URL and this machine's outbound network access.",
|
|
520
585
|
});
|
|
521
586
|
}
|
|
@@ -534,10 +599,11 @@ async function askTableAccess(prompter, config, dependencies) {
|
|
|
534
599
|
const read = await askTableSelection(prompter, "READS", DEFAULT_READ_TABLES);
|
|
535
600
|
const write = await askTableSelection(prompter, "WRITES", "");
|
|
536
601
|
const related = new Map();
|
|
602
|
+
const resolveParent = dependencies.resolveParentTable ?? parentTableReader();
|
|
537
603
|
for (const table of new Set([...read, ...write])) {
|
|
538
604
|
if (table === TABLE_ALLOWLIST_WILDCARD)
|
|
539
605
|
continue;
|
|
540
|
-
const parent = await lookupParentTable(config, table
|
|
606
|
+
const parent = await lookupParentTable(resolveParent, config, table);
|
|
541
607
|
if (parent === undefined || parent === table)
|
|
542
608
|
continue;
|
|
543
609
|
prompter.note(`\n ${table} extends ${parent}.`);
|
|
@@ -586,7 +652,9 @@ async function askTableSelection(prompter, operation, fallback) {
|
|
|
586
652
|
prompter.note(`\n "*" grants every table for ${operation.toLowerCase()}. ServiceNow's own\n` +
|
|
587
653
|
" per-user ACLs are then the only remaining boundary, so the integration\n" +
|
|
588
654
|
" account's roles become the whole control. It also skips the per-tool\n" +
|
|
589
|
-
" binding and the related-table closure check
|
|
655
|
+
" binding and the related-table closure check. It does not cover\n" +
|
|
656
|
+
` ${table_policy_js_1.NAMED_ONLY_TABLES.join(", ")};\n` +
|
|
657
|
+
" name them to allow them.\n");
|
|
590
658
|
return Object.freeze(["*"]);
|
|
591
659
|
}
|
|
592
660
|
return askCustomTableList(prompter, operation);
|
|
@@ -613,39 +681,39 @@ async function askCustomTableList(prompter, operation) {
|
|
|
613
681
|
* ServiceNow's inheritance graph. Best effort: a failure here is not a setup
|
|
614
682
|
* failure, because the self-only closure the wizard writes is valid on its own.
|
|
615
683
|
*/
|
|
616
|
-
async function lookupParentTable(config, table
|
|
617
|
-
const resolve = dependencies.resolveParentTable ?? defaultParentTable;
|
|
684
|
+
async function lookupParentTable(resolve, config, table) {
|
|
618
685
|
try {
|
|
619
|
-
|
|
686
|
+
const parent = await resolve(config, table);
|
|
687
|
+
// Only a table name is ever offered, whichever resolver produced it: the
|
|
688
|
+
// answer goes into the allowlist and the target's closure as written.
|
|
689
|
+
return typeof parent === "string" && TABLE_NAME.test(parent) ? parent : undefined;
|
|
620
690
|
}
|
|
621
691
|
catch {
|
|
622
692
|
return undefined;
|
|
623
693
|
}
|
|
624
694
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
const normalized = parent.trim().toLowerCase();
|
|
648
|
-
return TABLE_NAME.test(normalized) ? normalized : undefined;
|
|
695
|
+
/** The table itself and its immediate parent: the wizard offers only that one. */
|
|
696
|
+
const PARENT_LOOKUP_DEPTH = 2;
|
|
697
|
+
/**
|
|
698
|
+
* The default resolver: the parent's name from sys_db_object, through the same
|
|
699
|
+
* walk sn_schema uses. super_class's display value is the parent's label, not
|
|
700
|
+
* its name, so following it offered "server" for cmdb_ci_linux_server and
|
|
701
|
+
* nothing at all for a label with a space, such as "Configuration Item".
|
|
702
|
+
*
|
|
703
|
+
* It keeps one client per configuration, so an OAuth profile fetches one token
|
|
704
|
+
* for the run's lookups rather than one per table.
|
|
705
|
+
*/
|
|
706
|
+
function parentTableReader() {
|
|
707
|
+
let cached;
|
|
708
|
+
return async (config, table) => {
|
|
709
|
+
if (!TABLE_NAME.test(table))
|
|
710
|
+
return undefined;
|
|
711
|
+
if (cached?.config !== config) {
|
|
712
|
+
cached = { config, client: new client_js_1.ServiceNowClient(config, { maxRetries: 0 }) };
|
|
713
|
+
}
|
|
714
|
+
const [, parent] = await (0, table_hierarchy_js_1.resolveTableHierarchy)(cached.client, table, PARENT_LOOKUP_DEPTH, false);
|
|
715
|
+
return parent;
|
|
716
|
+
};
|
|
649
717
|
}
|
|
650
718
|
async function registerClientsInteractively(prompter, options, clis, context) {
|
|
651
719
|
if (clis.length === 0) {
|
|
@@ -691,6 +759,7 @@ function renderClientCliNote(clis) {
|
|
|
691
759
|
}
|
|
692
760
|
function renderWizardSummary(profile, tableAccess, registered, home, checks) {
|
|
693
761
|
const failed = checks.filter((check) => !check.ok).length;
|
|
762
|
+
const riskWarning = (0, risky_grants_js_1.riskyGrantWarning)(tableAccess.writeTables ?? [], profile);
|
|
694
763
|
const lines = [
|
|
695
764
|
"",
|
|
696
765
|
"Setup complete.",
|
|
@@ -698,6 +767,7 @@ function renderWizardSummary(profile, tableAccess, registered, home, checks) {
|
|
|
698
767
|
`Profile ${profile}`,
|
|
699
768
|
`Reads ${(tableAccess.readTables ?? []).join(", ") || "(none)"}`,
|
|
700
769
|
`Writes ${(tableAccess.writeTables ?? []).join(", ") || "(none)"}`,
|
|
770
|
+
...(riskWarning === undefined ? [] : ["", riskWarning.trimEnd(), ""]),
|
|
701
771
|
`Transport stdio (each client spawns its own ${SERVER_COMMAND})`,
|
|
702
772
|
`Clients ${registered.length > 0 ? registered.join(", ") : "(none registered)"}`,
|
|
703
773
|
"",
|
|
@@ -1085,27 +1155,49 @@ function runGrant(options, home, dependencies, out) {
|
|
|
1085
1155
|
? Object.freeze({})
|
|
1086
1156
|
: (current.tableAccess ?? Object.freeze({}));
|
|
1087
1157
|
const ordinary = buildTableAccess(existing, options);
|
|
1088
|
-
const
|
|
1158
|
+
const withAtf = options.atf
|
|
1089
1159
|
? buildTableAccess(ordinary, { ...options, read: ["sys_atf_test_suite", "sys_atf_test", "sys_atf_step", "sys_atf_step_config", "var_dictionary", "sys_variable_value", "sys_element_mapping"], write: ATF_AUTHOR_TABLES, tools: ["sn_atf_author"] })
|
|
1090
1160
|
: ordinary;
|
|
1161
|
+
const tableAccess = options.flows
|
|
1162
|
+
? buildTableAccess(withAtf, { ...options, read: flow_view_contracts_js_1.FLOW_VIEW_TABLES, write: [], tools: ["sn_flow_view"] })
|
|
1163
|
+
: withAtf;
|
|
1164
|
+
// What this grant adds to the write allowlist, including related tables
|
|
1165
|
+
// that buildTableAccess pulls in. A re-run that adds nothing new still
|
|
1166
|
+
// names the tables it was asked for.
|
|
1167
|
+
const alreadyWritable = new Set(existing.writeTables ?? []);
|
|
1168
|
+
const grantedWrites = [
|
|
1169
|
+
...new Set([
|
|
1170
|
+
...options.write,
|
|
1171
|
+
...(tableAccess.writeTables ?? []).filter((table) => !alreadyWritable.has(table)),
|
|
1172
|
+
]),
|
|
1173
|
+
];
|
|
1174
|
+
const riskWarning = (0, risky_grants_js_1.riskyGrantWarning)(grantedWrites, options.profile);
|
|
1175
|
+
const warnings = riskWarning === undefined ? {} : { warnings: [riskWarning.trim()] };
|
|
1091
1176
|
if (options.dryRun) {
|
|
1092
1177
|
out(options.json
|
|
1093
|
-
? `${JSON.stringify({ status: "dry-run", profile: options.profile, tableAccess }, null, 2)}\n`
|
|
1094
|
-
: `Would write to profile ${options.profile}:\n${indent(JSON.stringify(tableAccess, null, 2))}\n`
|
|
1178
|
+
? `${JSON.stringify({ status: "dry-run", profile: options.profile, tableAccess, ...warnings }, null, 2)}\n`
|
|
1179
|
+
: `Would write to profile ${options.profile}:\n${indent(JSON.stringify(tableAccess, null, 2))}\n` +
|
|
1180
|
+
(riskWarning === undefined ? "" : `\n${riskWarning}`));
|
|
1095
1181
|
return;
|
|
1096
1182
|
}
|
|
1097
1183
|
manager.addProfile(options.profile, { ...current, tableAccess });
|
|
1098
1184
|
if (options.json) {
|
|
1099
|
-
out(`${JSON.stringify({ status: "granted", profile: options.profile, tableAccess }, null, 2)}\n`);
|
|
1185
|
+
out(`${JSON.stringify({ status: "granted", profile: options.profile, tableAccess, ...warnings }, null, 2)}\n`);
|
|
1100
1186
|
return;
|
|
1101
1187
|
}
|
|
1102
1188
|
out(`Granted table access on profile ${options.profile}.\n\n` +
|
|
1103
1189
|
`${indent(JSON.stringify(tableAccess, null, 2))}\n\n` +
|
|
1104
|
-
|
|
1105
|
-
`
|
|
1106
|
-
|
|
1107
|
-
`
|
|
1108
|
-
`
|
|
1190
|
+
(riskWarning === undefined ? "" : `${riskWarning}\n`) +
|
|
1191
|
+
`relatedTables is a declaration the loader checks: each related table must\n` +
|
|
1192
|
+
`be allowed for every operation its target has, so --related adds it to the\n` +
|
|
1193
|
+
`allowlist of each of those operations, including one a later grant adds.\n` +
|
|
1194
|
+
`On its own that makes the table addressable by no tool, because it has no\n` +
|
|
1195
|
+
`target, unless such an allowlist is "*". If the table has, or later gets,\n` +
|
|
1196
|
+
`a target of its own, that target's tools can then use those operations on\n` +
|
|
1197
|
+
`it.\n` +
|
|
1198
|
+
`Inherited fields are read through the table itself, so a self-only list is\n` +
|
|
1199
|
+
`enough. Pass --related "<table>=<t1>,<t2>" to declare a parent or a view's\n` +
|
|
1200
|
+
`backing table.\n` +
|
|
1109
1201
|
`Restart the MCP client for the change to take effect: it reads the\n` +
|
|
1110
1202
|
`profile when it launches the server.\n`);
|
|
1111
1203
|
}
|
|
@@ -1116,11 +1208,10 @@ function runGrant(options, home, dependencies, out) {
|
|
|
1116
1208
|
function buildTableAccess(existing, options) {
|
|
1117
1209
|
const readTables = new Set([...(existing.readTables ?? []), ...options.read]);
|
|
1118
1210
|
const writeTables = new Set([...(existing.writeTables ?? []), ...options.write]);
|
|
1119
|
-
const targets = mergeTargets(existing.targets, options
|
|
1120
|
-
//
|
|
1121
|
-
//
|
|
1122
|
-
//
|
|
1123
|
-
// through the target but never directly addressable by a caller.
|
|
1211
|
+
const targets = mergeTargets(existing.targets, options);
|
|
1212
|
+
// The policy loader requires every table a target declares in relatedTables
|
|
1213
|
+
// to carry the target's operation permission. They stay out of `targets`,
|
|
1214
|
+
// so they are never directly addressable by a caller.
|
|
1124
1215
|
for (const target of targets) {
|
|
1125
1216
|
if (readTables.has(target.table)) {
|
|
1126
1217
|
for (const related of target.relatedTables)
|
|
@@ -1144,7 +1235,7 @@ function buildTableAccess(existing, options) {
|
|
|
1144
1235
|
function sorted(values) {
|
|
1145
1236
|
return Object.freeze([...values].sort());
|
|
1146
1237
|
}
|
|
1147
|
-
function mergeTargets(existing, options
|
|
1238
|
+
function mergeTargets(existing, options) {
|
|
1148
1239
|
const byTable = new Map();
|
|
1149
1240
|
for (const target of existing ?? [])
|
|
1150
1241
|
byTable.set(target.table, target);
|
|
@@ -1157,13 +1248,21 @@ function mergeTargets(existing, options, readTables, writeTables) {
|
|
|
1157
1248
|
tools.add(tool);
|
|
1158
1249
|
}
|
|
1159
1250
|
else {
|
|
1160
|
-
|
|
1251
|
+
// Defaults follow what this invocation granted, not the merged
|
|
1252
|
+
// allowlists. Those also hold the profile's earlier grants and the
|
|
1253
|
+
// related tables of other targets, so gating on them would let a
|
|
1254
|
+
// read-only grant add write tools to a target.
|
|
1255
|
+
if (options.read.includes(table)) {
|
|
1161
1256
|
for (const tool of DEFAULT_READ_TOOLS)
|
|
1162
1257
|
tools.add(tool);
|
|
1163
1258
|
}
|
|
1164
|
-
if (
|
|
1259
|
+
if (options.write.includes(table)) {
|
|
1165
1260
|
for (const tool of DEFAULT_WRITE_TOOLS)
|
|
1166
1261
|
tools.add(tool);
|
|
1262
|
+
if (table === "incident") {
|
|
1263
|
+
for (const tool of INCIDENT_JOURNAL_TOOLS)
|
|
1264
|
+
tools.add(tool);
|
|
1265
|
+
}
|
|
1167
1266
|
}
|
|
1168
1267
|
}
|
|
1169
1268
|
const related = new Set([
|
|
@@ -1181,9 +1280,59 @@ function mergeTargets(existing, options, readTables, writeTables) {
|
|
|
1181
1280
|
}
|
|
1182
1281
|
return Object.freeze([...byTable.values()]);
|
|
1183
1282
|
}
|
|
1283
|
+
/**
|
|
1284
|
+
* `policy show`: the profile's effective policy as one table. It is built from
|
|
1285
|
+
* the same loaders the server uses (profile snapshot, table-access policy,
|
|
1286
|
+
* field-policy resolver), and reads no credential: the profile is loaded
|
|
1287
|
+
* without resolving any secret.
|
|
1288
|
+
*/
|
|
1289
|
+
function runPolicy(options, home, env, dependencies, out) {
|
|
1290
|
+
const manager = dependencies.profileManager ?? profileManagerFor(home);
|
|
1291
|
+
const profile = manager.getProfile(options.profile);
|
|
1292
|
+
// Raw encoded-query reads are configured in the server's environment, which
|
|
1293
|
+
// this shell may not share. Say so rather than guess.
|
|
1294
|
+
let encodedQueryAccess = (0, encoded_query_policy_js_1.createEncodedQueryAccessPolicy)();
|
|
1295
|
+
let encodedNote = "Raw encoded read queries and ATF grants shown are those of this shell's environment; " +
|
|
1296
|
+
"the server reads its own.";
|
|
1297
|
+
try {
|
|
1298
|
+
encodedQueryAccess = (0, encoded_query_policy_js_1.encodedQueryAccessPolicyFromEnvironment)(env);
|
|
1299
|
+
}
|
|
1300
|
+
catch {
|
|
1301
|
+
encodedNote = "The encoded-query read policy in this shell's environment is invalid; shown as denied.";
|
|
1302
|
+
}
|
|
1303
|
+
const card = (0, policy_card_js_1.buildPolicyCard)({
|
|
1304
|
+
profile: options.profile,
|
|
1305
|
+
instance: profile.instance,
|
|
1306
|
+
authType: profile.authType ?? "basic",
|
|
1307
|
+
...(profile.grantType === undefined || profile.authType !== "oauth"
|
|
1308
|
+
? {}
|
|
1309
|
+
: { grantType: profile.grantType }),
|
|
1310
|
+
tableAccess: (0, table_policy_js_1.createTableAccessPolicy)(profile.tableAccess ?? Object.freeze({})),
|
|
1311
|
+
fieldPolicy: {
|
|
1312
|
+
...(profile.fieldPolicy === undefined ? {} : { fieldPolicy: profile.fieldPolicy }),
|
|
1313
|
+
...(profile.readableTableFields === undefined
|
|
1314
|
+
? {}
|
|
1315
|
+
: { readableTableFields: profile.readableTableFields }),
|
|
1316
|
+
...(profile.writableTableFields === undefined
|
|
1317
|
+
? {}
|
|
1318
|
+
: { writableTableFields: profile.writableTableFields }),
|
|
1319
|
+
},
|
|
1320
|
+
encodedQueryAccess,
|
|
1321
|
+
atf: manager.getAtfConfig(options.profile),
|
|
1322
|
+
fieldTypes: { dictionary: (0, hidden_values_js_1.dictionaryNotRequired)(profile.fieldTypes) ? "not_required" : "required" },
|
|
1323
|
+
});
|
|
1324
|
+
out(options.json
|
|
1325
|
+
? `${JSON.stringify({ policy: card, note: encodedNote }, null, 2)}\n`
|
|
1326
|
+
: `${(0, policy_card_js_1.renderPolicyCard)(card)}\n${encodedNote}\n`);
|
|
1327
|
+
}
|
|
1184
1328
|
async function runDoctor(options, home, env, dependencies, out) {
|
|
1185
1329
|
const paths = resolvePaths(home);
|
|
1186
|
-
const checks =
|
|
1330
|
+
const checks = options.live
|
|
1331
|
+
? [
|
|
1332
|
+
...runInstallChecks(paths, home, env, dependencies, options.profile),
|
|
1333
|
+
...(await runLiveChecks(paths, home, dependencies, options.profile)),
|
|
1334
|
+
]
|
|
1335
|
+
: runInstallChecks(paths, home, env, dependencies, options.profile);
|
|
1187
1336
|
const failed = checks.filter((check) => !check.ok);
|
|
1188
1337
|
if (options.json) {
|
|
1189
1338
|
out(`${JSON.stringify({ status: failed.length === 0 ? "ok" : "problems", checks }, null, 2)}\n`);
|
|
@@ -1194,6 +1343,62 @@ async function runDoctor(options, home, env, dependencies, out) {
|
|
|
1194
1343
|
if (failed.length > 0)
|
|
1195
1344
|
process.exitCode = 1;
|
|
1196
1345
|
}
|
|
1346
|
+
/**
|
|
1347
|
+
* `doctor --live`: one bounded authenticated read per profile, through the
|
|
1348
|
+
* same probe the wizard uses, so a hibernating instance is reported as such
|
|
1349
|
+
* with the wake hint instead of a generic failure. Opt-in, because plain
|
|
1350
|
+
* `doctor` never touches the network.
|
|
1351
|
+
*/
|
|
1352
|
+
/** Per-profile bound for `doctor --live`; shorter than the client default. */
|
|
1353
|
+
const DOCTOR_LIVE_TIMEOUT_MS = 10_000;
|
|
1354
|
+
async function runLiveChecks(paths, home, dependencies, only) {
|
|
1355
|
+
if (!(0, node_fs_1.existsSync)(paths.profileConfig) && dependencies.profileManager === undefined)
|
|
1356
|
+
return [];
|
|
1357
|
+
const verify = dependencies.verifyCredential ?? verifyCredentialAgainstInstance;
|
|
1358
|
+
const checks = [];
|
|
1359
|
+
try {
|
|
1360
|
+
const manager = dependencies.profileManager ?? profileManagerFor(home);
|
|
1361
|
+
const names = manager
|
|
1362
|
+
.listProfiles()
|
|
1363
|
+
.map((entry) => entry.name)
|
|
1364
|
+
.filter((name) => only === undefined || name === only);
|
|
1365
|
+
// Concurrent, with doctor's own short timeout, so unresponsive profiles
|
|
1366
|
+
// cost one timeout in total. Promise.all keeps the profile-name order.
|
|
1367
|
+
const results = await Promise.all([...names].sort().map(async (name) => {
|
|
1368
|
+
let config;
|
|
1369
|
+
try {
|
|
1370
|
+
config = { ...manager.getConfig(name), timeoutMs: DOCTOR_LIVE_TIMEOUT_MS };
|
|
1371
|
+
}
|
|
1372
|
+
catch {
|
|
1373
|
+
return undefined; // The credential check has already reported why.
|
|
1374
|
+
}
|
|
1375
|
+
try {
|
|
1376
|
+
const result = await verify(config);
|
|
1377
|
+
return {
|
|
1378
|
+
name: `profile ${name}: live instance`,
|
|
1379
|
+
ok: result.ok,
|
|
1380
|
+
detail: result.detail,
|
|
1381
|
+
...(result.remedy === undefined ? {} : { remedy: result.remedy }),
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
catch {
|
|
1385
|
+
return {
|
|
1386
|
+
name: `profile ${name}: live instance`,
|
|
1387
|
+
ok: false,
|
|
1388
|
+
detail: "could not be probed",
|
|
1389
|
+
remedy: "Check the profile's instance URL and credential settings.",
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
}));
|
|
1393
|
+
for (const check of results)
|
|
1394
|
+
if (check !== undefined)
|
|
1395
|
+
checks.push(check);
|
|
1396
|
+
}
|
|
1397
|
+
catch {
|
|
1398
|
+
// Profile loading failures are reported by the static checks.
|
|
1399
|
+
}
|
|
1400
|
+
return checks;
|
|
1401
|
+
}
|
|
1197
1402
|
/**
|
|
1198
1403
|
* Prove the command registered clients spawn can actually be found.
|
|
1199
1404
|
*
|
|
@@ -1496,7 +1701,10 @@ function normalizeArgv(argv) {
|
|
|
1496
1701
|
}
|
|
1497
1702
|
function splitSubcommand(argv) {
|
|
1498
1703
|
const first = argv[0];
|
|
1499
|
-
if (first === "client" ||
|
|
1704
|
+
if (first === "client" ||
|
|
1705
|
+
first === "grant" ||
|
|
1706
|
+
first === "doctor" ||
|
|
1707
|
+
first === "policy") {
|
|
1500
1708
|
return { subcommand: first, args: Object.freeze(argv.slice(1)) };
|
|
1501
1709
|
}
|
|
1502
1710
|
if (first === "init")
|
|
@@ -1582,7 +1790,7 @@ function parseClientArguments(args) {
|
|
|
1582
1790
|
function parseGrantArguments(args) {
|
|
1583
1791
|
const usage = renderGrantHelp();
|
|
1584
1792
|
const parsed = parseFlags(args, {
|
|
1585
|
-
boolean: new Set(["--replace", "--dry-run", "--json", "--atf"]),
|
|
1793
|
+
boolean: new Set(["--replace", "--dry-run", "--json", "--atf", "--flows"]),
|
|
1586
1794
|
value: new Set(["--profile", "--read", "--write", "--tools", "--related"]),
|
|
1587
1795
|
repeatable: new Set(["--related"]),
|
|
1588
1796
|
}, usage);
|
|
@@ -1591,8 +1799,8 @@ function parseGrantArguments(args) {
|
|
|
1591
1799
|
throw new Error(`--profile is required.\n\n${usage}`);
|
|
1592
1800
|
const read = parseTableList(parsed.values.get("--read"), "--read");
|
|
1593
1801
|
const write = parseTableList(parsed.values.get("--write"), "--write");
|
|
1594
|
-
if (read.length === 0 && write.length === 0 && !parsed.flags.has("--atf")) {
|
|
1595
|
-
throw new Error(`Give at least one of --read, --write, or --
|
|
1802
|
+
if (read.length === 0 && write.length === 0 && !parsed.flags.has("--atf") && !parsed.flags.has("--flows")) {
|
|
1803
|
+
throw new Error(`Give at least one of --read, --write, --atf or --flows.\n\n${usage}`);
|
|
1596
1804
|
}
|
|
1597
1805
|
return Object.freeze({
|
|
1598
1806
|
profile,
|
|
@@ -1602,21 +1810,36 @@ function parseGrantArguments(args) {
|
|
|
1602
1810
|
? { tools: parseToolList(parsed.values.get("--tools")) }
|
|
1603
1811
|
: {}),
|
|
1604
1812
|
atf: parsed.flags.has("--atf"),
|
|
1813
|
+
flows: parsed.flags.has("--flows"),
|
|
1605
1814
|
related: parseRelated(parsed.repeated.get("--related") ?? []),
|
|
1606
1815
|
replace: parsed.flags.has("--replace"),
|
|
1607
1816
|
dryRun: parsed.flags.has("--dry-run"),
|
|
1608
1817
|
json: parsed.flags.has("--json"),
|
|
1609
1818
|
});
|
|
1610
1819
|
}
|
|
1820
|
+
function parsePolicyArguments(args) {
|
|
1821
|
+
const usage = renderPolicyHelp();
|
|
1822
|
+
if (args[0] !== "show") {
|
|
1823
|
+
if (args[0] === "--help" || args[0] === "-h")
|
|
1824
|
+
throw new SetupHelp(usage);
|
|
1825
|
+
throw new Error(`Usage: servicenow-mcp-setup policy show --profile NAME\n\n${usage}`);
|
|
1826
|
+
}
|
|
1827
|
+
const parsed = parseFlags(args.slice(1), { boolean: new Set(["--json"]), value: new Set(["--profile"]) }, usage);
|
|
1828
|
+
const profile = parsed.values.get("--profile");
|
|
1829
|
+
if (!profile)
|
|
1830
|
+
throw new Error(`--profile is required.\n\n${usage}`);
|
|
1831
|
+
return Object.freeze({ profile, json: parsed.flags.has("--json") });
|
|
1832
|
+
}
|
|
1611
1833
|
function parseDoctorArguments(args) {
|
|
1612
1834
|
const usage = renderDoctorHelp();
|
|
1613
1835
|
const parsed = parseFlags(args, {
|
|
1614
|
-
boolean: new Set(["--json"]),
|
|
1836
|
+
boolean: new Set(["--json", "--live"]),
|
|
1615
1837
|
value: new Set(["--profile"]),
|
|
1616
1838
|
}, usage);
|
|
1617
1839
|
return Object.freeze({
|
|
1618
1840
|
...(parsed.values.has("--profile") ? { profile: parsed.values.get("--profile") } : {}),
|
|
1619
1841
|
json: parsed.flags.has("--json"),
|
|
1842
|
+
live: parsed.flags.has("--live"),
|
|
1620
1843
|
});
|
|
1621
1844
|
}
|
|
1622
1845
|
function parseClients(value) {
|
|
@@ -1934,6 +2157,7 @@ function renderSetupHelp() {
|
|
|
1934
2157
|
" instance, table access, and client registration.",
|
|
1935
2158
|
" client Print copy-pasteable configuration for one or more MCP clients.",
|
|
1936
2159
|
" grant Add least-privilege table access rules to an existing profile.",
|
|
2160
|
+
" policy Show a profile's effective policy as one table (policy show).",
|
|
1937
2161
|
" doctor Diagnose a local install and print the remedy for each failure.",
|
|
1938
2162
|
"",
|
|
1939
2163
|
"Run any command with --help for its options.",
|
|
@@ -1990,11 +2214,15 @@ function renderGrantHelp() {
|
|
|
1990
2214
|
" --write TABLES Comma-separated tables to allow for writes",
|
|
1991
2215
|
" --atf Grant the ATF authoring tables to sn_atf_author only",
|
|
1992
2216
|
" Does not enable execution or script-step authoring",
|
|
2217
|
+
" --flows Grant read on the 15 sn_flow_view tables to sn_flow_view only",
|
|
2218
|
+
" (see docs/FLOW-VIEW.md)",
|
|
1993
2219
|
` --tools LIST Tools permitted on these targets`,
|
|
1994
2220
|
` (default read: ${DEFAULT_READ_TOOLS.join(",")};`,
|
|
1995
|
-
` default write adds: ${DEFAULT_WRITE_TOOLS.join(",")}
|
|
1996
|
-
|
|
1997
|
-
"
|
|
2221
|
+
` default write adds: ${DEFAULT_WRITE_TOOLS.join(",")};`,
|
|
2222
|
+
` default write on incident also adds:`,
|
|
2223
|
+
` ${INCIDENT_JOURNAL_TOOLS.join(",")})`,
|
|
2224
|
+
" --related TABLE=LIST Parent or backing tables to declare for a target;",
|
|
2225
|
+
" repeatable. Optional for a table that extends another",
|
|
1998
2226
|
" --replace Discard existing rules instead of adding to them",
|
|
1999
2227
|
" --dry-run Print the resulting rules without writing them",
|
|
2000
2228
|
" --json Machine-readable output",
|
|
@@ -2004,17 +2232,35 @@ function renderGrantHelp() {
|
|
|
2004
2232
|
"docs/PRODUCTION-SECURITY.md.",
|
|
2005
2233
|
].join("\n");
|
|
2006
2234
|
}
|
|
2235
|
+
function renderPolicyHelp() {
|
|
2236
|
+
return [
|
|
2237
|
+
"Usage: servicenow-mcp-setup policy show --profile NAME [--json]",
|
|
2238
|
+
"",
|
|
2239
|
+
"Prints what the profile may do, from the same policy the server enforces:",
|
|
2240
|
+
"tables readable and writable with their tools, readable and writable fields,",
|
|
2241
|
+
"the explicit-listing fields, auth type, raw encoded-query reads, ATF grants,",
|
|
2242
|
+
"and the sn_batch limits. Warns when write access reaches privilege-sensitive",
|
|
2243
|
+
"tables (roles, approvals, scripts, users). Never prints a secret, a key, or a credential reference, and never",
|
|
2244
|
+
"touches the network.",
|
|
2245
|
+
"",
|
|
2246
|
+
"Options:",
|
|
2247
|
+
" --profile NAME Profile to show (required)",
|
|
2248
|
+
" --json Machine-readable output",
|
|
2249
|
+
].join("\n");
|
|
2250
|
+
}
|
|
2007
2251
|
function renderDoctorHelp() {
|
|
2008
2252
|
return [
|
|
2009
|
-
"Usage: servicenow-mcp-setup doctor [--profile NAME]",
|
|
2253
|
+
"Usage: servicenow-mcp-setup doctor [--profile NAME] [--live]",
|
|
2010
2254
|
"",
|
|
2011
2255
|
"Checks Node version, that the servicenow-mcp command clients spawn resolves",
|
|
2012
2256
|
"on PATH, config file ownership and modes, profile completeness, credential",
|
|
2013
2257
|
"resolution, and table access. Exits non-zero when any check fails. Never",
|
|
2014
|
-
"prints a secret value
|
|
2258
|
+
"prints a secret value. It touches the network only with --live.",
|
|
2015
2259
|
"",
|
|
2016
2260
|
"Options:",
|
|
2017
2261
|
" --profile NAME Check only this profile (default: every configured profile)",
|
|
2262
|
+
" --live Also make one authenticated read per profile; reports a",
|
|
2263
|
+
" hibernating instance with how to wake it",
|
|
2018
2264
|
" --json Machine-readable output",
|
|
2019
2265
|
].join("\n");
|
|
2020
2266
|
}
|