@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.
Files changed (269) hide show
  1. package/.env.example +6 -3
  2. package/CHANGELOG.md +404 -0
  3. package/README.md +580 -104
  4. package/dist/atf-form.d.ts +3 -15
  5. package/dist/atf-form.d.ts.map +1 -1
  6. package/dist/atf-policy.d.ts +1 -1
  7. package/dist/atf-policy.d.ts.map +1 -1
  8. package/dist/atf-policy.js +2 -0
  9. package/dist/atf-policy.js.map +1 -1
  10. package/dist/atf-result-cache.d.ts +23 -59
  11. package/dist/atf-result-cache.d.ts.map +1 -1
  12. package/dist/auth.d.ts +1 -0
  13. package/dist/auth.d.ts.map +1 -1
  14. package/dist/auth.js +17 -0
  15. package/dist/auth.js.map +1 -1
  16. package/dist/batch-limits.d.ts +18 -0
  17. package/dist/batch-limits.d.ts.map +1 -0
  18. package/dist/batch-limits.js +21 -0
  19. package/dist/batch-limits.js.map +1 -0
  20. package/dist/bounded-input.d.ts +49 -0
  21. package/dist/bounded-input.d.ts.map +1 -0
  22. package/dist/bounded-input.js +81 -0
  23. package/dist/bounded-input.js.map +1 -0
  24. package/dist/client.d.ts +25 -0
  25. package/dist/client.d.ts.map +1 -1
  26. package/dist/client.js +92 -18
  27. package/dist/client.js.map +1 -1
  28. package/dist/credential-tables.d.ts +32 -0
  29. package/dist/credential-tables.d.ts.map +1 -0
  30. package/dist/credential-tables.js +58 -0
  31. package/dist/credential-tables.js.map +1 -0
  32. package/dist/encoded-query-policy.d.ts +11 -0
  33. package/dist/encoded-query-policy.d.ts.map +1 -1
  34. package/dist/encoded-query-policy.js +18 -2
  35. package/dist/encoded-query-policy.js.map +1 -1
  36. package/dist/execution-context.d.ts +14 -0
  37. package/dist/execution-context.d.ts.map +1 -1
  38. package/dist/execution-context.js +8 -0
  39. package/dist/execution-context.js.map +1 -1
  40. package/dist/field-policy.d.ts +115 -3
  41. package/dist/field-policy.d.ts.map +1 -1
  42. package/dist/field-policy.js +909 -97
  43. package/dist/field-policy.js.map +1 -1
  44. package/dist/hidden-values.d.ts +225 -0
  45. package/dist/hidden-values.d.ts.map +1 -0
  46. package/dist/hidden-values.js +748 -0
  47. package/dist/hidden-values.js.map +1 -0
  48. package/dist/html-response.d.ts +34 -0
  49. package/dist/html-response.d.ts.map +1 -0
  50. package/dist/html-response.js +72 -0
  51. package/dist/html-response.js.map +1 -0
  52. package/dist/http-entrypoint.d.ts.map +1 -1
  53. package/dist/http-entrypoint.js +7 -0
  54. package/dist/http-entrypoint.js.map +1 -1
  55. package/dist/http-runtime.d.ts.map +1 -1
  56. package/dist/http-runtime.js +8 -0
  57. package/dist/http-runtime.js.map +1 -1
  58. package/dist/incident-journal-policy.d.ts +27 -5
  59. package/dist/incident-journal-policy.d.ts.map +1 -1
  60. package/dist/incident-journal-policy.js +34 -21
  61. package/dist/incident-journal-policy.js.map +1 -1
  62. package/dist/index.js +7 -0
  63. package/dist/index.js.map +1 -1
  64. package/dist/json-shape-limits.d.ts +71 -0
  65. package/dist/json-shape-limits.d.ts.map +1 -0
  66. package/dist/json-shape-limits.js +131 -0
  67. package/dist/json-shape-limits.js.map +1 -0
  68. package/dist/metadata-cache.d.ts +84 -21
  69. package/dist/metadata-cache.d.ts.map +1 -1
  70. package/dist/metadata-cache.js +316 -196
  71. package/dist/metadata-cache.js.map +1 -1
  72. package/dist/policy-card.d.ts +146 -0
  73. package/dist/policy-card.d.ts.map +1 -0
  74. package/dist/policy-card.js +420 -0
  75. package/dist/policy-card.js.map +1 -0
  76. package/dist/profile-manager.d.ts +19 -3
  77. package/dist/profile-manager.d.ts.map +1 -1
  78. package/dist/profile-manager.js +89 -4
  79. package/dist/profile-manager.js.map +1 -1
  80. package/dist/record-identifier-policy.d.ts +2 -8
  81. package/dist/record-identifier-policy.d.ts.map +1 -1
  82. package/dist/risky-grants.d.ts +25 -0
  83. package/dist/risky-grants.d.ts.map +1 -0
  84. package/dist/risky-grants.js +77 -0
  85. package/dist/risky-grants.js.map +1 -0
  86. package/dist/server.d.ts.map +1 -1
  87. package/dist/server.js +26 -5
  88. package/dist/server.js.map +1 -1
  89. package/dist/setup-prompts.js +1 -0
  90. package/dist/setup-prompts.js.map +1 -1
  91. package/dist/setup.d.ts +1 -1
  92. package/dist/setup.d.ts.map +1 -1
  93. package/dist/setup.js +305 -59
  94. package/dist/setup.js.map +1 -1
  95. package/dist/stdio-runtime.d.ts +15 -0
  96. package/dist/stdio-runtime.d.ts.map +1 -1
  97. package/dist/stdio-runtime.js +60 -0
  98. package/dist/stdio-runtime.js.map +1 -1
  99. package/dist/structured-query.d.ts +100 -115
  100. package/dist/structured-query.d.ts.map +1 -1
  101. package/dist/structured-query.js +138 -17
  102. package/dist/structured-query.js.map +1 -1
  103. package/dist/table-policy.d.ts +41 -4
  104. package/dist/table-policy.d.ts.map +1 -1
  105. package/dist/table-policy.js +82 -10
  106. package/dist/table-policy.js.map +1 -1
  107. package/dist/tool-error.d.ts +34 -0
  108. package/dist/tool-error.d.ts.map +1 -1
  109. package/dist/tool-error.js +109 -1
  110. package/dist/tool-error.js.map +1 -1
  111. package/dist/tool-table-access.d.ts.map +1 -1
  112. package/dist/tool-table-access.js +35 -5
  113. package/dist/tool-table-access.js.map +1 -1
  114. package/dist/tools/aggregate.d.ts +13 -19
  115. package/dist/tools/aggregate.d.ts.map +1 -1
  116. package/dist/tools/aggregate.js +4 -5
  117. package/dist/tools/aggregate.js.map +1 -1
  118. package/dist/tools/all-fields-cap.d.ts.map +1 -1
  119. package/dist/tools/all-fields-cap.js +32 -45
  120. package/dist/tools/all-fields-cap.js.map +1 -1
  121. package/dist/tools/atf-author-module.d.ts +29 -14
  122. package/dist/tools/atf-author-module.d.ts.map +1 -1
  123. package/dist/tools/atf-author-module.js +11 -5
  124. package/dist/tools/atf-author-module.js.map +1 -1
  125. package/dist/tools/atf-contracts.d.ts +135 -829
  126. package/dist/tools/atf-contracts.d.ts.map +1 -1
  127. package/dist/tools/atf-shared.js +2 -2
  128. package/dist/tools/atf-shared.js.map +1 -1
  129. package/dist/tools/atf-step-catalog.d.ts +16 -15
  130. package/dist/tools/atf-step-catalog.d.ts.map +1 -1
  131. package/dist/tools/atf-step-catalog.js +181 -10
  132. package/dist/tools/atf-step-catalog.js.map +1 -1
  133. package/dist/tools/atf.d.ts +8 -24
  134. package/dist/tools/atf.d.ts.map +1 -1
  135. package/dist/tools/atf.js +2 -2
  136. package/dist/tools/atf.js.map +1 -1
  137. package/dist/tools/attach.d.ts +6 -22
  138. package/dist/tools/attach.d.ts.map +1 -1
  139. package/dist/tools/batch.d.ts +18 -71
  140. package/dist/tools/batch.d.ts.map +1 -1
  141. package/dist/tools/batch.js +566 -100
  142. package/dist/tools/batch.js.map +1 -1
  143. package/dist/tools/catalog.d.ts +2 -2
  144. package/dist/tools/catalog.d.ts.map +1 -1
  145. package/dist/tools/catalog.js +7 -1
  146. package/dist/tools/catalog.js.map +1 -1
  147. package/dist/tools/codesearch.d.ts +1 -13
  148. package/dist/tools/codesearch.d.ts.map +1 -1
  149. package/dist/tools/create-module.d.ts +9 -14
  150. package/dist/tools/create-module.d.ts.map +1 -1
  151. package/dist/tools/create-module.js +4 -8
  152. package/dist/tools/create-module.js.map +1 -1
  153. package/dist/tools/delete.d.ts +1 -9
  154. package/dist/tools/delete.d.ts.map +1 -1
  155. package/dist/tools/delete.js +2 -3
  156. package/dist/tools/delete.js.map +1 -1
  157. package/dist/tools/discover.d.ts +6 -14
  158. package/dist/tools/discover.d.ts.map +1 -1
  159. package/dist/tools/flow-view-contracts.d.ts +1023 -0
  160. package/dist/tools/flow-view-contracts.d.ts.map +1 -0
  161. package/dist/tools/flow-view-contracts.js +570 -0
  162. package/dist/tools/flow-view-contracts.js.map +1 -0
  163. package/dist/tools/flow-view-graph.d.ts +86 -0
  164. package/dist/tools/flow-view-graph.d.ts.map +1 -0
  165. package/dist/tools/flow-view-graph.js +993 -0
  166. package/dist/tools/flow-view-graph.js.map +1 -0
  167. package/dist/tools/flow-view-gzip.d.ts +52 -0
  168. package/dist/tools/flow-view-gzip.d.ts.map +1 -0
  169. package/dist/tools/flow-view-gzip.js +179 -0
  170. package/dist/tools/flow-view-gzip.js.map +1 -0
  171. package/dist/tools/flow-view-mermaid.d.ts +37 -0
  172. package/dist/tools/flow-view-mermaid.d.ts.map +1 -0
  173. package/dist/tools/flow-view-mermaid.js +337 -0
  174. package/dist/tools/flow-view-mermaid.js.map +1 -0
  175. package/dist/tools/flow-view-module.d.ts +61 -0
  176. package/dist/tools/flow-view-module.d.ts.map +1 -0
  177. package/dist/tools/flow-view-module.js +378 -0
  178. package/dist/tools/flow-view-module.js.map +1 -0
  179. package/dist/tools/flow-view-policy.d.ts +106 -0
  180. package/dist/tools/flow-view-policy.d.ts.map +1 -0
  181. package/dist/tools/flow-view-policy.js +462 -0
  182. package/dist/tools/flow-view-policy.js.map +1 -0
  183. package/dist/tools/flow-view-renderers.d.ts +68 -0
  184. package/dist/tools/flow-view-renderers.d.ts.map +1 -0
  185. package/dist/tools/flow-view-renderers.js +513 -0
  186. package/dist/tools/flow-view-renderers.js.map +1 -0
  187. package/dist/tools/flow-view-table.d.ts +115 -0
  188. package/dist/tools/flow-view-table.d.ts.map +1 -0
  189. package/dist/tools/flow-view-table.js +1002 -0
  190. package/dist/tools/flow-view-table.js.map +1 -0
  191. package/dist/tools/get-module.d.ts +36 -42
  192. package/dist/tools/get-module.d.ts.map +1 -1
  193. package/dist/tools/health.d.ts +9 -6
  194. package/dist/tools/health.d.ts.map +1 -1
  195. package/dist/tools/incident-journal-module.d.ts +8 -7
  196. package/dist/tools/incident-journal-module.d.ts.map +1 -1
  197. package/dist/tools/index.d.ts +4 -4
  198. package/dist/tools/index.d.ts.map +1 -1
  199. package/dist/tools/index.js +118 -18
  200. package/dist/tools/index.js.map +1 -1
  201. package/dist/tools/markdown.d.ts +27 -0
  202. package/dist/tools/markdown.d.ts.map +1 -1
  203. package/dist/tools/markdown.js +104 -1
  204. package/dist/tools/markdown.js.map +1 -1
  205. package/dist/tools/nl.d.ts +1 -11
  206. package/dist/tools/nl.d.ts.map +1 -1
  207. package/dist/tools/profile.d.ts +1 -1
  208. package/dist/tools/profile.d.ts.map +1 -1
  209. package/dist/tools/profile.js +20 -1
  210. package/dist/tools/profile.js.map +1 -1
  211. package/dist/tools/query-module.d.ts +59 -71
  212. package/dist/tools/query-module.d.ts.map +1 -1
  213. package/dist/tools/query-module.js +28 -7
  214. package/dist/tools/query-module.js.map +1 -1
  215. package/dist/tools/record-write-shared.d.ts.map +1 -1
  216. package/dist/tools/record-write-shared.js +20 -2
  217. package/dist/tools/record-write-shared.js.map +1 -1
  218. package/dist/tools/relationships.d.ts +6 -22
  219. package/dist/tools/relationships.d.ts.map +1 -1
  220. package/dist/tools/result-envelope.d.ts +2255 -1357
  221. package/dist/tools/result-envelope.d.ts.map +1 -1
  222. package/dist/tools/result-envelope.js +24 -2
  223. package/dist/tools/result-envelope.js.map +1 -1
  224. package/dist/tools/schema-module.d.ts +36 -21
  225. package/dist/tools/schema-module.d.ts.map +1 -1
  226. package/dist/tools/schema-module.js +106 -65
  227. package/dist/tools/schema-module.js.map +1 -1
  228. package/dist/tools/script.d.ts +1 -11
  229. package/dist/tools/script.d.ts.map +1 -1
  230. package/dist/tools/syslog.d.ts +11 -18
  231. package/dist/tools/syslog.d.ts.map +1 -1
  232. package/dist/tools/syslog.js +2 -3
  233. package/dist/tools/syslog.js.map +1 -1
  234. package/dist/tools/table-hierarchy.d.ts +35 -0
  235. package/dist/tools/table-hierarchy.d.ts.map +1 -0
  236. package/dist/tools/table-hierarchy.js +74 -0
  237. package/dist/tools/table-hierarchy.js.map +1 -0
  238. package/dist/tools/tool-module.d.ts +40 -15
  239. package/dist/tools/tool-module.d.ts.map +1 -1
  240. package/dist/tools/tool-module.js +755 -205
  241. package/dist/tools/tool-module.js.map +1 -1
  242. package/dist/tools/update-module.d.ts +11 -17
  243. package/dist/tools/update-module.d.ts.map +1 -1
  244. package/dist/tools/update-module.js +10 -12
  245. package/dist/tools/update-module.js.map +1 -1
  246. package/dist/unknown-filter-fields.d.ts +52 -0
  247. package/dist/unknown-filter-fields.d.ts.map +1 -0
  248. package/dist/unknown-filter-fields.js +87 -0
  249. package/dist/unknown-filter-fields.js.map +1 -0
  250. package/dist/version.d.ts +1 -1
  251. package/dist/version.d.ts.map +1 -1
  252. package/dist/version.js +1 -1
  253. package/dist/version.js.map +1 -1
  254. package/dist/write-value-policy.d.ts +20 -12
  255. package/dist/write-value-policy.d.ts.map +1 -1
  256. package/dist/write-value-policy.js +179 -67
  257. package/dist/write-value-policy.js.map +1 -1
  258. package/docs/ADDING-TOOLS.md +22 -13
  259. package/docs/CLIENT-SETUP.md +110 -52
  260. package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +2 -2
  261. package/docs/FLOW-VIEW.md +214 -0
  262. package/docs/PRODUCTION-SECURITY.md +218 -25
  263. package/docs/RELEASE-VALIDATION.md +2 -2
  264. package/docs/TESTING-OAUTH.md +1 -1
  265. package/docs/V2-MIGRATION.md +404 -30
  266. package/package.json +20 -6
  267. package/scripts/release-validate.mjs +56 -0
  268. package/server.json +22 -0
  269. package/tools/inspector/package-lock.json +163 -201
