@onlyflows/servicenow-mcp 2.2.0-dev.5 → 2.2.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/.env.example +6 -3
- package/CHANGELOG.md +312 -0
- package/README.md +504 -101
- package/dist/atf-form.d.ts +3 -15
- package/dist/atf-form.d.ts.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/command-resolution.d.ts +53 -0
- package/dist/command-resolution.d.ts.map +1 -0
- package/dist/command-resolution.js +154 -0
- package/dist/command-resolution.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 +10 -1
- package/dist/encoded-query-policy.js.map +1 -1
- package/dist/field-policy.d.ts +82 -3
- package/dist/field-policy.d.ts.map +1 -1
- package/dist/field-policy.js +609 -80
- package/dist/field-policy.js.map +1 -1
- 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-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/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 +46 -21
- package/dist/metadata-cache.d.ts.map +1 -1
- package/dist/metadata-cache.js +228 -195
- package/dist/metadata-cache.js.map +1 -1
- package/dist/policy-card.d.ts +131 -0
- package/dist/policy-card.d.ts.map +1 -0
- package/dist/policy-card.js +409 -0
- package/dist/policy-card.js.map +1 -0
- package/dist/profile-admin.d.ts.map +1 -1
- package/dist/profile-admin.js +3 -0
- package/dist/profile-admin.js.map +1 -1
- package/dist/profile-manager.d.ts +17 -3
- package/dist/profile-manager.d.ts.map +1 -1
- package/dist/profile-manager.js +98 -6
- 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 +74 -0
- 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 +8 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +492 -111
- 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 +132 -16
- package/dist/structured-query.js.map +1 -1
- package/dist/table-policy.d.ts +10 -4
- package/dist/table-policy.d.ts.map +1 -1
- package/dist/table-policy.js +1 -1
- package/dist/table-policy.js.map +1 -1
- package/dist/tool-error.d.ts +18 -0
- package/dist/tool-error.d.ts.map +1 -1
- package/dist/tool-error.js +69 -0
- package/dist/tool-error.js.map +1 -1
- package/dist/tool-table-access.d.ts.map +1 -1
- package/dist/tool-table-access.js +32 -2
- 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 +2 -3
- 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 +3 -38
- package/dist/tools/all-fields-cap.js.map +1 -1
- package/dist/tools/atf-author-module.d.ts +28 -7
- package/dist/tools/atf-author-module.d.ts.map +1 -1
- package/dist/tools/atf-author-module.js +4 -2
- 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 +3 -7
- package/dist/tools/atf-step-catalog.d.ts.map +1 -1
- package/dist/tools/atf-step-catalog.js +12 -5
- 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 +544 -96
- 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 +461 -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 +43 -6
- 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 +19 -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 +2 -2
- 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 +19 -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/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 +154 -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 +21 -6
- package/scripts/release-validate.mjs +56 -0
- package/server.json +22 -0
- package/tools/inspector/package-lock.json +163 -201
package/README.md
CHANGED
|
@@ -1,17 +1,92 @@
|
|
|
1
1
|
# @onlyflows/servicenow-mcp
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<!--  -->
|
|
3
|
+
A governed ServiceNow MCP server: it lets an AI client read and change records on your instances, within limits you set per connection.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Built by [OnlyFlows](https://onlyflows.tech) · Published by [@onlyflowstech](https://github.com/onlyflowstech)
|
|
5
|
+
<!-- DEMO GIF PLACEHOLDER: add a short screen recording here (asking a question, then a denied write and a dry-run batch). Not recorded yet. -->
|
|
9
6
|
|
|
10
7
|
[](https://www.npmjs.com/package/@onlyflows/servicenow-mcp)
|
|
11
8
|
[](https://opensource.org/licenses/MIT)
|
|
12
9
|
|
|
13
|
-
|
|
10
|
+
Built by [OnlyFlows](https://onlyflows.tech) · Published by [@onlyflowstech](https://github.com/onlyflowstech)
|
|
11
|
+
|
|
12
|
+
## Governed and safe for production
|
|
13
|
+
|
|
14
|
+
The server exposes 24 tools over stdio. Every call runs inside controls that
|
|
15
|
+
you configure and that no tool of this server can change:
|
|
16
|
+
|
|
17
|
+
- **Per-profile table and field policy.** Each profile (a named ServiceNow
|
|
18
|
+
connection) has its own read and write table allowlists. Access is
|
|
19
|
+
deny-by-default: a profile with no rules denies every ServiceNow call. Field
|
|
20
|
+
policy decides which fields can be read or written; sensitive field names
|
|
21
|
+
are refused.
|
|
22
|
+
- **Confirmation flag on destructive tools.** `sn_delete` and `sn_batch`
|
|
23
|
+
change nothing unless the call carries `confirm: true`. The model sets that
|
|
24
|
+
flag itself, so it is a guard against accidents, not an approval. A person
|
|
25
|
+
approves through the client's own tool-approval prompt, and many clients let
|
|
26
|
+
you "always allow" a tool. `sn_create` and `sn_update` take no confirm flag;
|
|
27
|
+
keep write grants narrow.
|
|
28
|
+
- **Safe batching.** `sn_batch` takes a structured filter (no raw encoded
|
|
29
|
+
queries), runs as a dry run by default, caps a run at 10,000 records, and
|
|
30
|
+
never re-sends a batch.
|
|
31
|
+
- **Activity events.** Each completed tool call writes one JSON line to
|
|
32
|
+
stderr with the tool, profile, instance and outcome, plus hashed owner and
|
|
33
|
+
client labels. It records no table, record or fields. Delivery is
|
|
34
|
+
best-effort through stderr, and events are dropped above 256 pending lines.
|
|
35
|
+
Use ServiceNow's own audit history for record changes.
|
|
36
|
+
- **Explicit profile on every call.** There is no default or "active"
|
|
37
|
+
instance. Each call names its profile, so nothing reaches an instance the
|
|
38
|
+
call didn't name. Keep write grants on production profiles narrow.
|
|
39
|
+
- **Credentials stay out of clients.** Secrets are entered at a hidden prompt,
|
|
40
|
+
verified against the instance before anything is saved, and stored
|
|
41
|
+
encrypted in an owner-only `~/.servicenow-mcp` directory.
|
|
42
|
+
|
|
43
|
+
> **Limits of these controls.** They hold against the model's tool calls. A
|
|
44
|
+
> client that gives the model a shell or file access (Claude Code and Codex
|
|
45
|
+
> can) could run `servicenow-mcp-setup grant` or read
|
|
46
|
+
> `~/.servicenow-mcp/server.env`. The encryption key sits in the same
|
|
47
|
+
> owner-only folder as the encrypted profiles, so it protects against other
|
|
48
|
+
> users and stray copies of the files, not against your own account. Run
|
|
49
|
+
> production profiles from a client or account without shell access where you
|
|
50
|
+
> can.
|
|
51
|
+
|
|
52
|
+
Details: [Table access policy](#table-access-policy),
|
|
53
|
+
[Safety Features](#safety-features) and [docs/PRODUCTION-SECURITY.md](docs/PRODUCTION-SECURITY.md).
|
|
54
|
+
|
|
55
|
+
## Works with
|
|
56
|
+
|
|
57
|
+
Any MCP client that can launch a stdio server. Setup registers **Claude Code**
|
|
58
|
+
and **Codex** automatically; **Claude Desktop**, **Cursor**, **VS Code** and
|
|
59
|
+
**Windsurf** are configured with `servicenow-mcp-setup client --client <name>`
|
|
60
|
+
(see [Connecting a client](#connecting-a-client)). Requires Node.js 20 or newer.
|
|
61
|
+
|
|
62
|
+
## Quick start
|
|
63
|
+
|
|
64
|
+
1. **Install:** `npm install -g @onlyflows/servicenow-mcp`
|
|
65
|
+
2. **Set up a connection:** `servicenow-mcp-setup`. It asks for your instance
|
|
66
|
+
and credential, checks them against the instance, asks which tables to
|
|
67
|
+
allow, and registers Claude Code and Codex if their CLIs are installed.
|
|
68
|
+
Choose **OAuth** when the wizard asks for the authentication type; Basic
|
|
69
|
+
is the wizard's default but is [deprecated by ServiceNow](#basic-default-deprecated-by-servicenow).
|
|
70
|
+
3. **Open your client and ask.** There is no server to start; the client
|
|
71
|
+
launches `servicenow-mcp` itself.
|
|
72
|
+
|
|
73
|
+
The default read grant in the wizard is **just `incident`**, and writes default
|
|
74
|
+
to **none**. Grant more later with `servicenow-mcp-setup grant`.
|
|
75
|
+
|
|
76
|
+
## Try asking
|
|
77
|
+
|
|
78
|
+
These work with the default read grant (profile named `dev`):
|
|
79
|
+
|
|
80
|
+
1. "On dev, list the 10 most recent open P1 incidents."
|
|
81
|
+
2. "On dev, how many incidents are there, grouped by priority?"
|
|
82
|
+
3. "On dev, which assignment groups have the most incidents?"
|
|
83
|
+
4. "On dev, which open incidents have no assignee, oldest first?"
|
|
84
|
+
5. "On dev, show incident INC0010001 and summarize where it stands."
|
|
85
|
+
|
|
86
|
+
Your client sends `profile: "dev"` with each call. Asking about other tables
|
|
87
|
+
(for example `change_request`) is denied until you grant them.
|
|
14
88
|
|
|
89
|
+
---
|
|
15
90
|
|
|
16
91
|
## Installation
|
|
17
92
|
|
|
@@ -136,8 +211,14 @@ servicenow-mcp-setup grant --profile dev --read incident,problem --write inciden
|
|
|
136
211
|
| `servicenow-mcp-setup` | Generate local auth material and register supported clients |
|
|
137
212
|
| `servicenow-mcp-setup client --client <name>` | Print copy-pasteable config for a client |
|
|
138
213
|
| `servicenow-mcp-setup grant --profile <name> --read <tables>` | Add table access rules to a profile |
|
|
214
|
+
| `servicenow-mcp-setup policy show --profile <name>` | Print the profile's effective policy as one table (tables, tools, fields, batch limits); never prints a secret |
|
|
139
215
|
| `servicenow-mcp-setup doctor` | Diagnose the install and print remedies |
|
|
140
216
|
|
|
217
|
+
`grant` and the wizard print a warning, and still grant, when write access
|
|
218
|
+
lands on a privilege-sensitive table: role, group, approval, script,
|
|
219
|
+
property, user or authentication tables such as `sys_user_has_role`,
|
|
220
|
+
`sysapproval_approver` or `sys_script`.
|
|
221
|
+
|
|
141
222
|
`--force` regenerates the owner/client identifiers but deliberately preserves
|
|
142
223
|
`SN_PROFILE_ENCRYPTION_KEY`, which decrypts every credential envelope in
|
|
143
224
|
`config.json`. Add `--help` to any command for its full options.
|
|
@@ -324,7 +405,11 @@ The resulting `~/.servicenow-mcp/config.json` looks like this. Note
|
|
|
324
405
|
{
|
|
325
406
|
"table": "incident",
|
|
326
407
|
"kind": "canonical",
|
|
327
|
-
"tools": [
|
|
408
|
+
"tools": [
|
|
409
|
+
"sn_query", "sn_get", "sn_aggregate", "sn_schema",
|
|
410
|
+
"sn_create", "sn_update",
|
|
411
|
+
"sn_incident_add_comment", "sn_incident_add_work_note"
|
|
412
|
+
],
|
|
328
413
|
"closureComplete": true,
|
|
329
414
|
"relatedTables": ["incident"]
|
|
330
415
|
},
|
|
@@ -348,12 +433,29 @@ environment the server is spawned with, or in `~/.servicenow-mcp/server.env`,
|
|
|
348
433
|
which the server falls back to. Do not type either value into a shell command,
|
|
349
434
|
command argument, dotenv file, or command history.
|
|
350
435
|
|
|
351
|
-
Each `targets` entry
|
|
352
|
-
|
|
353
|
-
|
|
436
|
+
Each `targets` entry must set the literal `closureComplete: true`, and its
|
|
437
|
+
`relatedTables` must include the target table itself. `relatedTables` is a
|
|
438
|
+
declaration that the loader checks for consistency: every related table must
|
|
439
|
+
be in the allowlist of each operation the target is in, or the profile is
|
|
440
|
+
rejected. The loader does not derive it from the instance. ServiceNow returns
|
|
441
|
+
inherited fields through the child table's own endpoint, so a self-only list
|
|
442
|
+
such as `["incident"]` is enough to read them. Declaring the immediate parent,
|
|
443
|
+
as `servicenow-mcp-setup` offers, is optional:
|
|
354
444
|
`servicenow-mcp-setup grant --profile dev --read change_request --related change_request=task`.
|
|
355
|
-
|
|
356
|
-
|
|
445
|
+
That adds `task` to the read allowlist, because the loader requires it, and a
|
|
446
|
+
later grant that gives `change_request` another operation adds `task` to that
|
|
447
|
+
operation's allowlist too. On its own this makes `task` addressable by no tool,
|
|
448
|
+
because it has no target of its own, unless such an allowlist is `*`. If
|
|
449
|
+
`task` has, or later gets, a target of its own, that target's tools can then
|
|
450
|
+
use those operations on it, so declare a table only where every tool on its
|
|
451
|
+
own target may use every operation the declaring target has or will have.
|
|
452
|
+
A grant on a base table such as `task` reaches the records of the tables that
|
|
453
|
+
extend it, such as `incident`, whatever `relatedTables` lists, so grant a base
|
|
454
|
+
table only when those records should be reachable through it. Likewise, a
|
|
455
|
+
view or alias returns data from every table it reads, whatever
|
|
456
|
+
`relatedTables` lists: declare each of those tables, so the loader requires
|
|
457
|
+
each to carry the same permission, and grant the view only when all of that
|
|
458
|
+
data should be reachable.
|
|
357
459
|
|
|
358
460
|
### Credential Options
|
|
359
461
|
|
|
@@ -471,36 +573,28 @@ ServiceNow upstream can return HTTP 429 with an empty body, while this server's
|
|
|
471
573
|
|
|
472
574
|
---
|
|
473
575
|
|
|
474
|
-
##
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
|
481
|
-
|
|
482
|
-
|
|
|
483
|
-
|
|
|
484
|
-
|
|
|
485
|
-
|
|
|
486
|
-
|
|
|
487
|
-
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
| System log queries | ❌ | ✅ |
|
|
493
|
-
| Code search across artifacts | ❌ | ✅ |
|
|
494
|
-
| Table/app/plugin discovery | ❌ | ✅ |
|
|
495
|
-
| ATF test execution | ❌ | ✅ suite execution with explicit profile grant |
|
|
496
|
-
| Natural language interface | ❌ | 🚧 currently policy-denied pending a typed access plan |
|
|
497
|
-
| Background scripts | ❌ | 🚧 on the [roadmap](#roadmap) (SNS-39) |
|
|
498
|
-
| Multi-instance profiles | ❌ | ✅ (named profiles, per-call override) |
|
|
499
|
-
| **Total tools** | **1–3** | **23** |
|
|
576
|
+
## What the tools cover
|
|
577
|
+
|
|
578
|
+
The registered catalog has 24 tools (see [Tools Reference](#tools-reference)):
|
|
579
|
+
|
|
580
|
+
| Area | Tools |
|
|
581
|
+
|------|-------|
|
|
582
|
+
| Records | `sn_query`, `sn_get`, `sn_create`, `sn_update`, `sn_delete`, `sn_batch` |
|
|
583
|
+
| Incident journals (append-only) | `sn_incident_add_comment`, `sn_incident_add_work_note` |
|
|
584
|
+
| Analytics and schema | `sn_aggregate`, `sn_schema`, `sn_health` |
|
|
585
|
+
| CMDB and operations | `sn_relationships`, `sn_attach`, `sn_syslog`, `sn_codesearch`, `sn_discover` |
|
|
586
|
+
| ATF | `sn_atf_author`, `sn_atf_run`, `sn_atf_results`, `sn_atf_readiness`, `sn_atf` |
|
|
587
|
+
| Flow Designer (read-only) | `sn_flow_view` |
|
|
588
|
+
| Profiles | `sn_profile` |
|
|
589
|
+
| Natural language | `sn_nl` (currently policy-denied pending a typed access plan) |
|
|
590
|
+
|
|
591
|
+
Every tool requires a `profile`, and every tool is subject to the profile's
|
|
592
|
+
table and field policy. `sn_script` (background scripts) is not registered; see
|
|
593
|
+
the [Roadmap](#roadmap).
|
|
500
594
|
|
|
501
595
|
---
|
|
502
596
|
|
|
503
|
-
##
|
|
597
|
+
## Manual environment setup
|
|
504
598
|
|
|
505
599
|
The server speaks stdio and requires Node.js 20 or newer. The shortest path is
|
|
506
600
|
the bootstrap described under [Installation](#installation):
|
|
@@ -570,6 +664,10 @@ Those two require action on every install. The transport is stdio, as it was in
|
|
|
570
664
|
The breaking changes from `1.0.0`, each with a before/after example, are in
|
|
571
665
|
[Migrating to 2.0](docs/V2-MIGRATION.md#breaking-changes-at-a-glance).
|
|
572
666
|
|
|
667
|
+
Already on 2.x? 2.2.0 changes field-policy loading and journal writes, and
|
|
668
|
+
can refuse to start on a configuration that loads today. Read
|
|
669
|
+
[Upgrading to 2.2.0](docs/V2-MIGRATION.md#upgrading-to-220) first.
|
|
670
|
+
|
|
573
671
|
### Deployment guides for the dormant HTTP transport
|
|
574
672
|
|
|
575
673
|
2.0 ships stdio only. The container image, the health and shutdown contract,
|
|
@@ -596,12 +694,12 @@ in this section is needed to use this server.
|
|
|
596
694
|
|------|-------------|
|
|
597
695
|
| `sn_query` | Query an approved table with structured filters, field selection, pagination, and sorting; bounded raw reads require an explicit policy rule |
|
|
598
696
|
| `sn_get` | Get a single record by sys_id from an approved table |
|
|
599
|
-
| `sn_create` | Create a record on any table granted for writes, using only field-policy-approved writable fields
|
|
600
|
-
| `sn_update` | Update one record selected by exact `sys_id` on any table granted for writes, using only field-policy-approved writable fields;
|
|
697
|
+
| `sn_create` | Create a record on any table granted for writes, using only field-policy-approved writable fields, including the journal fields `comments` and `work_notes`; `incident` additionally requires a bounded `short_description` |
|
|
698
|
+
| `sn_update` | Update one record selected by exact `sys_id` on any table granted for writes, using only field-policy-approved writable fields; `comments` and `work_notes` append a journal entry |
|
|
601
699
|
| `sn_incident_add_comment` | Append one bounded customer-visible comment to an incident; repeated calls append again |
|
|
602
700
|
| `sn_incident_add_work_note` | Append one bounded internal work note to an incident; repeated calls append again |
|
|
603
701
|
| `sn_delete` | Delete a record on an approved write table (requires `confirm: true`) |
|
|
604
|
-
| `sn_batch` | Bulk update/delete using a required structured filter and dry-run safety (raw encoded selectors are prohibited; requires `confirm: true` to execute) |
|
|
702
|
+
| `sn_batch` | Bulk update/delete using a required structured filter and dry-run safety (raw encoded selectors are prohibited; requires `confirm: true` to execute; a dry run returns the count, up to 5 sample records the profile may read, and the field names it would write). Values get the same policy as `sn_update`; execution uses the ServiceNow REST Batch API and never re-sends a batch |
|
|
605
703
|
|
|
606
704
|
### Analytics & Schema
|
|
607
705
|
|
|
@@ -636,11 +734,17 @@ in this section is needed to use this server.
|
|
|
636
734
|
stub and is **not published in 2.0** — it does not appear in `tools/list`. Use
|
|
637
735
|
`sn_query` and `sn_batch` instead. See [Roadmap](#roadmap).
|
|
638
736
|
|
|
737
|
+
### Flow Designer
|
|
738
|
+
|
|
739
|
+
| Tool | Description |
|
|
740
|
+
|------|-------------|
|
|
741
|
+
| `sn_flow_view` | Show a flow or subflow as a Mermaid diagram, an outline and a structured graph: trigger, steps, branches, loops, error handling, input values under field policy, and called subflows to depth 3. Read-only through the Table API; never calls Flow Designer's internal API. See [docs/FLOW-VIEW.md](docs/FLOW-VIEW.md) |
|
|
742
|
+
|
|
639
743
|
### Profile Management
|
|
640
744
|
|
|
641
745
|
| Tool | Description |
|
|
642
746
|
|------|-------------|
|
|
643
|
-
| `sn_profile` | Inspect non-secret metadata for one explicitly named profile; profile configuration is operator-managed out of band |
|
|
747
|
+
| `sn_profile` | Inspect non-secret metadata and the effective policy card for one explicitly named profile; profile configuration is operator-managed out of band |
|
|
644
748
|
|
|
645
749
|
---
|
|
646
750
|
|
|
@@ -747,49 +851,57 @@ for 24 hours by default. The default cached table patterns are
|
|
|
747
851
|
`sys_metadata*`, and `sys_flow*`. Set `metadataCache.ttlMs` and
|
|
748
852
|
`metadataCache.tables` on a file-backed profile, or `SN_METADATA_CACHE_TTL_MS`
|
|
749
853
|
/ `SN_METADATA_CACHE_TABLES` for the explicit environment profile. `sn_query`,
|
|
750
|
-
`sn_get`, and `sn_schema` accept `force_recache: true` to refresh metadata.
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
the
|
|
762
|
-
|
|
763
|
-
This has one consequence worth knowing before you configure it:
|
|
764
|
-
|
|
765
|
-
| Profile auth | Metadata caching |
|
|
766
|
-
|---|---|
|
|
767
|
-
| Basic | works — the profile carries a username |
|
|
768
|
-
| OAuth **password** grant | works — the profile carries a username |
|
|
769
|
-
| OAuth **client_credentials** | **disabled** — no username to resolve a timezone from |
|
|
770
|
-
| API key | **disabled** — no username to resolve a timezone from |
|
|
771
|
-
|
|
772
|
-
The profile also needs read access to `sys_user` (for `time_zone`) and
|
|
773
|
-
`sys_properties` (for `glide.sys.default.tz`) for the lookup to succeed at all.
|
|
854
|
+
`sn_get`, and `sn_schema` accept `force_recache: true` to refresh metadata.
|
|
855
|
+
|
|
856
|
+
**Freshness is checked against the instance, in every auth mode.** Before each
|
|
857
|
+
fetch the cache reads a watermark in one small request: the table's row count
|
|
858
|
+
(`X-Total-Count`) and its newest row by `sys_updated_on`, as ServiceNow stores
|
|
859
|
+
it (UTC). A cache hit is served only while a new read of that watermark still
|
|
860
|
+
matches. Inserts and deletes change the count, and inserts and updates change
|
|
861
|
+
the newest row. Both sides of the comparison come from the instance, so the
|
|
862
|
+
session timezone, the date format, and clock skew between this host and the
|
|
863
|
+
instance play no part, and no user lookup is needed. Basic, OAuth (password or
|
|
864
|
+
client_credentials), and API-key profiles all cache the same way. The only
|
|
865
|
+
access it needs is the ServiceNow read permission of the user the credential
|
|
866
|
+
runs as, on the cached table itself; no `tableAccess` change is needed.
|
|
774
867
|
|
|
775
868
|
**The honest tradeoff:** the cache only ever saved payload bytes, never round
|
|
776
|
-
trips — a cache hit still costs one
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
869
|
+
trips — a cache hit still costs one watermark read, and a miss costs one extra.
|
|
870
|
+
A tool call reads each table's watermark once, however many times it reads the
|
|
871
|
+
table, until the call writes. A hierarchy walk reads `sys_db_object` once for
|
|
872
|
+
the whole chain. An empty table caches like any other.
|
|
873
|
+
|
|
874
|
+
If a table's watermark cannot be used, its reads go straight upstream, without
|
|
875
|
+
a watermark request, for a while: 15 minutes when the cause persists (an
|
|
876
|
+
incomplete or future-dated watermark, a 403 or 404), 30 seconds when it may not
|
|
877
|
+
(429, 5xx, timeouts, network), never longer than the TTL. A table whose newest
|
|
878
|
+
row is dated after the instance's own clock is one of these: that row would
|
|
879
|
+
stay the newest however many others were updated. Entries cached earlier are
|
|
880
|
+
kept and serve again once the table is cacheable, and `force_recache: true`
|
|
881
|
+
asks again at once.
|
|
882
|
+
|
|
883
|
+
**What the watermark can miss.** An update within the same second as the stored
|
|
884
|
+
watermark, to a row other than the newest, and a write that skips the system
|
|
885
|
+
fields (`autoSysFields(false)`) leave it unchanged. Such a change shows within
|
|
886
|
+
one TTL — up to 24 hours at the default. Lower `SN_METADATA_CACHE_TTL_MS` or
|
|
887
|
+
pass `force_recache: true` to see it sooner. `sn_batch` is not exposed to these
|
|
888
|
+
gaps: it looks up the records it will update or delete on the instance on every
|
|
889
|
+
run, never in the cache, even on a cached table.
|
|
890
|
+
|
|
891
|
+
**`sn_schema` results** are also kept for 5 minutes per profile, credential
|
|
892
|
+
identity, and effective policy, so a repeat call costs no request at all. They
|
|
893
|
+
are not revalidated in that window; `force_recache: true` refreshes them, and
|
|
894
|
+
`schemaCacheTtlMs` / `SN_SCHEMA_CACHE_TTL_MS` (up to 1 hour) changes the window.
|
|
786
895
|
|
|
787
896
|
### Unrestricted field selection (`fields=all`, `response_format=detailed`)
|
|
788
897
|
|
|
789
|
-
Both resolve to
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
898
|
+
Both resolve to the profile's readable set for the table. Where the field
|
|
899
|
+
policy narrows that set, they request exactly the listed fields and read no
|
|
900
|
+
dictionary rows; the rest of this section applies when the readable set is
|
|
901
|
+
every field. That wildcard selection used to drop `sysparm_fields` entirely,
|
|
902
|
+
so ServiceNow returned every column and a wide table could breach the 1 MiB
|
|
903
|
+
cumulative upstream cap and **fail the call outright**. It is now bounded to at
|
|
904
|
+
most **100 columns**.
|
|
793
905
|
|
|
794
906
|
The cap bounds the *upstream request*, not the response — truncating after
|
|
795
907
|
receipt would not help, because the bytes have already crossed the wire and
|
|
@@ -808,7 +920,8 @@ Two behavior changes worth stating plainly, because they change what a caller
|
|
|
808
920
|
gets back:
|
|
809
921
|
|
|
810
922
|
- **Journal fields are now returned.** `comments` and `work_notes` are included
|
|
811
|
-
in the resolved set for `fields=all` and `detailed
|
|
923
|
+
in the resolved set for `fields=all` and `detailed` wherever the profile can
|
|
924
|
+
read them. See
|
|
812
925
|
[Journal content and field selection](#journal-content-and-field-selection).
|
|
813
926
|
- **Sensitive-looking field names are excluded from the resolved set entirely.**
|
|
814
927
|
A name matching the sensitive-field pattern is never *requested*, rather than
|
|
@@ -870,6 +983,7 @@ the same loader the server uses at request time:
|
|
|
870
983
|
servicenow-mcp-setup grant --profile dev --read incident,problem --write incident
|
|
871
984
|
servicenow-mcp-setup grant --profile dev --read cmdb_ci --tools sn_query,sn_relationships
|
|
872
985
|
servicenow-mcp-setup grant --profile dev --read change_request --related change_request=task
|
|
986
|
+
servicenow-mcp-setup grant --profile dev --flows # sn_flow_view's 15 tables, bound to sn_flow_view only
|
|
873
987
|
```
|
|
874
988
|
|
|
875
989
|
Allowlist entries may be exact table names or the literal `*` to allow every
|
|
@@ -889,21 +1003,25 @@ and must be valid ServiceNow identifiers.
|
|
|
889
1003
|
|----------|----------|---------|-------------|
|
|
890
1004
|
| `SN_ALLOWED_READ_TABLES` | ❌ | deny all | Tables permitted for read operations on the explicit `SN_PROFILE_NAME` environment profile only. Use `*` to allow every readable table. |
|
|
891
1005
|
| `SN_ALLOWED_WRITE_TABLES` | ❌ | deny all | Tables permitted for create, update, incident journal append, delete, upload, and confirmed batch operations on the explicit `SN_PROFILE_NAME` environment profile only. Use `*` to allow every writable table. Write permission never implies read permission. |
|
|
892
|
-
| `SN_TABLE_ACCESS_TARGETS` | Required for exact allowlisted caller-addressable tables; optional with `*` | `[]` | Trusted JSON classification with `table`, exact permitted `tools`, `kind` (`canonical`, `alias`, `view`, or `extension`), literal `closureComplete: true`, and the
|
|
893
|
-
| `SN_FIELD_POLICY_DEFINITIONS` |
|
|
1006
|
+
| `SN_TABLE_ACCESS_TARGETS` | Required for exact allowlisted caller-addressable tables; optional with `*` | `[]` | Trusted JSON classification with `table`, exact permitted `tools`, `kind` (`canonical`, `alias`, `view`, or `extension`), literal `closureComplete: true`, and `relatedTables`: the target itself plus any backing or parent tables the operator declares. The loader checks that every related table has the target's operation permission; it does not derive the list from the instance, and the list grants no access. A self-only list is valid for a `canonical` target; `alias`, `view` and `extension` targets must name at least one backing table, and a view or alias should declare every table it reads, because it returns data from each of them whatever the list says. With `*`, omitted target entries use the wildcard operation grant; explicit target entries can still narrow tools and check their related tables. |
|
|
1007
|
+
| `SN_FIELD_POLICY_DEFINITIONS` | ❌ | no narrowing | Field policy for the explicit `SN_PROFILE_NAME` environment profile only, like the `SN_ALLOWED_*` variables. **If `~/.servicenow-mcp/config.json` exists, setting this variable stops startup**; give those profiles their own `fieldPolicy` instead. The value is trusted JSON, at most 65,536 characters: either a table map keyed by table name or `*`, the same shape as a profile's `fieldPolicy`, or an object holding the profile keys (`fieldPolicy`, or `readableTableFields` / `writableTableFields`), not both. Each field set is a list of exact field names or `"*"`; `["*"]` means `"*"` in that exact form only, and patterns such as `"u_*"` are rejected. A malformed value stops startup with the key named. Sensitive field names are always denied. See [Field policy](#field-policy). |
|
|
894
1008
|
| `SN_ENCODED_QUERY_READ_POLICY` | ❌ | deny all | Trusted JSON object containing bounded `rules` for an exact `sn_query`/table pair. Each rule requires `maxLength`, `maxTerms`, readable `fields`, supported `operators`, `maxLimit`, `maxOffset`, and `maxResponseBytes`. No rule can authorize a write or another tool. |
|
|
895
1009
|
|
|
896
1010
|
Invalid policy configuration fails startup. A composed tool is admitted only
|
|
897
|
-
when its
|
|
898
|
-
client access.
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1011
|
+
when every table in its access plan is allowed before the first ServiceNow
|
|
1012
|
+
client access. A target's declared related tables must each have the same
|
|
1013
|
+
read or write permission as the target, or the policy is rejected. Related
|
|
1014
|
+
permission does not make a table directly caller-addressable without its own
|
|
1015
|
+
target entry. The related tables are a declaration, not a list derived from
|
|
1016
|
+
the instance: a grant on a base table reaches the records of the tables that
|
|
1017
|
+
extend it whether or not they are listed, so grant a base table only when
|
|
1018
|
+
those records should be reachable. Likewise, a view or alias returns data from
|
|
1019
|
+
every table it reads, whatever `relatedTables` lists: declare each of those
|
|
1020
|
+
tables, so the loader requires each to carry the same permission, and grant
|
|
1021
|
+
the view only when all of that data should be reachable. Field policy narrows what a granted table exposes; it does not deny a table the
|
|
903
1022
|
operator granted. Sensitive-looking field names remain excluded regardless. Build the
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
complete. File-backed profile example:
|
|
1023
|
+
target catalog from approved ServiceNow metadata and treat it as trusted
|
|
1024
|
+
startup configuration. File-backed profile example:
|
|
907
1025
|
|
|
908
1026
|
```json
|
|
909
1027
|
{
|
|
@@ -920,7 +1038,7 @@ complete. File-backed profile example:
|
|
|
920
1038
|
{
|
|
921
1039
|
"table": "incident",
|
|
922
1040
|
"kind": "canonical",
|
|
923
|
-
"tools": ["sn_query", "sn_get", "sn_create", "sn_update"],
|
|
1041
|
+
"tools": ["sn_query", "sn_get", "sn_create", "sn_update", "sn_incident_add_comment", "sn_incident_add_work_note"],
|
|
924
1042
|
"closureComplete": true,
|
|
925
1043
|
"relatedTables": ["incident"]
|
|
926
1044
|
}
|
|
@@ -935,11 +1053,296 @@ complete. File-backed profile example:
|
|
|
935
1053
|
`atf.execute` profile grant. Typed ATF steps use the authenticated native form
|
|
936
1054
|
to save and verify inputs and output references without ACL changes or an
|
|
937
1055
|
installed application. See [ATF workflow](docs/ATF-WORKFLOW.md).
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1056
|
+
|
|
1057
|
+
#### Field policy
|
|
1058
|
+
|
|
1059
|
+
Field policy is the second gate after `tableAccess`. It narrows which fields
|
|
1060
|
+
of a granted table a profile may read, filter on, return and write; it never
|
|
1061
|
+
denies a table the profile grants. A profile with no field policy may read and
|
|
1062
|
+
write every field of a granted table, except that sensitive-looking names
|
|
1063
|
+
(`password`, `token`, `secret`, `api_key` and similar) are always denied, and
|
|
1064
|
+
the class and domain fields below must be listed before they can be written.
|
|
1065
|
+
|
|
1066
|
+
State it on a profile in `~/.servicenow-mcp/config.json`, beside
|
|
1067
|
+
`tableAccess`, in one of two forms. A profile that states both fails to load.
|
|
1068
|
+
For the `SN_PROFILE_NAME` environment profile, `SN_FIELD_POLICY_DEFINITIONS`
|
|
1069
|
+
supplies the same keys.
|
|
1070
|
+
|
|
1071
|
+
**`fieldPolicy`** maps a table name, or `"*"`, to an entry with up to three
|
|
1072
|
+
keys:
|
|
1073
|
+
|
|
1074
|
+
| Key | What it limits | When the entry leaves it out |
|
|
1075
|
+
|---|---|---|
|
|
1076
|
+
| `readable` | Fields a call may read, return, or filter on | The `"*"` entry's `readable` where that entry applies (below); otherwise every field |
|
|
1077
|
+
| `writable` | Fields a write may set | The `"*"` entry's `writable` where that entry applies; otherwise every field |
|
|
1078
|
+
| `defaults` | Fields a read returns when the caller names none | A bounded projection inside `readable`: a built-in table's own projection; on other tables the `"*"` entry's `defaults`, or `sys_id` |
|
|
1079
|
+
|
|
1080
|
+
**`readableTableFields` / `writableTableFields`** are lists of
|
|
1081
|
+
`{ "table": ..., "fields": ... }` entries that set `readable` and `writable`.
|
|
1082
|
+
They have no `defaults`. A table may appear once in each list.
|
|
1083
|
+
|
|
1084
|
+
Every field set is a list of exact field names, or `"*"` for every field.
|
|
1085
|
+
`["*"]` means the same as `"*"`, in that exact form only: `["*", "number"]`,
|
|
1086
|
+
`[" * "]` and patterns such as `"u_*"` are rejected. Table and field names are
|
|
1087
|
+
letters, digits and underscores, start with a letter, are at most 80
|
|
1088
|
+
characters, and are compared case-insensitively. `defaults` must stay inside
|
|
1089
|
+
`readable`. On a table with no built-in entry, an entry that lists
|
|
1090
|
+
`readable` but no `defaults` returns that whole list by default, and an entry
|
|
1091
|
+
that states only `defaults` also limits `readable` to those fields unless a
|
|
1092
|
+
`"*"` entry states `readable`.
|
|
1093
|
+
|
|
1094
|
+
A worked example, added to a profile beside `tableAccess`:
|
|
1095
|
+
|
|
1096
|
+
```json
|
|
1097
|
+
{
|
|
1098
|
+
"fieldPolicy": {
|
|
1099
|
+
"*": {
|
|
1100
|
+
"writable": ["short_description", "description", "state", "work_notes"]
|
|
1101
|
+
},
|
|
1102
|
+
"incident": {
|
|
1103
|
+
"writable": ["short_description", "description", "state", "assigned_to", "assignment_group", "work_notes"]
|
|
1104
|
+
},
|
|
1105
|
+
"u_integration_log": {
|
|
1106
|
+
"readable": [],
|
|
1107
|
+
"writable": "*"
|
|
1108
|
+
},
|
|
1109
|
+
"sys_user": {
|
|
1110
|
+
"readable": ["sys_id", "user_name", "name", "email"],
|
|
1111
|
+
"writable": []
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
```
|
|
1116
|
+
|
|
1117
|
+
On that profile, for the tables its `tableAccess` grants:
|
|
1118
|
+
|
|
1119
|
+
- Every ITSM table except `incident`, and every table without a built-in
|
|
1120
|
+
entry except `u_integration_log`, can be written only in the four fields of
|
|
1121
|
+
the `"*"` entry. `comments` is not listed, so no customer-visible comment
|
|
1122
|
+
can be posted there. The `"*"` entry states no `readable`, so reads stay
|
|
1123
|
+
open.
|
|
1124
|
+
- `incident` states its own `writable`, which replaces the `"*"` list for
|
|
1125
|
+
`incident` only. `sn_incident_add_comment` is denied there, because
|
|
1126
|
+
`comments` is not listed, and `sn_incident_add_work_note` is allowed.
|
|
1127
|
+
- `u_integration_log` is write-only. Any field except sensitive names and the
|
|
1128
|
+
class and domain fields can be written, and a write returns only `sys_id`.
|
|
1129
|
+
Reads are denied, so `sn_batch`, which reads the matching `sys_id`s first,
|
|
1130
|
+
cannot run there.
|
|
1131
|
+
- `sys_user` is a system table, so the `"*"` entry does not reach it, and
|
|
1132
|
+
naming it is the only way to narrow it. Here it can read four fields and
|
|
1133
|
+
cannot be written. Other system tables, such as `sys_script`, are not
|
|
1134
|
+
narrowed by this policy at all.
|
|
1135
|
+
|
|
1136
|
+
The same policy in the list form:
|
|
1137
|
+
|
|
1138
|
+
```json
|
|
1139
|
+
{
|
|
1140
|
+
"readableTableFields": [
|
|
1141
|
+
{ "table": "u_integration_log", "fields": [] },
|
|
1142
|
+
{ "table": "sys_user", "fields": ["sys_id", "user_name", "name", "email"] }
|
|
1143
|
+
],
|
|
1144
|
+
"writableTableFields": [
|
|
1145
|
+
{ "table": "*", "fields": ["short_description", "description", "state", "work_notes"] },
|
|
1146
|
+
{ "table": "incident", "fields": ["short_description", "description", "state", "assigned_to", "assignment_group", "work_notes"] },
|
|
1147
|
+
{ "table": "u_integration_log", "fields": "*" },
|
|
1148
|
+
{ "table": "sys_user", "fields": [] }
|
|
1149
|
+
]
|
|
1150
|
+
}
|
|
1151
|
+
```
|
|
1152
|
+
|
|
1153
|
+
**Which tables a `"*"` entry reaches.** Tables fall into three groups:
|
|
1154
|
+
|
|
1155
|
+
- **ITSM tables:** `incident`, `change_request`, `problem`, `sc_request`,
|
|
1156
|
+
`sc_req_item`, `sc_task`, `task`, `cmdb_ci`, `cmdb_ci_server`,
|
|
1157
|
+
`cmdb_ci_computer`, `kb_knowledge`.
|
|
1158
|
+
- **Every table without a built-in entry:** `u_*` and `x_*` tables, and
|
|
1159
|
+
platform tables such as `change_task` and `sys_properties`.
|
|
1160
|
+
- **The 23 system tables:** `sys_script`, `sys_script_include`,
|
|
1161
|
+
`sys_script_client`, `sys_ui_script`, `sys_ws_operation`, `sys_user`,
|
|
1162
|
+
`sys_user_group`, `sys_user_grmember`, `sys_db_object`, `sys_app`,
|
|
1163
|
+
`sys_store_app`, `v_plugin`, `sys_atf_test`, `sys_atf_test_suite`,
|
|
1164
|
+
`sys_atf_test_suite_test`, `sys_atf_test_result`, `sys_atf_step`,
|
|
1165
|
+
`sys_element_mapping`, `sys_variable_value`, `sys_atf_test_suite_result`,
|
|
1166
|
+
`sys_atf_test_result_step`, `sys_atf_agent`, `syslog`.
|
|
1167
|
+
|
|
1168
|
+
On an ITSM table or a table without a built-in entry, named in the policy or
|
|
1169
|
+
not, `readable` and `writable` each resolve from the table's own entry, then
|
|
1170
|
+
the `"*"` entry, then every field. To keep one key open on such a table under
|
|
1171
|
+
a narrowing `"*"` entry, state it on the table, such as
|
|
1172
|
+
`"u_x": { "writable": "*" }`. The ITSM tables keep their built-in default
|
|
1173
|
+
projections, trimmed to the effective `readable` set.
|
|
1174
|
+
|
|
1175
|
+
A `"*"` entry never reaches a system table, named or not: each key comes from
|
|
1176
|
+
the table's own entry, or else covers every field. The system tables include
|
|
1177
|
+
the script tables (`sys_script`, `sys_script_include`, `sys_script_client`,
|
|
1178
|
+
`sys_ui_script`, `sys_ws_operation`), whose records hold server- or
|
|
1179
|
+
client-side code, and the user and group tables (`sys_user`,
|
|
1180
|
+
`sys_user_group`, `sys_user_grmember`). Name a system table to narrow it, and
|
|
1181
|
+
grant it in `tableAccess` only deliberately.
|
|
1182
|
+
|
|
1183
|
+
**Read-only profiles.** A `"*"` entry with `writable: []` does not make a
|
|
1184
|
+
profile read-only, because it never reaches the system tables. To make a
|
|
1185
|
+
profile read-only, grant no writes: `tableAccess.writeTables: []`, or
|
|
1186
|
+
`SN_ALLOWED_WRITE_TABLES=''` for the environment profile.
|
|
1187
|
+
|
|
1188
|
+
**Class and domain fields.** `sys_class_name`, `sys_class_path`, `sys_domain`
|
|
1189
|
+
and `sys_domain_path` move a record to another class or domain, so no
|
|
1190
|
+
writable wildcard covers them, including the open default of a profile with
|
|
1191
|
+
no field policy. Each is written only where it is named in the table's
|
|
1192
|
+
`writable`, or in a `"*"` entry's `writable` on a table that entry reaches.
|
|
1193
|
+
Listing `sys_domain` does not list `sys_domain_path`, and the reverse.
|
|
1194
|
+
Otherwise the write is denied with:
|
|
1195
|
+
|
|
1196
|
+
```text
|
|
1197
|
+
Write denied by policy: field "sys_domain" on "incident" changes the record's class or domain, so a writable wildcard never covers it. List it explicitly in fieldPolicy.incident.writable to allow this write.
|
|
1198
|
+
```
|
|
1199
|
+
|
|
1200
|
+
**`readable: []` and `writable: []`.** `readable: []` makes a table
|
|
1201
|
+
write-only: writes succeed and return only `sys_id`, reads are denied, and
|
|
1202
|
+
`sn_batch` cannot run there. `writable: []` blocks writes. To make a table
|
|
1203
|
+
unreachable, leave it out of `tableAccess`. Every write response includes the
|
|
1204
|
+
written record's `sys_id`; every other field, `number` included, follows the
|
|
1205
|
+
readable set.
|
|
1206
|
+
|
|
1207
|
+
**Parent tables.** Field policy is evaluated against the table a call names.
|
|
1208
|
+
If a profile may write a parent table such as `task`, a write addressed to
|
|
1209
|
+
`task` is checked against `task`'s policy, whatever the class of the record.
|
|
1210
|
+
When you narrow a field such as `comments` on `incident`, narrow it on every
|
|
1211
|
+
write-granted parent table too, or do not grant writes on the parent. A
|
|
1212
|
+
`"*"` entry covers `incident` and `task` alike. The same holds for a platform
|
|
1213
|
+
table that stores journal entries directly, such as `sys_journal_field`: if a
|
|
1214
|
+
profile may write it, per-table narrowing on `incident` does not reach a
|
|
1215
|
+
write addressed to it, so either leave it out of the write grant or narrow
|
|
1216
|
+
with a `"*"` entry, which reaches it.
|
|
1217
|
+
|
|
1218
|
+
**Schema metadata.** `sn_schema` describes the fields the profile can read on
|
|
1219
|
+
the table it names. It needs `tableAccess` read on `sys_dictionary`,
|
|
1220
|
+
`sys_db_object`, `sys_documentation` and `sys_choice`, but a field policy on
|
|
1221
|
+
those metadata tables does not trim the labels, types, choices and help it
|
|
1222
|
+
returns for the readable fields. The exception is `inherited_from`, the
|
|
1223
|
+
ancestor table a field comes from: it appears only where the profile can read
|
|
1224
|
+
`super_class` on `sys_db_object`.
|
|
1225
|
+
|
|
1226
|
+
**Role and group-membership tables.** Nothing built in blocks
|
|
1227
|
+
`sys_user_role`, `sys_user_has_role`, `sys_group_has_role` or
|
|
1228
|
+
`sys_user_grmember`. This is deliberate: profile configuration alone decides,
|
|
1229
|
+
with `tableAccess` granting the table, field policy narrowing it, and the
|
|
1230
|
+
integration account's ServiceNow roles bounding what is left. Grant these
|
|
1231
|
+
tables only deliberately. `sys_user_grmember` is a system table; the other
|
|
1232
|
+
three have no built-in entry, so a `"*"` entry reaches them.
|
|
1233
|
+
|
|
1234
|
+
**Validation.** Field policy is checked when profiles load, and any error
|
|
1235
|
+
stops the server from starting. Table keys must be unique ignoring case, a
|
|
1236
|
+
table may appear once in each list, and a field may appear once in each set.
|
|
1237
|
+
Unknown keys are rejected, including comment keys such as `_comment`: a
|
|
1238
|
+
`fieldPolicy` entry accepts only `defaults`, `readable` and `writable`, and a
|
|
1239
|
+
list entry only `table` and `fields`. Every error and its message is listed in
|
|
1240
|
+
[Field-policy load errors](docs/V2-MIGRATION.md#field-policy-load-errors).
|
|
1241
|
+
|
|
1242
|
+
#### Journal fields
|
|
1243
|
+
|
|
1244
|
+
`comments` (customer-visible) and `work_notes` (internal) are written like any
|
|
1245
|
+
other field through `sn_create`, `sn_update` and `sn_batch`, on any table
|
|
1246
|
+
granted for writes: `incident`, `change_request`, `problem`, `sc_task`, custom
|
|
1247
|
+
task tables. A Table API write to a journal field appends one entry; it never
|
|
1248
|
+
edits or removes earlier entries. Each entry is 1-8,000 characters of
|
|
1249
|
+
non-blank text, at most 16,384 UTF-8 bytes, without control or format
|
|
1250
|
+
characters other than newline, carriage return and tab.
|
|
1251
|
+
|
|
1252
|
+
Field policy decides who may write them, and with no field policy every
|
|
1253
|
+
write-granted table accepts both. To keep a profile from posting
|
|
1254
|
+
customer-visible comments, set `writable` to an explicit list that leaves
|
|
1255
|
+
`comments` out: on each table, or on the `"*"` entry, and on write-granted
|
|
1256
|
+
parent tables such as `task` (see [Field policy](#field-policy)). On
|
|
1257
|
+
`incident` the same setting also denies `sn_incident_add_comment`, so both
|
|
1258
|
+
routes to the field agree. Leaving the dedicated tools off a target does not
|
|
1259
|
+
withhold journals from `sn_create`, `sn_update` or `sn_batch`.
|
|
1260
|
+
|
|
1261
|
+
The dedicated incident tools take exactly `profile`, incident `sys_id` and
|
|
1262
|
+
bounded `content`, and need write access to `incident`.
|
|
1263
|
+
`servicenow-mcp-setup grant --write incident` binds both to the incident
|
|
1264
|
+
target unless you pass `--tools`.
|
|
1265
|
+
|
|
1266
|
+
Journal handling is keyed by field name. Only `comments` and `work_notes` get
|
|
1267
|
+
the journal bounds and are never re-sent; a custom journal field gets the
|
|
1268
|
+
generic bounds. See
|
|
1269
|
+
[Production security boundaries](docs/PRODUCTION-SECURITY.md#journal-content).
|
|
1270
|
+
|
|
1271
|
+
#### Write values
|
|
1272
|
+
|
|
1273
|
+
A field approved by the field policy accepts:
|
|
1274
|
+
|
|
1275
|
+
- a string, a boolean, a safe integer, or a finite decimal such as `12.5`
|
|
1276
|
+
(not exponent forms such as `1e21`);
|
|
1277
|
+
- `""` or `null` to clear the field;
|
|
1278
|
+
- an array of scalars for a list field such as `watch_list`, sent as one
|
|
1279
|
+
comma-separated value, so no element may contain a comma;
|
|
1280
|
+
- a `{"value": ..., "display_value": ..., "link": ...}` object, the shape
|
|
1281
|
+
reads return with display values, which is written as its `value`.
|
|
1282
|
+
|
|
1283
|
+
Values cannot contain control or format characters (newline, carriage return
|
|
1284
|
+
and tab are allowed) and are bounded to 100,000 characters and 400,000 UTF-8
|
|
1285
|
+
bytes. On `incident`,
|
|
1286
|
+
`short_description`, `description`, `close_notes`, the reference fields
|
|
1287
|
+
`caller_id`, `assignment_group` and `assigned_to`, and the choice fields keep
|
|
1288
|
+
typed checks: a reference takes a 32-character `sys_id` or `""`, a choice
|
|
1289
|
+
cannot contain `^`, `=` or `,`, and `short_description` is required on create
|
|
1290
|
+
and cannot be cleared. Every other incident field gets the generic bounds.
|
|
1291
|
+
|
|
1292
|
+
#### Bulk writes
|
|
1293
|
+
|
|
1294
|
+
`sn_batch` sends confirmed updates and deletes through the ServiceNow REST
|
|
1295
|
+
Batch API (`/api/now/v1/batch`), up to 50 records per request and fewer when
|
|
1296
|
+
field values are large, so a request body stays under 4 MiB unless one
|
|
1297
|
+
record's fields alone exceed about 3 MiB of JSON; such a record is sent one
|
|
1298
|
+
per request. Each request gets its own 1 MiB response budget, so a run can reach the 10,000-record cap
|
|
1299
|
+
(`limit` defaults to 200). The lookup's `sys_id`s are de-duplicated, so each
|
|
1300
|
+
matched record is targeted once per run.
|
|
1301
|
+
|
|
1302
|
+
A batch request that may have reached the instance is never sent again:
|
|
1303
|
+
|
|
1304
|
+
- If the instance refuses a batch request outright (401, 403 or 404), nothing
|
|
1305
|
+
in it ran, so the run switches to one Table API call per record, for that
|
|
1306
|
+
batch and the rest. Batches already confirmed are not sent again.
|
|
1307
|
+
- A rate limit (429) stops the run. The remaining records are reported as not
|
|
1308
|
+
sent, with the `Retry-After` hint, because serial calls would only add load.
|
|
1309
|
+
- A record whose sub-request returns a server error (5xx or 408) is
|
|
1310
|
+
unconfirmed: it may have been changed, so it is reported and never retried,
|
|
1311
|
+
and the run continues.
|
|
1312
|
+
- The run stops, and reports the remaining records as not sent, when a batch
|
|
1313
|
+
request fails or its response cannot be read or matched to the records
|
|
1314
|
+
sent, when every serviced record in one batch returns a server error, or
|
|
1315
|
+
when more than 10 records in the run are unconfirmed.
|
|
1316
|
+
|
|
1317
|
+
The result's `message` says how many records were unconfirmed or not sent,
|
|
1318
|
+
and why a run stopped. Unconfirmed records count as neither processed nor
|
|
1319
|
+
failed; records not sent count as failed.
|
|
1320
|
+
|
|
1321
|
+
The serial fallback follows the HTTP client's retry rules. A journal write
|
|
1322
|
+
(`comments` or `work_notes`) is never re-sent on any path. An ordinary
|
|
1323
|
+
`PATCH` is retried up to twice after a 502, 503, 504 or connection error, the
|
|
1324
|
+
same rule `sn_update` follows. The fallback stops at the first record whose
|
|
1325
|
+
outcome it cannot confirm, at a 429, and at a 401.
|
|
1326
|
+
|
|
1327
|
+
**Re-running a batch appends again.** A journal-only update does not change
|
|
1328
|
+
which records the filter matches, so running the same `sn_batch` again
|
|
1329
|
+
appends another entry to every matched record, not only to the records
|
|
1330
|
+
reported as unconfirmed or not sent. Check the unconfirmed records and
|
|
1331
|
+
narrow the filter to the records still to do before you re-run it.
|
|
1332
|
+
|
|
1333
|
+
**Practical size per call.** Each batch request must finish within the
|
|
1334
|
+
profile's request timeout (`timeoutMs`, or `SN_TIMEOUT_MS`; 30 seconds by
|
|
1335
|
+
default), and its duration grows with the server-side time each record's
|
|
1336
|
+
business rules take. As a rough guide, at 50-100 ms per record a 50-record
|
|
1337
|
+
batch takes a few seconds; at about 600 ms per record a single batch can
|
|
1338
|
+
reach the timeout, and its records are then reported as unconfirmed and the
|
|
1339
|
+
run stops. Over stdio the server sets no overall deadline on a call; the
|
|
1340
|
+
dormant HTTP transport ends a call after 120 seconds by default, which at
|
|
1341
|
+
those rates is roughly 1,200-2,400 records. For tables with heavy business
|
|
1342
|
+
rules, use a lower `limit` and split the work across calls with narrower
|
|
1343
|
+
filters. While the fields being set come to less than about 62 KB of JSON,
|
|
1344
|
+
each batch holds 50 records, so journal fields alone never make a batch
|
|
1345
|
+
smaller.
|
|
943
1346
|
|
|
944
1347
|
### ServiceNow profiles
|
|
945
1348
|
|
|
@@ -1010,10 +1413,10 @@ exact `profile`; no prior call creates default, active, or switch-profile state.
|
|
|
1010
1413
|
This server is designed for production use with multiple safety layers:
|
|
1011
1414
|
|
|
1012
1415
|
- **Delete operations** require explicit `confirm: true`
|
|
1013
|
-
- **Batch operations** run in dry-run mode by default — shows match count without making changes
|
|
1416
|
+
- **Batch operations** run in dry-run mode by default — shows the match count, a sample of up to 5 records and the fields it would write, without making changes (`confirm` re-runs the query and can match different records)
|
|
1014
1417
|
- **Bulk operations** require `confirm: true` to leave dry-run mode
|
|
1015
1418
|
- **Unclassified composition is denied** — `sn_nl` requires a complete typed access plan; ATF suite execution requires a separate explicit `atf.execute` grant
|
|
1016
|
-
- **Table access is deny-by-default** with independent exact read/write allowlists and
|
|
1419
|
+
- **Table access is deny-by-default** with independent exact read/write allowlists; sensitive field names are denied and no configuration can grant them
|
|
1017
1420
|
- **User input is neutralized** before interpolation into encoded queries (`^` is stripped from filter values — ServiceNow's query syntax has no escape sequence)
|
|
1018
1421
|
|
|
1019
1422
|
---
|