@@ -12,10 +12,10 @@
12
12
  > Sections about profiles, credentials, table access, field policy, and tool
13
13
  > behavior are transport-independent and remain accurate.
14
14
 
15
- This is the shortest complete path from a clean install to two
16
- provider-neutral clients using the same ServiceNow MCP V2 service. The server
17
- exposes Streamable HTTP at `/mcp`; it does not expose stdio and it does not
18
- select a default or active ServiceNow profile.
15
+ This is the shortest complete path from a clean install to a working
16
+ connection. The shipped server speaks stdio only; the Streamable HTTP
17
+ runtime that the later sections describe is dormant. In both cases the server
18
+ does not select a default or active ServiceNow profile.
19
19
 
20
20
  ## Quickstart: zero to a working connection
21
21
 
@@ -42,10 +42,10 @@ Three properties are worth knowing:
42
42
  - **The profile and its table-access rules are written together**, so there is
43
43
  never a window in which a profile exists that denies every call.
44
44
 
45
- Then start the service and verify end to end:
45
+ There is nothing to start. Each registered client spawns its own
46
+ `servicenow-mcp` over stdio. Verify end to end with the same checks setup runs:
46
47
 
47
48
  ```sh
48
- set -a; source ~/.servicenow-mcp/server.env; set +a; servicenow-mcp &
49
49
  servicenow-mcp-setup doctor --profile dev
50
50
  ```
51
51
 
@@ -80,6 +80,25 @@ completeness, credential resolution, table-access rules, and the live endpoint,
80
80
  and prints the exact remedy for anything it finds. It never prints a secret and
81
81
  exits non-zero when a check fails.
82
82
 
83
+ `doctor` never touches the network by default. `doctor --live` also makes one
84
+ bounded authenticated read per profile, so it can tell you whether ServiceNow
85
+ accepts the credential and whether the instance is awake.
86
+
87
+ ### Troubleshooting: "appears to be hibernating"
88
+
89
+ A personal developer instance sleeps when idle and answers every request,
90
+ including the OAuth token request, with an HTML "Instance Hibernating" page and
91
+ HTTP 200. The server reports `The ServiceNow instance <host> appears to be
92
+ hibernating.` with the retry decision "retry later". Wake the instance at
93
+ https://developer.servicenow.com, wait a few minutes, then retry; the server
94
+ does not retry on its own. `servicenow-mcp-setup doctor --live` shows the same
95
+ condition as `Instance hibernating`.
96
+
97
+ If the message instead says `The instance returned an HTML page instead of an
98
+ API response`, the instance may be asleep, behind single sign-on, or under
99
+ maintenance: open the instance URL in a browser to see which. The detection
100
+ inspects only the first 16 K characters of the page and never repeats any of it.
101
+
83
102
  ### What the bootstrap writes
84
103
 
85
104
  | File | Mode | Contents |
@@ -151,7 +170,9 @@ rules. For a **file-backed profile** — anything created with
151
170
  `servicenow-mcp-profile` — those rules live in the profile itself, and
152
171
  `SN_ALLOWED_READ_TABLES` / `SN_ALLOWED_WRITE_TABLES` / `SN_TABLE_ACCESS_TARGETS`
153
172
  in the environment **do not apply**. This is the single most common reason a
154
- freshly installed server answers every call with a policy denial.
173
+ freshly installed server answers every call with a policy denial. Field
174
+ policy also lives on the profile (`fieldPolicy`); with a profile file
175
+ present, a set `SN_FIELD_POLICY_DEFINITIONS` stops the server from starting.
155
176
 
156
177
  ```sh
157
178
  # Reads on two tables, writes on one.
@@ -160,9 +181,12 @@ servicenow-mcp-setup grant --profile dev --read incident,problem --write inciden
160
181
  # Narrow the tools permitted on a target.
161
182
  servicenow-mcp-setup grant --profile dev --read cmdb_ci --tools sn_query,sn_relationships
162
183
 
163
- # A table that extends another must declare the tables it reaches. Related
164
- # tables join the allowlist but get no target of their own, so a caller cannot
165
- # address them directly.
184
+ # Optionally declare the table a target extends. --related adds it, with no
185
+ # target, to the allowlist of every operation change_request has, including one
186
+ # a later grant adds. On its own no tool can then address it, unless such an
187
+ # allowlist is "*"; if it has, or later gets, a target of its own, that
188
+ # target's tools can use those operations on it. Inherited fields are read
189
+ # through change_request itself, so the grant works without --related too.
166
190
  servicenow-mcp-setup grant --profile dev --read change_request --related change_request=task
167
191
 
168
192
  # Inspect the result without writing it.
@@ -171,10 +195,36 @@ servicenow-mcp-setup grant --profile dev --read incident --dry-run
171
195
 
172
196
  Grants are additive; `--replace` discards the existing rules instead. Every
173
197
  grant is validated with the same loader the server uses at request time, so a
174
- rejected policy fails at the CLI rather than at the first tool call. Default
175
- tools are `sn_query,sn_get,sn_aggregate,sn_schema` for a read grant and those
176
- plus `sn_create,sn_update` for a write grant — `sn_delete`, `sn_batch`, and
177
- `sn_atf` are never granted implicitly and must be named with `--tools`.
198
+ rejected policy fails at the CLI rather than at the first tool call.
199
+
200
+ Without `--tools`, each table named with `--read` gets
201
+ `sn_query,sn_get,sn_aggregate,sn_schema`, and each table named with `--write`
202
+ gets `sn_create,sn_update`. A write grant on `incident` also binds
203
+ `sn_incident_add_comment` and `sn_incident_add_work_note`. Comments are
204
+ customer-visible, so a comment the agent appends can notify the incident's
205
+ caller. Defaults apply only to the tables named in that command, never to
206
+ tables the profile already allows or reaches as related tables. A re-grant adds
207
+ the defaults to the tools already on an existing target, so re-running
208
+ `--write incident` on a target you narrowed earlier restores `sn_create` and
209
+ both journal tools. That includes a re-grant made only to add `--related`,
210
+ such as `--write incident --related incident=task`: repeat `--tools` with the
211
+ target's current list to keep it narrow. To withhold the journal tools, pass
212
+ an explicit `--tools` list, such as `--tools sn_create,sn_update`. A grant
213
+ never removes a tool, so on a profile that already has them, use `--replace`
214
+ with `--tools`; `--replace` discards every rule on the profile, so grant its
215
+ other tables again afterwards. `sn_delete`, `sn_batch`, and `sn_atf` are never
216
+ granted implicitly and must be named with `--tools`.
217
+
218
+ A grant decides which tools reach a table; the profile's field policy still
219
+ decides which fields they may write. The journal tools follow it like
220
+ `sn_update` does: if the incident's effective `writable` list, from
221
+ `fieldPolicy.incident.writable` or from a `"*"` entry's `writable`, leaves
222
+ out `comments`, `sn_incident_add_comment` is denied even though the grant
223
+ binds it, and likewise `sn_incident_add_work_note` without `work_notes`.
224
+ Withholding the journal tools does not withhold journals: `sn_create`,
225
+ `sn_update` and `sn_batch` write `comments` and `work_notes` wherever field
226
+ policy allows them. See the
227
+ [field policy reference](../README.md#field-policy).
178
228
 
179
229
  `grant` refuses `*` and rejects anything that is not a valid table name. It
180
230
  does **not** refuse any particular table: `tableAccess` is the sole table-level
@@ -415,7 +465,7 @@ runtime and immutable image. See `CROSS-CLIENT-RELEASE-MATRIX.md`.
415
465
 
416
466
  ## 5. Profile selection, results, and audit evidence
417
467
 
418
- All 23 tools require a non-empty `profile`. Missing, empty, unknown, or invalid
468
+ All 24 tools require a non-empty `profile`. Missing, empty, unknown, or invalid
419
469
  names fail before credentials or a ServiceNow client. There is no default,
420
470
  active, current, selected-session, or switch-profile operation. To work across
421
471
  instances, make separate calls and include the intended name each time:
@@ -456,8 +506,10 @@ otherwise surfaces only as a generic policy denial at call time.
456
506
 
457
507
  ### Unrestricted field selection
458
508
 
459
- `fields=all` and `response_format: "detailed"` resolve to a wildcard selection
460
- and are bounded to at most **100 columns**, resolved from `sys_dictionary`
509
+ `fields=all` and `response_format: "detailed"` resolve to the profile's readable
510
+ set for the table. Where the field policy narrows that set, they request exactly
511
+ the listed fields and read no dictionary rows. Where it is every field, they
512
+ are bounded to at most **100 columns**, resolved from `sys_dictionary`
461
513
  including fields inherited through `super_class`. Ordering is the table's
462
514
  default projection first in declared order, then the remainder alphabetically.
463
515
  `sn_query` reports truncation in its `hint` field; `sn_get` will carry the same
@@ -467,43 +519,48 @@ failed the call outright.
467
519
 
468
520
  Two consequences for callers:
469
521
 
470
- - **Journal fields are returned.** `comments` and `work_notes` are in the
471
- resolved set for `fields=all` and `detailed`, as they are for an explicit
472
- `fields=comments` and for `sn_schema`. The default projection still excludes
473
- them. Journal content on real instances routinely contains customer PII, so
522
+ - **Journal fields are returned** wherever the profile can read them.
523
+ `comments` and `work_notes` are in the resolved set for `fields=all` and
524
+ `detailed`, as they are for an explicit `fields=comments` and for
525
+ `sn_schema`. The default projection still excludes them. Journal content on real instances routinely contains customer PII, so
474
526
  asking for all fields on `incident` returns customer-visible commentary.
475
527
  - **Sensitive-looking names are never requested.** A field whose name matches
476
528
  the sensitive pattern is excluded from the resolved set rather than requested
477
529
  and scrubbed on arrival, so the value does not cross the wire at all.
478
530
 
479
- ### Metadata caching prerequisites
480
-
481
- Caching is per instance *and* credential identity, and it requires a resolvable
482
- session timezone: the freshness probe compares `sys_updated_on`, which
483
- ServiceNow evaluates in the session user's timezone rather than UTC. Resolving
484
- it needs the authenticating account's `user_name` to read `sys_user.time_zone`,
485
- falling back to the `glide.sys.default.tz` property. The profile therefore needs
486
- read access to `sys_user` and `sys_properties` for the lookup to work.
487
-
488
- When the zone cannot be resolved, **caching is disabled for that identity**
489
- rather than falling back to a UTC assumption — a wrong assumption would serve
490
- silently stale metadata for the length of the offset. Because OAuth
491
- client_credentials and API-key profiles carry no username, metadata caching is
492
- disabled for them entirely. Basic auth and the OAuth password grant are
493
- unaffected.
494
-
495
- The practical cost is small and worth stating: the cache only ever saved payload
496
- bytes, never round trips, since a hit still performs one freshness probe. The
497
- loss on an affected profile is bandwidth on `sys_dictionary` reads, not latency.
498
-
499
- Deletions to a cached metadata table become visible within one TTL — 24 hours by
500
- default. The probe detects updates, not deletes, so a deleted row stays served
501
- until its entry expires. Lower the TTL or pass `force_recache: true` when a
502
- deletion must be reflected sooner.
503
-
504
- Incident `comments` and `work_notes` are append-only. Generic `sn_update`
505
- rejects them before credentials/client construction. After separate human
506
- authorization on a disposable non-production incident, use a dedicated tool:
531
+ ### Metadata caching
532
+
533
+ Caching is per instance *and* credential identity, and it works the same in
534
+ every auth mode, including OAuth client_credentials and API key. Freshness is
535
+ checked against a watermark the instance reports: the table's row count and its
536
+ newest row by `sys_updated_on`, read as its stored UTC value. No timezone,
537
+ username, or `sys_user` / `sys_properties` read is involved. The only access it
538
+ needs is the ServiceNow read permission of the user the credential runs as, on
539
+ the cached table; no `tableAccess` change is needed. If a table's watermark
540
+ cannot be used, its reads go straight upstream for a while: 15 minutes for a
541
+ lasting cause such as a 403 or an incomplete watermark, 30 seconds for a 429,
542
+ 5xx, or network failure.
543
+
544
+ The practical saving is payload bytes, never round trips: a hit still performs
545
+ one watermark read, and a miss performs one extra. Within one tool call each
546
+ table's watermark is read once.
547
+
548
+ Inserts, updates, and deletes all move the watermark. An update in the same
549
+ second as the stored watermark, to a row other than the newest, and a write that
550
+ skips the system fields (`autoSysFields(false)`) can go unseen for up to one
551
+ TTL — 24 hours by default. Lower the TTL or pass `force_recache: true` when a
552
+ change must be reflected sooner.
553
+
554
+ `sn_schema` keeps its assembled result for 5 minutes per profile, credential
555
+ identity, and effective policy, without revalidating it. `force_recache: true`
556
+ refreshes it.
557
+
558
+ Incident `comments` and `work_notes` are append-only journal fields. Both
559
+ `sn_update` and the dedicated incident tools can write them, and the
560
+ profile's field policy decides for both routes. For a controlled validation
561
+ write, after separate human authorization on a disposable non-production
562
+ incident, use a dedicated tool, which can only append one entry to one
563
+ incident:
507
564
 
508
565
  ```ts
509
566
  const writeResult = await client.callTool({
@@ -516,8 +573,9 @@ const writeResult = await client.callTool({
516
573
  });
517
574
  ```
518
575
 
519
- The staging policy must grant write access to `incident` and list
520
- `sn_incident_add_comment` on its exact target. A repeated call appends again;
576
+ The staging policy must grant write access to `incident`, list
577
+ `sn_incident_add_comment` on its exact target, and leave `comments` writable
578
+ in its field policy. A repeated call appends again;
521
579
  the operation is intentionally non-idempotent. Do not substitute a generic
522
580
  journal update, production record, unrestricted query, batch, ATF execution,
523
581
  or script.
@@ -659,7 +717,7 @@ have been separately authorized. The current official OpenAI flow is:
659
717
  create a developer-mode app, choose **Tunnel** under **Connection**, and
660
718
  select the associated tunnel. Do not enter a public MCP URL or a second
661
719
  Authorization value in the app.
662
- 4. Scan tools and compare the 23 names, schemas, and annotations with the
720
+ 4. Scan tools and compare the 24 names, schemas, and annotations with the
663
721
  frozen release manifest. Keep the app private and draft-only.
664
722
  5. On every use, name the profile in the request. For example, instruct the
665
723
  app to invoke `sn_query` with these exact non-secret arguments:
@@ -3,7 +3,7 @@
3
3
  This is the release contract for the HTTP MCP surface. A release must expose
4
4
  one immutable server artifact at `/mcp` and pass the same contract through both
5
5
  the official Model Context Protocol SDK client and an independent Fetch
6
- JSON-RPC client. The required production catalog contains exactly 23 tools.
6
+ JSON-RPC client. The required production catalog contains exactly 24 tools.
7
7
  User-facing configuration and examples for both clients are in
8
8
  `docs/CLIENT-SETUP.md`.
9
9
 
@@ -18,7 +18,7 @@ transport.
18
18
  | Contract | Required evidence | Blocking evidence |
19
19
  | --- | --- | --- |
20
20
  | One artifact and endpoint | Both clients initialize, list, and invoke the same runtime at `/mcp`; the container check repeats discovery against one image ID | `test/snsdk-55-release-matrix.test.ts`, `scripts/container-validate.mjs` |
21
- | Exact discovery parity | Both clients return the same sorted 20 tool names, input schemas, output schemas, and annotations; every input schema requires non-empty `profile` | `test/snsdk-55-release-matrix.test.ts`, `test/http-cross-client.test.ts`, `scripts/container-validate.mjs` |
21
+ | Exact discovery parity | Both clients return the same sorted 24 tool names, input schemas, output schemas, and annotations; every input schema requires non-empty `profile` | `test/snsdk-55-release-matrix.test.ts`, `test/http-cross-client.test.ts`, `scripts/container-validate.mjs` |
22
22
  | Profile boundary | Missing and unknown profiles fail before configuration or client construction; `sn_profile` succeeds without ServiceNow access or secret disclosure | `test/snsdk-55-release-matrix.test.ts`, `test/http-cross-client.test.ts`, `scripts/container-validate.mjs` |
23
23
  | Selected-instance isolation | Crossed read/write calls from both clients bind only to the selected profile's fake ServiceNow adapter | `test/snsdk-55-release-matrix.test.ts`, `test/execution-context.test.ts` |
24
24
  | Representative read and controlled write | Each client executes `sn_query` and the dedicated append-only incident journal tool against local fakes | `test/snsdk-55-release-matrix.test.ts`, `test/http-cross-client.test.ts` |
@@ -0,0 +1,214 @@
1
+ # Viewing Flow Designer flows
2
+
3
+ `sn_flow_view` shows one Flow Designer flow or subflow: its trigger, steps,
4
+ branches, loops, error handling and the subflows it calls. It is read-only and
5
+ reads only through the Table API. Every call requires an explicit `profile`.
6
+
7
+ ```json
8
+ { "profile": "pdi", "flow": "Route new incidents", "depth": 2 }
9
+ ```
10
+
11
+ | Argument | Default | Meaning |
12
+ | --- | --- | --- |
13
+ | `flow` | required | A 32-character sys_id, or the flow's exact, case-sensitive name (at most 100 characters). A name that matches more than one flow fails with a conflict: pass the sys_id instead. |
14
+ | `depth` | `1` | `1` shows this flow only. `2` or `3` also expand the subflows it calls, and theirs. |
15
+ | `include_inputs` | `true` | Show step input values. `false` requests no value field from the instance at all. |
16
+ | `format` | `both` | Text output: `both`, `mermaid` or `outline`. The structured graph is always complete. |
17
+ | `max_nodes` | `150` | Most graph nodes returned, 10 to 300, counting the trigger. Steps past the limit collapse into one "more" node. |
18
+ | `max_response_bytes` | `100000` | Byte budget for the whole result, 10,000 to 1,000,000. |
19
+
20
+ ## What it returns
21
+
22
+ - **`structuredContent.data`** is the flow graph: flow headers (root first,
23
+ then each expanded subflow), the trigger, nodes, typed edges (`next`,
24
+ `true`, `false`, `loop_body`, `loop_back`, `parallel`, `error`, `subflow`),
25
+ data pills, flow variables, the limits that were hit and fixed-vocabulary
26
+ warnings. Node ids are generated (`n0` is the trigger), never instance
27
+ data.
28
+ - **The text** holds a headline, a summary table, a Mermaid `flowchart TD`
29
+ diagram and a numbered outline in an untrusted-content block.
30
+
31
+ Branches are drawn the way Flow Designer stores them. The `false` edge of an If
32
+ or Else If enters the next Else If or the Else node, which then leads into its
33
+ own steps. A Try or Top Level Try has an `error` edge into its Catch node. An
34
+ expanded subflow is numbered under its call site (a call at step `3` has steps
35
+ `3.1`, `3.2`, …), its node `depth` counts from its own top level, and the
36
+ outline indents it one level below the call.
37
+
38
+ Flow names, step labels and values are untrusted instance text. Mermaid labels
39
+ are entity-encoded into a closed alphabet, the diagram is built from a fixed
40
+ line grammar, and input values never appear in it. The outline flattens each
41
+ value to one line, so instance text cannot forge outline lines.
42
+
43
+ ## Granting access
44
+
45
+ A profile with no table rules denies every tool call. `sn_flow_view` needs
46
+ **read on all 15 tables** below, all or nothing, and each table's target must
47
+ list `sn_flow_view` in its `tools`, unless the read allowlist is `"*"`:
48
+
49
+ `sys_hub_flow`, `sys_hub_flow_snapshot`, `sys_hub_trigger_instance`,
50
+ `sys_hub_trigger_instance_v2`, `sys_hub_action_instance`,
51
+ `sys_hub_action_instance_v2`, `sys_hub_flow_logic`,
52
+ `sys_hub_flow_logic_instance_v2`, `sys_hub_sub_flow_instance`,
53
+ `sys_hub_sub_flow_instance_v2`, `sys_hub_flow_variable`, `sys_hub_flow_input`,
54
+ `sys_hub_flow_output`, `sys_variable_value`, `var_dictionary`.
55
+
56
+ The setup CLI grants exactly that, bound to `sn_flow_view` alone:
57
+
58
+ ```sh
59
+ servicenow-mcp-setup grant --profile pdi --flows --dry-run
60
+ servicenow-mcp-setup grant --profile pdi --flows
61
+ ```
62
+
63
+ `--flows` adds to existing rules. A table that another grant already binds,
64
+ such as `sys_variable_value` and `var_dictionary` under `--atf`, keeps its
65
+ other tools and gains `sn_flow_view`. No write access is ever granted. Restart
66
+ the MCP client after a profile change.
67
+
68
+ To write the rules by hand, give each table a target like this one:
69
+
70
+ ```json
71
+ { "table": "sys_hub_flow", "kind": "canonical", "tools": ["sn_flow_view"],
72
+ "closureComplete": true, "relatedTables": ["sys_hub_flow"] }
73
+ ```
74
+
75
+ Binding these targets to `sn_flow_view` only keeps `sn_query`, `sn_get` and the
76
+ other generic tools off the flow tables, which hold scripts and configuration.
77
+
78
+ On the instance, the profile's user also needs ServiceNow read access to the
79
+ same tables. Every reported read so far ran as `admin`. Whether a non-admin
80
+ role can read `var_dictionary` and `sys_variable_value` through their ACLs is
81
+ not yet confirmed.
82
+
83
+ ## Field policy
84
+
85
+ Each part of the graph is read from known `(table, field)` pairs, and it is
86
+ shown only when **every** pair it comes from is readable, across both storage
87
+ formats. The same profile therefore shows the same parts whether a flow is
88
+ stored in the older (V1) tables or the `_v2` tables.
89
+
90
+ Structural fields are required. If a profile's field policy hides one, the
91
+ whole call is denied with a message naming the table and field:
92
+
93
+ | Table | Required fields |
94
+ | --- | --- |
95
+ | `sys_hub_flow` | `sys_id`, `name`, `type` |
96
+ | `sys_hub_flow_snapshot` | `sys_id`, `parent_flow` |
97
+ | trigger tables | `sys_id`, `flow` |
98
+ | action and subflow tables | `sys_id`, `flow`, `order`, `ui_id`, `parent_ui_id` (subflow tables also `subflow`) |
99
+ | logic tables | the step fields plus `logic_definition`, `connected_to` |
100
+ | flow variable, input and output tables | `sys_id`, `model`, `element` |
101
+ | `sys_variable_value` | `sys_id`, `document`, `document_key`, `variable` |
102
+ | `var_dictionary` | `sys_id` |
103
+
104
+ Everything else is optional and simply hidden when unreadable. The switches
105
+ that matter most:
106
+
107
+ | To hide | Make unreadable |
108
+ | --- | --- |
109
+ | All input values | Any one of `sys_hub_trigger_instance_v2.trigger_inputs`, `sys_hub_action_instance_v2.values`, `sys_hub_flow_logic_instance_v2.values`, `sys_hub_sub_flow_instance_v2.subflow_inputs` hides that kind of value; `sys_variable_value.value`, `var_dictionary.element` or `var_dictionary.internal_type` hides every kind. Or pass `include_inputs: false`. |
110
+ | Data pill labels | `sys_hub_flow.label_cache` (pills then show their raw `{{token}}`) |
111
+ | Step annotations | `comment` on the action, logic or subflow tables |
112
+ | Flow description | `sys_hub_flow.description` |
113
+ | Flow variables, inputs, outputs | `element`, `label` or `internal_type` on the matching table |
114
+
115
+ Regardless of policy, an input is redacted when its name or label looks
116
+ sensitive (the same check as everywhere else in the server, applied to
117
+ camelCase and spaced forms such as `clientSecret` and `API Key`) or its type
118
+ is `password`, `password2`, `masked` or `encrypted_text`. Script inputs are
119
+ shown as their first line in the outline; the structured graph keeps at most
120
+ 2,000 characters of any value.
121
+
122
+ ### Caveats
123
+
124
+ - **`sys_variable_value` is a system table.** A profile's `"*"` field-policy
125
+ entry does not reach it, so it is not narrowed unless you name it. The ATF
126
+ tools read it too. To hide older (V1) flows' input values, name it:
127
+ `"sys_variable_value": { "readable": ["sys_id", "document", "document_key", "variable", "order"] }`.
128
+ - **`var_dictionary` is needed for V1 values.** `sys_variable_value` has no
129
+ input type, so without `var_dictionary.internal_type` a V1 `password2`
130
+ value could be recognized only by its name. Both `element` and
131
+ `internal_type` are in the sources of every input value, so hiding either
132
+ hides all input values (fail closed); the call itself still succeeds.
133
+ `var_dictionary` is not a system table, so a `"*"` entry narrows it.
134
+ - Logic step titles come from the logic definition's English display name.
135
+ A session in another language shows those steps as generic steps with an
136
+ "unknown logic type" warning.
137
+
138
+ ## Why it never calls Flow Designer's internal API
139
+
140
+ Flow Designer has an internal REST API (`/api/now/processflow/...`) that
141
+ returns a whole flow in one call. `sn_flow_view` never calls it. Its flow GET
142
+ is not read-only: on a developer instance it created a Workflow Studio history
143
+ (version) record for the flow and linked the flow to it. That most likely
144
+ happens once per flow that has no history yet, but a tool that declares
145
+ `readOnlyHint: true` must not change the instance at all, and the API is
146
+ undocumented and can change in any release.
147
+
148
+ Everything the view needs is in the Table API: the step tables, the
149
+ compressed input values (decoded with bounded gzip), `sys_variable_value` for
150
+ older flows and `sys_hub_flow.label_cache` for pill labels. Each read goes
151
+ through the same table and field policy as any other tool, and the code never
152
+ requests the flow version table. Tests assert that no `processflow` path is
153
+ ever requested.
154
+
155
+ ## Limits and size
156
+
157
+ | Limit | Value |
158
+ | --- | --- |
159
+ | Subflows expanded per call | 8 |
160
+ | Response scopes per call | 12 (each holds at most 1 MiB of instance JSON): 2 for the root, 1 per subflow, the rest for retries without input values |
161
+ | Rows read per table and flow | 500 |
162
+ | Logic nesting levels | 16 |
163
+ | Inputs per step | 40 |
164
+ | Characters per value (structured) | 2,000 |
165
+ | Edges | 600 |
166
+
167
+ Each flow is read in one or two batches of requests issued together; the
168
+ server sends at most four requests to an instance at a time. Compressed input
169
+ values are read in their own requests without display values, which would
170
+ repeat them. The root flow's record lookup and its load each run in their own
171
+ response scope, and each subflow (its record and its load) runs in its own;
172
+ at most two subflows of one level load at a time, which keeps the request
173
+ queue short. When a read fails the call, the reads started with it are
174
+ cancelled rather than sent.
175
+
176
+ When a flow is too large for its scope with its input values, it is read
177
+ again without them, in a new scope while any remain, and the result carries
178
+ the warning that input values were left out. A root flow too large even
179
+ without input values is shown as its record only, with a warning; it does not
180
+ fail the call. A subflow that cannot be loaded (missing, denied or too large)
181
+ is marked on its call site and never fails the call. A subflow whose read
182
+ timed out is marked as a timeout, so retrying the call may expand it.
183
+
184
+ Older (V1) steps keep their values in `sys_variable_value`. Those reads are
185
+ paged past the 500-row cap, up to 40 values per step (the most a step shows),
186
+ while the load's response scope has room for another read of the same size;
187
+ past either, the values already read are kept and the result says some
188
+ inputs may be incomplete. The room left is an estimate that does not count
189
+ compressed V2 values read at the same time or the variable definitions read
190
+ afterwards, so an unusual flow can still exceed its scope; it is then read
191
+ again without input values, as above.
192
+
193
+ The result fits `max_response_bytes`. The graph gets about 55% of it and is
194
+ reduced in fixed steps when needed: values cut to 500 then 120 characters,
195
+ then values dropped, then descriptions, annotations and conditions cut to 200
196
+ characters, then steps halved behind a "more" node, then pills and variables
197
+ dropped. The text gets the rest: diagram and full outline, then a shortened
198
+ outline, then the outline alone, then the summary table. Every reduction is
199
+ reported in `limits_hit`.
200
+
201
+ ## How clients show it
202
+
203
+ | Client | What to expect |
204
+ | --- | --- |
205
+ | Clients that read `structuredContent` | The full graph, for their own rendering. |
206
+ | Chat clients that render Markdown with Mermaid support | The diagram drawn, plus the outline. Whether a `mermaid` block is drawn depends on the client and its version. |
207
+ | Terminal clients (Claude Code, Codex CLI) | The Mermaid source and the outline as text. `format: "outline"` saves space; paste the diagram into any Mermaid viewer to draw it. |
208
+
209
+ ## Credit
210
+
211
+ The approach, reading a flow's structure from the `sys_hub_*` tables, nesting
212
+ steps by `parent_ui_id`, relabelling data pills from `label_cache` and
213
+ recognizing compressed values by their gzip prefix, follows the flow
214
+ inspection in Jace Benson's `jsn` ServiceNow CLI. No `jsn` code was copied.