@onlyflows/servicenow-mcp 1.0.0 → 2.1.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.
Files changed (281) hide show
  1. package/.env.example +56 -0
  2. package/CHANGELOG.md +214 -0
  3. package/README.md +939 -101
  4. package/dist/auth.d.ts +88 -0
  5. package/dist/auth.d.ts.map +1 -0
  6. package/dist/auth.js +396 -0
  7. package/dist/auth.js.map +1 -0
  8. package/dist/client.d.ts +111 -17
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/client.js +554 -79
  11. package/dist/client.js.map +1 -1
  12. package/dist/config.d.ts +41 -4
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/config.js +44 -34
  15. package/dist/config.js.map +1 -1
  16. package/dist/encoded-query-policy.d.ts +72 -0
  17. package/dist/encoded-query-policy.d.ts.map +1 -0
  18. package/dist/encoded-query-policy.js +409 -0
  19. package/dist/encoded-query-policy.js.map +1 -0
  20. package/dist/execution-context.d.ts +235 -0
  21. package/dist/execution-context.d.ts.map +1 -0
  22. package/dist/execution-context.js +441 -0
  23. package/dist/execution-context.js.map +1 -0
  24. package/dist/field-policy.d.ts +117 -0
  25. package/dist/field-policy.d.ts.map +1 -0
  26. package/dist/field-policy.js +1684 -0
  27. package/dist/field-policy.js.map +1 -0
  28. package/dist/http-auth.d.ts +131 -0
  29. package/dist/http-auth.d.ts.map +1 -0
  30. package/dist/http-auth.js +347 -0
  31. package/dist/http-auth.js.map +1 -0
  32. package/dist/http-entrypoint.d.ts +26 -0
  33. package/dist/http-entrypoint.d.ts.map +1 -0
  34. package/dist/http-entrypoint.js +255 -0
  35. package/dist/http-entrypoint.js.map +1 -0
  36. package/dist/http-observability.d.ts +147 -0
  37. package/dist/http-observability.d.ts.map +1 -0
  38. package/dist/http-observability.js +711 -0
  39. package/dist/http-observability.js.map +1 -0
  40. package/dist/http-request-policy.d.ts +72 -0
  41. package/dist/http-request-policy.d.ts.map +1 -0
  42. package/dist/http-request-policy.js +463 -0
  43. package/dist/http-request-policy.js.map +1 -0
  44. package/dist/http-request-signal.d.ts +12 -0
  45. package/dist/http-request-signal.d.ts.map +1 -0
  46. package/dist/http-request-signal.js +39 -0
  47. package/dist/http-request-signal.js.map +1 -0
  48. package/dist/http-runtime.d.ts +77 -0
  49. package/dist/http-runtime.d.ts.map +1 -0
  50. package/dist/http-runtime.js +1321 -0
  51. package/dist/http-runtime.js.map +1 -0
  52. package/dist/incident-journal-policy.d.ts +22 -0
  53. package/dist/incident-journal-policy.d.ts.map +1 -0
  54. package/dist/incident-journal-policy.js +115 -0
  55. package/dist/incident-journal-policy.js.map +1 -0
  56. package/dist/index.d.ts +14 -4
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +140 -36
  59. package/dist/index.js.map +1 -1
  60. package/dist/metadata-cache.d.ts +71 -0
  61. package/dist/metadata-cache.d.ts.map +1 -0
  62. package/dist/metadata-cache.js +397 -0
  63. package/dist/metadata-cache.js.map +1 -0
  64. package/dist/profile-admin.d.ts +64 -0
  65. package/dist/profile-admin.d.ts.map +1 -0
  66. package/dist/profile-admin.js +351 -0
  67. package/dist/profile-admin.js.map +1 -0
  68. package/dist/profile-credentials.d.ts +68 -0
  69. package/dist/profile-credentials.d.ts.map +1 -0
  70. package/dist/profile-credentials.js +329 -0
  71. package/dist/profile-credentials.js.map +1 -0
  72. package/dist/profile-manager.d.ts +187 -0
  73. package/dist/profile-manager.d.ts.map +1 -0
  74. package/dist/profile-manager.js +1026 -0
  75. package/dist/profile-manager.js.map +1 -0
  76. package/dist/record-identifier-policy.d.ts +39 -0
  77. package/dist/record-identifier-policy.d.ts.map +1 -0
  78. package/dist/record-identifier-policy.js +203 -0
  79. package/dist/record-identifier-policy.js.map +1 -0
  80. package/dist/runtime-environment.d.ts +23 -0
  81. package/dist/runtime-environment.d.ts.map +1 -0
  82. package/dist/runtime-environment.js +58 -0
  83. package/dist/runtime-environment.js.map +1 -0
  84. package/dist/server.d.ts +33 -0
  85. package/dist/server.d.ts.map +1 -0
  86. package/dist/server.js +73 -0
  87. package/dist/server.js.map +1 -0
  88. package/dist/servicenow-identifiers.d.ts +8 -0
  89. package/dist/servicenow-identifiers.d.ts.map +1 -0
  90. package/dist/servicenow-identifiers.js +22 -0
  91. package/dist/servicenow-identifiers.js.map +1 -0
  92. package/dist/setup-prompts.d.ts +7 -0
  93. package/dist/setup-prompts.d.ts.map +1 -0
  94. package/dist/setup-prompts.js +123 -0
  95. package/dist/setup-prompts.js.map +1 -0
  96. package/dist/setup.d.ts +109 -0
  97. package/dist/setup.d.ts.map +1 -0
  98. package/dist/setup.js +1903 -0
  99. package/dist/setup.js.map +1 -0
  100. package/dist/startup.d.ts +43 -0
  101. package/dist/startup.d.ts.map +1 -0
  102. package/dist/startup.js +75 -0
  103. package/dist/startup.js.map +1 -0
  104. package/dist/stdio-runtime.d.ts +106 -0
  105. package/dist/stdio-runtime.d.ts.map +1 -0
  106. package/dist/stdio-runtime.js +231 -0
  107. package/dist/stdio-runtime.js.map +1 -0
  108. package/dist/structured-query.d.ts +187 -0
  109. package/dist/structured-query.d.ts.map +1 -0
  110. package/dist/structured-query.js +503 -0
  111. package/dist/structured-query.js.map +1 -0
  112. package/dist/table-defaults.d.ts +28 -0
  113. package/dist/table-defaults.d.ts.map +1 -0
  114. package/dist/table-defaults.js +85 -0
  115. package/dist/table-defaults.js.map +1 -0
  116. package/dist/table-policy.d.ts +71 -0
  117. package/dist/table-policy.d.ts.map +1 -0
  118. package/dist/table-policy.js +290 -0
  119. package/dist/table-policy.js.map +1 -0
  120. package/dist/tool-error.d.ts +48 -0
  121. package/dist/tool-error.d.ts.map +1 -0
  122. package/dist/tool-error.js +139 -0
  123. package/dist/tool-error.js.map +1 -0
  124. package/dist/tool-table-access.d.ts +19 -0
  125. package/dist/tool-table-access.d.ts.map +1 -0
  126. package/dist/tool-table-access.js +388 -0
  127. package/dist/tool-table-access.js.map +1 -0
  128. package/dist/tools/aggregate.d.ts +22 -42
  129. package/dist/tools/aggregate.d.ts.map +1 -1
  130. package/dist/tools/aggregate.js +103 -47
  131. package/dist/tools/aggregate.js.map +1 -1
  132. package/dist/tools/all-fields-cap.d.ts +45 -0
  133. package/dist/tools/all-fields-cap.d.ts.map +1 -0
  134. package/dist/tools/all-fields-cap.js +151 -0
  135. package/dist/tools/all-fields-cap.js.map +1 -0
  136. package/dist/tools/atf.d.ts +21 -60
  137. package/dist/tools/atf.d.ts.map +1 -1
  138. package/dist/tools/atf.js +180 -116
  139. package/dist/tools/atf.js.map +1 -1
  140. package/dist/tools/attach.d.ts +31 -45
  141. package/dist/tools/attach.d.ts.map +1 -1
  142. package/dist/tools/attach.js +175 -137
  143. package/dist/tools/attach.js.map +1 -1
  144. package/dist/tools/batch.d.ts +78 -42
  145. package/dist/tools/batch.d.ts.map +1 -1
  146. package/dist/tools/batch.js +172 -68
  147. package/dist/tools/batch.js.map +1 -1
  148. package/dist/tools/catalog.d.ts +6 -0
  149. package/dist/tools/catalog.d.ts.map +1 -0
  150. package/dist/tools/catalog.js +203 -0
  151. package/dist/tools/catalog.js.map +1 -0
  152. package/dist/tools/codesearch.d.ts +14 -25
  153. package/dist/tools/codesearch.d.ts.map +1 -1
  154. package/dist/tools/codesearch.js +60 -48
  155. package/dist/tools/codesearch.js.map +1 -1
  156. package/dist/tools/create-module.d.ts +48 -0
  157. package/dist/tools/create-module.d.ts.map +1 -0
  158. package/dist/tools/create-module.js +98 -0
  159. package/dist/tools/create-module.js.map +1 -0
  160. package/dist/tools/create.d.ts +2 -38
  161. package/dist/tools/create.d.ts.map +1 -1
  162. package/dist/tools/create.js +9 -41
  163. package/dist/tools/create.js.map +1 -1
  164. package/dist/tools/delete.d.ts +13 -23
  165. package/dist/tools/delete.d.ts.map +1 -1
  166. package/dist/tools/delete.js +30 -33
  167. package/dist/tools/delete.js.map +1 -1
  168. package/dist/tools/discover.d.ts +15 -27
  169. package/dist/tools/discover.d.ts.map +1 -1
  170. package/dist/tools/discover.js +103 -60
  171. package/dist/tools/discover.js.map +1 -1
  172. package/dist/tools/get-module.d.ts +85 -0
  173. package/dist/tools/get-module.d.ts.map +1 -0
  174. package/dist/tools/get-module.js +221 -0
  175. package/dist/tools/get-module.js.map +1 -0
  176. package/dist/tools/get.d.ts +2 -51
  177. package/dist/tools/get.d.ts.map +1 -1
  178. package/dist/tools/get.js +9 -49
  179. package/dist/tools/get.js.map +1 -1
  180. package/dist/tools/handler-result.d.ts +14 -0
  181. package/dist/tools/handler-result.d.ts.map +1 -0
  182. package/dist/tools/handler-result.js +177 -0
  183. package/dist/tools/handler-result.js.map +1 -0
  184. package/dist/tools/health.d.ts +12 -15
  185. package/dist/tools/health.d.ts.map +1 -1
  186. package/dist/tools/health.js +55 -36
  187. package/dist/tools/health.js.map +1 -1
  188. package/dist/tools/incident-journal-module.d.ts +12 -0
  189. package/dist/tools/incident-journal-module.d.ts.map +1 -0
  190. package/dist/tools/incident-journal-module.js +61 -0
  191. package/dist/tools/incident-journal-module.js.map +1 -0
  192. package/dist/tools/index.d.ts +47 -36
  193. package/dist/tools/index.d.ts.map +1 -1
  194. package/dist/tools/index.js +814 -35
  195. package/dist/tools/index.js.map +1 -1
  196. package/dist/tools/nl.d.ts +10 -24
  197. package/dist/tools/nl.d.ts.map +1 -1
  198. package/dist/tools/nl.js +37 -147
  199. package/dist/tools/nl.js.map +1 -1
  200. package/dist/tools/profile.d.ts +37 -0
  201. package/dist/tools/profile.d.ts.map +1 -0
  202. package/dist/tools/profile.js +39 -0
  203. package/dist/tools/profile.js.map +1 -0
  204. package/dist/tools/query-module.d.ts +119 -0
  205. package/dist/tools/query-module.d.ts.map +1 -0
  206. package/dist/tools/query-module.js +324 -0
  207. package/dist/tools/query-module.js.map +1 -0
  208. package/dist/tools/query.d.ts +2 -72
  209. package/dist/tools/query.d.ts.map +1 -1
  210. package/dist/tools/query.js +8 -72
  211. package/dist/tools/query.js.map +1 -1
  212. package/dist/tools/record-write-shared.d.ts +7 -0
  213. package/dist/tools/record-write-shared.d.ts.map +1 -0
  214. package/dist/tools/record-write-shared.js +65 -0
  215. package/dist/tools/record-write-shared.js.map +1 -0
  216. package/dist/tools/relationships.d.ts +21 -42
  217. package/dist/tools/relationships.d.ts.map +1 -1
  218. package/dist/tools/relationships.js +70 -56
  219. package/dist/tools/relationships.js.map +1 -1
  220. package/dist/tools/result-envelope.d.ts +603 -0
  221. package/dist/tools/result-envelope.d.ts.map +1 -0
  222. package/dist/tools/result-envelope.js +770 -0
  223. package/dist/tools/result-envelope.js.map +1 -0
  224. package/dist/tools/schema-module.d.ts +64 -0
  225. package/dist/tools/schema-module.d.ts.map +1 -0
  226. package/dist/tools/schema-module.js +367 -0
  227. package/dist/tools/schema-module.js.map +1 -0
  228. package/dist/tools/schema.d.ts +2 -37
  229. package/dist/tools/schema.d.ts.map +1 -1
  230. package/dist/tools/schema.js +6 -57
  231. package/dist/tools/schema.js.map +1 -1
  232. package/dist/tools/script.d.ts +33 -27
  233. package/dist/tools/script.d.ts.map +1 -1
  234. package/dist/tools/script.js +43 -37
  235. package/dist/tools/script.js.map +1 -1
  236. package/dist/tools/syslog.d.ts +19 -46
  237. package/dist/tools/syslog.d.ts.map +1 -1
  238. package/dist/tools/syslog.js +101 -67
  239. package/dist/tools/syslog.js.map +1 -1
  240. package/dist/tools/tool-module.d.ts +143 -0
  241. package/dist/tools/tool-module.d.ts.map +1 -0
  242. package/dist/tools/tool-module.js +1095 -0
  243. package/dist/tools/tool-module.js.map +1 -0
  244. package/dist/tools/update-module.d.ts +51 -0
  245. package/dist/tools/update-module.d.ts.map +1 -0
  246. package/dist/tools/update-module.js +111 -0
  247. package/dist/tools/update-module.js.map +1 -0
  248. package/dist/tools/update.d.ts +2 -45
  249. package/dist/tools/update.d.ts.map +1 -1
  250. package/dist/tools/update.js +9 -41
  251. package/dist/tools/update.js.map +1 -1
  252. package/dist/utils.d.ts +68 -1
  253. package/dist/utils.d.ts.map +1 -1
  254. package/dist/utils.js +114 -16
  255. package/dist/utils.js.map +1 -1
  256. package/dist/version.d.ts +10 -0
  257. package/dist/version.d.ts.map +1 -0
  258. package/dist/version.js +13 -0
  259. package/dist/version.js.map +1 -0
  260. package/dist/write-value-policy.d.ts +56 -0
  261. package/dist/write-value-policy.d.ts.map +1 -0
  262. package/dist/write-value-policy.js +310 -0
  263. package/dist/write-value-policy.js.map +1 -0
  264. package/docs/ADDING-TOOLS.md +227 -0
  265. package/docs/CLIENT-SETUP.md +914 -0
  266. package/docs/CONTAINER-DEPLOYMENT.md +310 -0
  267. package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +63 -0
  268. package/docs/ENTERPRISE-RELEASE-BOUNDARY.md +149 -0
  269. package/docs/OPERATIONS-RUNBOOK.md +383 -0
  270. package/docs/PRIVATE-CHATGPT-CONNECTIVITY.md +347 -0
  271. package/docs/PRODUCTION-SECURITY.md +368 -0
  272. package/docs/PROFILE-CREDENTIALS.md +126 -0
  273. package/docs/RELEASE-VALIDATION.md +140 -0
  274. package/docs/TESTING-OAUTH.md +101 -0
  275. package/docs/V2-MIGRATION.md +493 -0
  276. package/package.json +60 -13
  277. package/scripts/inspector.mjs +140 -0
  278. package/scripts/release-validate.mjs +201 -0
  279. package/scripts/smoke-test.mjs +274 -0
  280. package/tools/inspector/package-lock.json +3812 -0
  281. package/tools/inspector/package.json +12 -0
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <!-- Logo placeholder -->
4
4
  <!-- ![ServiceNow MCP Server](banner.png) -->
5
5
 
6
- **The most comprehensive ServiceNow MCP server.** 17 tools for full CRUD, CMDB graph traversal, background scripts, ATF testing, and more.
6
+ **The most comprehensive ServiceNow MCP server.** 19 tools for full CRUD, append-only incident journals, CMDB graph traversal, ATF testing, multi-instance profiles, and more.
7
7
 
8
8
  Built by [OnlyFlows](https://onlyflows.tech) · Published by [@onlyflowstech](https://github.com/onlyflowstech)
9
9
 
@@ -12,114 +12,580 @@ Built by [OnlyFlows](https://onlyflows.tech) · Published by [@onlyflowstech](ht
12
12
 
13
13
  ---
14
14
 
15
- ## Why This MCP Server?
16
15
 
17
- Most ServiceNow MCP integrations are **read-only** and support a handful of tables. This one gives your AI assistant **full access** to the ServiceNow platform:
16
+ ## Installation
18
17
 
19
- | Feature | Others | @onlyflows/servicenow-mcp |
20
- |---------|--------|--------------------------|
21
- | Query records | ✅ | ✅ |
22
- | Create records | ❌ | ✅ |
23
- | Update records | ❌ | ✅ |
24
- | Delete records | ❌ | ✅ (with safety confirm) |
25
- | Bulk operations | ❌ | ✅ (dry-run by default) |
26
- | Aggregations (COUNT/AVG/MIN/MAX/SUM) | ❌ | ✅ |
27
- | Table schema introspection | ❌ | ✅ |
28
- | CMDB relationship traversal | ❌ | ✅ (recursive, configurable depth) |
29
- | Instance health monitoring | ❌ | ✅ (version, nodes, jobs, stats) |
30
- | Attachment management | ❌ | ✅ (list, upload, download) |
31
- | System log queries | ❌ | ✅ |
32
- | Code search across artifacts | ❌ | ✅ |
33
- | Table/app/plugin discovery | ❌ | ✅ |
34
- | ATF test execution | ❌ | ✅ |
35
- | Natural language interface | ❌ | ✅ |
36
- | Background scripts | ❌ | ✅ (with Playwright) |
37
- | **Total tools** | **1–3** | **17** |
18
+ ```bash
19
+ npm install -g @onlyflows/servicenow-mcp
20
+ servicenow-mcp-setup
21
+ ```
38
22
 
39
- ---
23
+ Run bare on a terminal, `servicenow-mcp-setup` walks you through the whole
24
+ thing in one command: it generates the local auth material, asks for your
25
+ instance and credential, **verifies that credential against the instance**,
26
+ asks which tables to grant, writes the profile, and registers any supported
27
+ client whose CLI is installed. The credential is entered at a hidden prompt —
28
+ never an argument, never shell history — and nothing is written to the profile
29
+ until the instance has accepted it, so a typo or a wrong password leaves
30
+ nothing behind.
40
31
 
41
- ## Quick Start
32
+ ```
33
+ ServiceNow MCP setup
34
+
35
+ This walks through one ServiceNow connection end to end. Nothing is
36
+ written to the profile until your credential is verified against the
37
+ instance. Press Ctrl+C at any point to stop; nothing will be saved.
38
+
39
+ Profile name [dev]: dev
40
+ ServiceNow instance (for example dev12345.service-now.com): dev12345.service-now.com
41
+ Authentication:
42
+ 1) basic (default)
43
+ 2) oauth
44
+ 3) apikey
45
+ Choice [1]: 1
46
+ How should the credential be stored?:
47
+ 1) encrypted (default)
48
+ 2) reference
49
+ Choice [1]: 1
50
+ ServiceNow username: integration.user
51
+
52
+ Enter each secret now. Input is hidden — nothing you type from here
53
+ is displayed.
54
+ credential:
55
+
56
+ Verifying against the instance...
57
+ ok https://dev12345.service-now.com accepted the credential.
58
+
59
+ Table access is deny-by-default: a profile with no rules denies every
60
+ tool call. Grant the narrowest set that does the job; you can add more
61
+ later with servicenow-mcp-setup grant.
62
+
63
+ Tables to allow for READS:
64
+ 1) Just incident (default)
65
+ 2) Common ITSM set (incident,change_request,problem,task,sys_user)
66
+ 3) All tables (*)
67
+ 4) Enter a custom list
68
+ 5) None
69
+ Choice [1]: 1
70
+
71
+ Tables to allow for WRITES:
72
+ 1) Just incident
73
+ 2) Common ITSM set (incident,change_request,problem,task,sys_user)
74
+ 3) All tables (*)
75
+ 4) Enter a custom list
76
+ 5) None (default)
77
+ Choice [5]: 1
78
+
79
+ Wrote profile dev.
80
+
81
+ Register this server with codex and claude-code? [Y/n]: y
82
+
83
+ ServiceNow MCP doctor
84
+
85
+ ok node: v22.11.0
86
+ ok server command: servicenow-mcp resolves on PATH; clients spawn it over stdio
87
+ ok config directory: ~/.servicenow-mcp (0700)
88
+ ok profile dev: instance: https://dev12345.service-now.com
89
+ ok profile dev: credential: basic credential resolves from its encrypted source
90
+ ok profile dev: table access: 1 read, 1 write, 1 target(s)
91
+
92
+ All checks passed.
93
+
94
+ Setup complete.
95
+
96
+ Profile dev
97
+ Reads incident
98
+ Writes incident
99
+ Transport stdio (each client spawns its own servicenow-mcp)
100
+ Clients codex, claude-code
101
+
102
+ Start codex or claude-code and it will launch the server itself.
103
+ There is nothing to keep running between sessions.
104
+ ```
42
105
 
43
- ### Claude Desktop
106
+ There is nothing to start. The server speaks **stdio**: each registered client
107
+ spawns its own copy of `servicenow-mcp` on demand and talks to it over that
108
+ process's stdin and stdout. Setup finishes by running the same checks `doctor`
109
+ runs, so you can re-run them any time:
110
+
111
+ ```bash
112
+ servicenow-mcp-setup doctor --profile dev
113
+ ```
114
+
115
+ `npx @onlyflows/servicenow-mcp@latest setup` runs the same wizard without a
116
+ global install, and `servicenow-mcp setup` is an alias for
117
+ `servicenow-mcp-setup`.
118
+
119
+ ### Scripted setup
120
+
121
+ Pass any flag, or run without a terminal, and the wizard steps aside for the
122
+ original non-interactive behavior — so CI and provisioning scripts are
123
+ unaffected. `--non-interactive` forces it explicitly:
124
+
125
+ ```bash
126
+ servicenow-mcp-setup --non-interactive --clients none --json
127
+ servicenow-mcp-profile create --name dev --instance https://yourinstance.service-now.com \
128
+ --auth-type oauth --client-id <client-id> --source reference --provider env
129
+ servicenow-mcp-setup grant --profile dev --read incident,problem --write incident
130
+ ```
44
131
 
45
- Add to your `claude_desktop_config.json`:
132
+ ### The `servicenow-mcp-setup` commands
133
+
134
+ | Command | Purpose |
135
+ |---------|---------|
136
+ | `servicenow-mcp-setup` | Generate local auth material and register supported clients |
137
+ | `servicenow-mcp-setup client --client <name>` | Print copy-pasteable config for a client |
138
+ | `servicenow-mcp-setup grant --profile <name> --read <tables>` | Add table access rules to a profile |
139
+ | `servicenow-mcp-setup doctor` | Diagnose the install and print remedies |
140
+
141
+ `--force` regenerates the owner/client identifiers but deliberately preserves
142
+ `SN_PROFILE_ENCRYPTION_KEY`, which decrypts every credential envelope in
143
+ `config.json`. Add `--help` to any command for its full options.
144
+
145
+ > **The server runs as you, and the client list is the boundary.** Nothing
146
+ > listens on a port, so nothing off this machine can reach it and no web page
147
+ > can drive it. What that leaves is the registration: every MCP client
148
+ > registered here can spawn the server and use whatever ServiceNow access your
149
+ > profiles grant, as your integration account. Keep the grants narrow, and
150
+ > remove a client you no longer use with `claude mcp remove servicenow-mcp` or
151
+ > `codex mcp remove servicenow-mcp`. No ServiceNow credential is copied into a
152
+ > client's configuration file — the spawned server reads the profile and its
153
+ > encryption key from the owner-only `~/.servicenow-mcp` directory.
154
+
155
+ ### Connecting a client
156
+
157
+ `servicenow-mcp-setup` registers Codex and Claude Code automatically when their
158
+ CLI is on `PATH`. For everything else:
159
+
160
+ ```bash
161
+ servicenow-mcp-setup client --client claude-desktop
162
+ servicenow-mcp-setup client --client all
163
+ ```
164
+
165
+ Every supported client speaks stdio natively, so each one is configured the
166
+ same way: a command to spawn.
167
+
168
+ ```bash
169
+ claude mcp add servicenow-mcp -- servicenow-mcp
170
+ codex mcp add servicenow-mcp -- servicenow-mcp
171
+ ```
172
+
173
+ stdio is the default transport for both CLIs, so there is no transport flag to
174
+ pass. For clients configured by file:
46
175
 
47
176
  ```json
48
177
  {
49
178
  "mcpServers": {
50
- "servicenow": {
51
- "command": "npx",
52
- "args": ["-y", "@onlyflows/servicenow-mcp"],
53
- "env": {
54
- "SN_INSTANCE": "https://yourinstance.service-now.com",
55
- "SN_USER": "your_username",
56
- "SN_PASSWORD": "your_password"
57
- }
58
- }
179
+ "servicenow-mcp": { "command": "servicenow-mcp", "args": [] }
59
180
  }
60
181
  }
61
182
  ```
62
183
 
63
- ### Cursor
184
+ | Client | Configured by | Config location |
185
+ |--------|---------------|-----------------|
186
+ | Claude Code | `claude mcp add` or `.mcp.json` | project or `--scope user` |
187
+ | Codex | `codex mcp add` or `config.toml` | `~/.codex/config.toml` |
188
+ | Cursor | file | `~/.cursor/mcp.json` or `.cursor/mcp.json` |
189
+ | VS Code | file (`"type": "stdio"`) | `.vscode/mcp.json` or user `mcp.json` |
190
+ | Claude Desktop | file | `claude_desktop_config.json` |
191
+ | Windsurf | file | `~/.codeium/windsurf/mcp_config.json` |
192
+
193
+ No client holds a ServiceNow credential. The spawned server resolves its own
194
+ from `~/.servicenow-mcp`, which is owner-only.
195
+
196
+ Full per-client blocks are in
197
+ [V2 service and client setup](docs/CLIENT-SETUP.md#7-mcp-client-configuration).
198
+
199
+ > **`servicenow-mcp` must be on the spawning client's `PATH`.** A global npm
200
+ > install puts it there. If it is not — a project-local install, or a GUI
201
+ > client with a different `PATH` — register the absolute entrypoint instead;
202
+ > `servicenow-mcp-setup doctor` checks this and prints the exact command.
203
+
204
+ ### Guided profile creation from your client
205
+
206
+ After the bootstrap, a connected MCP client can walk you through profile
207
+ creation:
208
+
209
+ ```text
210
+ Add a ServiceNow MCP profile for https://yourinstance.service-now.com
211
+ ```
212
+
213
+ The MCP prompt is `servicenow-mcp.add-profile`. It guides profile naming, auth
214
+ mode, and least-privilege default-deny access, and deliberately does **not**
215
+ ask you to paste passwords, API keys, bearer tokens, OAuth client secrets, or
216
+ encryption keys into chat.
217
+
218
+ ### What gets installed
219
+
220
+ - `servicenow-mcp` — the MCP server itself, spawned by a client over stdio
221
+ - `servicenow-mcp-profile` — manages profile credentials out of band
222
+ - `servicenow-mcp-setup` — bootstrap, client config, grants, and diagnosis
223
+
224
+ ### Manual configuration without the bootstrap
225
+
226
+ The server keeps configuration explicit. A manual run needs:
227
+
228
+ - audit identity: `MCP_OWNER_ID` and `MCP_CLIENT_ID` (optional; they label
229
+ audit records and default to `local-owner`/`local-client`)
230
+ - one named ServiceNow profile, either in `~/.servicenow-mcp/config.json` or
231
+ through `SN_PROFILE_NAME` + `SN_INSTANCE` + auth-specific `SN_*` variables
232
+ - per-profile table access rules; unconfigured access denies everything
233
+
234
+ The `SN_*` environment path builds a profile **only when
235
+ `~/.servicenow-mcp/config.json` does not exist**. Once you create a profile
236
+ file, `SN_ALLOWED_READ_TABLES`, `SN_ALLOWED_WRITE_TABLES`, and
237
+ `SN_TABLE_ACCESS_TARGETS` stop applying and the rules must live on the profile
238
+ (`servicenow-mcp-setup grant`). This is the most common cause of a server that
239
+ denies every call; `servicenow-mcp-setup doctor` detects it.
64
240
 
65
- Add to your Cursor MCP settings (`.cursor/mcp.json`):
241
+ The server reads `~/.servicenow-mcp/server.env` itself at startup, because the
242
+ client that spawns it supplies its own environment and will not have sourced
243
+ anything. A value already present in the environment always wins over that
244
+ file, so container and CI configuration is unaffected.
245
+
246
+ For a quick environment-only run with no profile file — driving the server by
247
+ hand over a pipe, or from a client that passes environment variables — inject
248
+ protected values from your keychain or secret manager and pass only non-secret
249
+ values on the command line:
250
+
251
+ ```bash
252
+ MCP_OWNER_ID=local-owner \
253
+ MCP_CLIENT_ID=local-client \
254
+ SN_PROFILE_NAME=dev \
255
+ SN_INSTANCE=https://yourinstance.service-now.com \
256
+ SN_USER=your_user \
257
+ SN_ALLOWED_READ_TABLES=incident,problem,change_request \
258
+ SN_ALLOWED_WRITE_TABLES=incident,change_request \
259
+ SN_TABLE_ACCESS_TARGETS='[{"table":"incident","kind":"canonical","tools":["sn_query","sn_get","sn_create","sn_update","sn_incident_add_comment","sn_incident_add_work_note","sn_delete","sn_batch"],"closureComplete":true,"relatedTables":["incident"]},{"table":"problem","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["problem"]},{"table":"change_request","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["change_request"]}]' \
260
+ servicenow-mcp
261
+ ```
262
+
263
+ Do not put `SN_PASSWORD`, OAuth client secrets, or API keys in command history.
264
+ Inject them into the server's environment from your approved secret mechanism,
265
+ or leave them in the owner-only profile file where the server can resolve them
266
+ without any client seeing them.
267
+
268
+ ### Source install for development
269
+
270
+ Use source install only for development or unreleased changes:
271
+
272
+ ```bash
273
+ git clone https://github.com/onlyflowstech/servicenow-mcp.git
274
+ cd servicenow-mcp
275
+ npm install
276
+ npm run build
277
+ npm start
278
+ ```
279
+
280
+ For local development with a rebuild and source maps:
281
+
282
+ ```bash
283
+ npm run dev
284
+ ```
285
+
286
+ Container deployment applies to the dormant HTTP transport rather than a 2.0 stdio install; see [Production container deployment](docs/CONTAINER-DEPLOYMENT.md) and the [enterprise boundary](docs/ENTERPRISE-RELEASE-BOUNDARY.md#the-dormant-http-transport).
287
+
288
+ ---
289
+
290
+ ## Multi-Instance Profiles
291
+
292
+ Manage multiple ServiceNow instances (dev, test, prod, PDI) with named profiles. Every tool call must select one configured profile explicitly; V2 has no active-profile or default-profile fallback.
293
+
294
+ ### Setup
295
+
296
+ Create profiles with the CLI rather than by hand — it captures credentials
297
+ without putting them in argv, and it writes the file with the right ownership
298
+ and mode:
299
+
300
+ ```bash
301
+ servicenow-mcp-profile create --name dev --instance https://mydev.service-now.com --auth-type basic --username admin --source reference --provider env
302
+ servicenow-mcp-profile create --name prod --instance https://myprod.service-now.com --auth-type basic --username api.user --source reference --provider env
303
+
304
+ servicenow-mcp-setup grant --profile dev --read incident,problem --write incident
305
+ servicenow-mcp-setup grant --profile prod --read incident
306
+ ```
307
+
308
+ The resulting `~/.servicenow-mcp/config.json` looks like this. Note
309
+ `tableAccess`: **a profile without it denies every tool call.**
66
310
 
67
311
  ```json
68
312
  {
69
- "mcpServers": {
70
- "servicenow": {
71
- "command": "npx",
72
- "args": ["-y", "@onlyflows/servicenow-mcp"],
73
- "env": {
74
- "SN_INSTANCE": "https://yourinstance.service-now.com",
75
- "SN_USER": "your_username",
76
- "SN_PASSWORD": "your_password"
313
+ "version": 2,
314
+ "profiles": {
315
+ "dev": {
316
+ "instance": "https://mydev.service-now.com",
317
+ "username": "admin",
318
+ "credential": { "type": "secret_ref", "provider": "env", "reference": "SN_PASSWORD_DEV" },
319
+ "description": "Development instance",
320
+ "tableAccess": {
321
+ "readTables": ["incident", "problem"],
322
+ "writeTables": ["incident"],
323
+ "targets": [
324
+ {
325
+ "table": "incident",
326
+ "kind": "canonical",
327
+ "tools": ["sn_query", "sn_get", "sn_aggregate", "sn_schema", "sn_create", "sn_update"],
328
+ "closureComplete": true,
329
+ "relatedTables": ["incident"]
330
+ },
331
+ {
332
+ "table": "problem",
333
+ "kind": "canonical",
334
+ "tools": ["sn_query", "sn_get", "sn_aggregate", "sn_schema"],
335
+ "closureComplete": true,
336
+ "relatedTables": ["problem"]
337
+ }
338
+ ]
77
339
  }
78
340
  }
79
341
  }
80
342
  }
81
343
  ```
82
344
 
83
- ### Windsurf
345
+ Have the approved supervisor, orchestrator, keychain, or secret manager provide
346
+ the values referenced by `SN_PASSWORD_DEV` and `SN_PASSWORD_PROD` in the
347
+ environment the server is spawned with, or in `~/.servicenow-mcp/server.env`,
348
+ which the server falls back to. Do not type either value into a shell command,
349
+ command argument, dotenv file, or command history.
350
+
351
+ Each `targets` entry asserts `closureComplete: true`, meaning `relatedTables`
352
+ lists every backing, ancestor, and descendant table the operation can reach.
353
+ When a table extends another, declare it:
354
+ `servicenow-mcp-setup grant --profile dev --read change_request --related change_request=task`.
355
+ Related tables join the allowlist but get no target of their own, so a caller
356
+ cannot address them directly.
357
+
358
+ ### Credential Options
359
+
360
+ | Format | Example | Description |
361
+ |--------|---------|-------------|
362
+ | Legacy environment reference | `"env:SN_PASSWORD_DEV"` | Read-compatible V1 form; migrated to a structured reference on the next write |
363
+ | Secret reference | `{"type":"secret_ref","provider":"env","reference":"SN_PASSWORD_DEV"}` | Provider-neutral reference resolved only for the selected request |
364
+ | Encrypted envelope | `{"type":"encrypted","version":1,...}` | AES-256-GCM value created by the protected administration CLI |
365
+
366
+ Plaintext profile secrets are rejected. Use the installed `servicenow-mcp-profile`
367
+ operator command to create, inspect, rotate, or remove profiles; it reads secrets
368
+ through a protected prompt or bounded standard input and rejects credential-bearing
369
+ command-line arguments. Encrypted sources require exactly 32 random bytes encoded
370
+ as base64 or base64url in `SN_PROFILE_ENCRYPTION_KEY`, supplied separately by the
371
+ deployment secret mechanism and never stored in the profile file. See the
372
+ [profile credential and administration guide](docs/PROFILE-CREDENTIALS.md).
373
+
374
+ The legacy `env:VAR_NAME` indirection remains readable for every secret field:
375
+ `credential`, `clientSecret`, and `apiKey`.
376
+
377
+ ### Using Profiles
378
+
379
+ Pass the `profile` parameter on every tool call:
380
+
381
+ - *"query incidents on prod"* — calls `sn_query` with `profile: "prod"`
382
+ - *"get incident INC0010001 on dev"* — calls `sn_get` with `profile: "dev"`
383
+ - *"show me the dev profile endpoint"* — calls the read-only `sn_profile` diagnostic with `profile: "dev"`
384
+
385
+ Profiles are created and changed out of band by the service operator. Legacy
386
+ `default_profile` metadata is ignored and is not persisted on the next
387
+ administrative write; the MCP boundary never consults it.
388
+
389
+ ### `SN_*` configuration compatibility
84
390
 
85
- Add to your Windsurf MCP configuration:
391
+ If no config file exists, canonical `SN_*` connection values are exposed only
392
+ through an explicit `SN_PROFILE_NAME` mapping. For example, set
393
+ `SN_PROFILE_NAME=dev` with `SN_INSTANCE`, `SN_USER`, and `SN_PASSWORD`, then
394
+ call tools with `profile: "dev"`. Without `SN_PROFILE_NAME`, bare connection
395
+ variables create no profile and cannot route a request. Secret values remain
396
+ runtime-only environment references and are never persisted as plaintext.
397
+
398
+ ---
399
+
400
+ ## Authentication
401
+
402
+ Three ServiceNow auth types are available per profile, selected with `authType` (default: `basic`). Profile configuration is managed out of band by the service operator. This is the only authentication involved: the transport is stdio, so there is no endpoint in front of the server to protect.
403
+
404
+ > **Heads up:** ServiceNow's [inbound Basic Auth restriction program](https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB3096078) is phasing out basic auth for API requests — instances can start hard-rejecting it at any time (exemptions: Web-Service-Access-Only accounts or the `snc_basic_auth_api_access` role). **OAuth is the recommended auth type.** The server prints a startup warning for basic-auth profiles.
405
+
406
+ ### OAuth 2.0 (recommended)
407
+
408
+ `client_credentials` grant (default) — create an OAuth API endpoint client in ServiceNow (**System OAuth → Application Registry**) and reference the secret via `env:` indirection:
86
409
 
87
410
  ```json
88
411
  {
89
- "mcpServers": {
90
- "servicenow": {
91
- "command": "npx",
92
- "args": ["-y", "@onlyflows/servicenow-mcp"],
93
- "env": {
94
- "SN_INSTANCE": "https://yourinstance.service-now.com",
95
- "SN_USER": "your_username",
96
- "SN_PASSWORD": "your_password"
97
- }
412
+ "version": 2,
413
+ "profiles": {
414
+ "dev": {
415
+ "instance": "https://mydev.service-now.com",
416
+ "authType": "oauth",
417
+ "clientId": "your-oauth-client-id",
418
+ "clientSecret": "env:SN_CLIENT_SECRET",
419
+ "description": "OAuth client_credentials"
98
420
  }
99
421
  }
100
422
  }
101
423
  ```
102
424
 
103
- ### VS Code (Copilot)
425
+ `password` grant — set `grantType` and provide the user credentials as well:
426
+
427
+ ```json
428
+ {
429
+ "instance": "https://mydev.service-now.com",
430
+ "authType": "oauth",
431
+ "grantType": "password",
432
+ "clientId": "your-oauth-client-id",
433
+ "clientSecret": "env:SN_CLIENT_SECRET",
434
+ "username": "integration.user",
435
+ "credential": "env:SN_PASSWORD_DEV"
436
+ }
437
+ ```
104
438
 
105
- Add to `.vscode/mcp.json`:
439
+ Tokens are cached until shortly before their `expires_in` expiry and refreshed automatically (including a single refresh + retry on 401). Token responses are never logged.
440
+
441
+ ### API key
442
+
443
+ For instances using Inbound Authentication Profiles with API keys. The header name is configurable (default `x-sn-apikey`):
106
444
 
107
445
  ```json
108
446
  {
109
- "servers": {
110
- "servicenow": {
111
- "command": "npx",
112
- "args": ["-y", "@onlyflows/servicenow-mcp"],
113
- "env": {
114
- "SN_INSTANCE": "https://yourinstance.service-now.com",
115
- "SN_USER": "your_username",
116
- "SN_PASSWORD": "your_password"
117
- }
118
- }
447
+ "instance": "https://mydev.service-now.com",
448
+ "authType": "apikey",
449
+ "apiKey": "env:SN_API_KEY",
450
+ "apiKeyHeader": "x-sn-apikey"
451
+ }
452
+ ```
453
+
454
+ ### Basic (default, deprecated by ServiceNow)
455
+
456
+ ```json
457
+ {
458
+ "instance": "https://mydev.service-now.com",
459
+ "username": "admin",
460
+ "credential": "env:SN_PASSWORD_DEV"
461
+ }
462
+ ```
463
+
464
+ On a 401, the error explains the Basic Auth restriction program (KB3096078) and how to move to OAuth.
465
+
466
+ ### Timeouts & retries
467
+
468
+ Every request is bounded by a timeout (default 30s; per-profile `timeoutMs` or env `SN_TIMEOUT_MS`) and retried up to twice with exponential backoff on 429/502/503/504, honoring `Retry-After`. POST requests are only retried on 429 — never after a 5xx that may have executed side effects.
469
+
470
+ ServiceNow upstream can return HTTP 429 with an empty body, while this server's own HTTP rate-limit rejections return a short JSON body plus `Retry-After`. Treat the status and `Retry-After` header as authoritative; do not benchmark or validate tool success from response latency or body shape alone. In normal ServiceNow instances, plan around the Background throttling default of roughly 120 requests per 60 seconds per identity unless the instance limit is explicitly raised.
471
+
472
+ ---
473
+
474
+ ## Why This MCP Server?
475
+
476
+ Most ServiceNow MCP integrations are **read-only** and support a handful of
477
+ tables. This service offers a broader tool catalog behind explicit,
478
+ deny-by-default table and tool policy:
479
+
480
+ | Feature | Others | @onlyflows/servicenow-mcp |
481
+ |---------|--------|--------------------------|
482
+ | Query records | ✅ | ✅ |
483
+ | Create records | ❌ | ✅ |
484
+ | Update records | ❌ | ✅ |
485
+ | Delete records | ❌ | ✅ (with safety confirm) |
486
+ | Bulk operations | ❌ | ✅ (dry-run by default) |
487
+ | Aggregations (COUNT/AVG/MIN/MAX/SUM) | ❌ | ✅ |
488
+ | Table schema introspection | ❌ | ✅ |
489
+ | CMDB relationship traversal | ❌ | ✅ (recursive, configurable depth) |
490
+ | Instance health monitoring | ❌ | ✅ (version, nodes, jobs, stats) |
491
+ | Attachment management | ❌ | ✅ (list, upload, download; inline base64, no host filesystem) |
492
+ | System log queries | ❌ | ✅ |
493
+ | Code search across artifacts | ❌ | ✅ |
494
+ | Table/app/plugin discovery | ❌ | ✅ |
495
+ | ATF test execution | ❌ | 🚧 listing/results available; execution currently policy-denied |
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** | **19** |
500
+
501
+ ---
502
+
503
+ ## Quick Start
504
+
505
+ The server speaks stdio and requires Node.js 20 or newer. The shortest path is
506
+ the bootstrap described under [Installation](#installation):
507
+
508
+ ```bash
509
+ servicenow-mcp-setup
510
+ ```
511
+
512
+ That registers your clients; each one spawns the server when it needs it.
513
+
514
+ The rest of this section is the manual environment path, for a deployment that
515
+ injects everything from a supervisor or secret manager, or for driving the
516
+ server by hand over a pipe.
517
+
518
+ Use [`.env.example`](.env.example) only as a non-secret configuration
519
+ inventory. Its protected-value assignments are intentionally empty; inject
520
+ ServiceNow secrets through a supervisor, orchestrator, keychain, or secret
521
+ manager rather than filling a repository dotenv file.
522
+
523
+ > The `SN_ALLOWED_*` and `SN_PROFILE_NAME` variables below build a profile only
524
+ > when `~/.servicenow-mcp/config.json` does **not** exist. With a profile file
525
+ > present, put the rules on the profile with `servicenow-mcp-setup grant`.
526
+
527
+ ```bash
528
+ export MCP_OWNER_ID="your-owner-id"
529
+ export MCP_CLIENT_ID="your-client-id"
530
+ export SN_ALLOWED_READ_TABLES="incident,problem,change_request"
531
+ export SN_ALLOWED_WRITE_TABLES="incident,change_request"
532
+ export SN_TABLE_ACCESS_TARGETS='[{"table":"incident","kind":"canonical","tools":["sn_query","sn_get","sn_create","sn_update","sn_incident_add_comment","sn_incident_add_work_note","sn_delete","sn_batch"],"closureComplete":true,"relatedTables":["incident"]},{"table":"problem","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["problem"]},{"table":"change_request","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["change_request"]}]'
533
+ export SN_PROFILE_NAME="dev"
534
+ export SN_INSTANCE="https://yourinstance.service-now.com"
535
+ export SN_USER="your_username"
536
+ npm run build
537
+ npm start
538
+ ```
539
+
540
+ Before running those non-secret commands, the approved runtime secret
541
+ mechanism must already have injected the authentication-specific ServiceNow
542
+ secret into the process. Do not enter it in this shell block.
543
+
544
+ A client connects by spawning the command; there is no URL and no header:
545
+
546
+ ```json
547
+ {
548
+ "mcpServers": {
549
+ "servicenow-mcp": { "command": "servicenow-mcp", "args": [] }
119
550
  }
120
551
  }
121
552
  ```
122
553
 
554
+ JSON-RPC messages travel on the child's stdin and stdout, one newline-delimited
555
+ message per frame. Everything else the server reports — startup warnings, and
556
+ one structured JSON-line event per completed tool call — goes to **stderr**,
557
+ which your client captures as its server log. There is no per-message size
558
+ limit imposed by the transport.
559
+
560
+ For complete official SDK and independent client examples, safe two-profile
561
+ setup, and crossed profile/result/audit checks, see
562
+ [V2 service and client setup](docs/CLIENT-SETUP.md).
563
+
564
+ ### Breaking changes in 2.0
565
+
566
+ Every tool call must name a `profile`, and table access is deny-by-default.
567
+ Those two require action on every install. The transport is stdio, as it was in
568
+ `1.0.0`, so a client configured with a `command` entry keeps working.
569
+
570
+ The breaking changes from `1.0.0`, each with a before/after example, are in
571
+ [Migrating to 2.0](docs/V2-MIGRATION.md#breaking-changes-at-a-glance).
572
+
573
+ ### Deployment guides for the dormant HTTP transport
574
+
575
+ 2.0 ships stdio only. The container image, the health and shutdown contract,
576
+ the operations runbook, and the Secure MCP Tunnel adapter all describe the
577
+ [dormant HTTP transport](docs/ENTERPRISE-RELEASE-BOUNDARY.md#the-dormant-http-transport),
578
+ which no CLI path reaches. They are kept because that transport is a planned
579
+ enterprise deployment shape, not because they apply to a 2.0 install — nothing
580
+ in this section is needed to use this server.
581
+
582
+ - [Production container deployment](docs/CONTAINER-DEPLOYMENT.md) — OCI
583
+ artifact, non-root runtime, provenance and scanning
584
+ - [Remote operations runbook](docs/OPERATIONS-RUNBOOK.md) — health
585
+ interpretation, telemetry, alerts, rotation, incident response
586
+ - [Private ChatGPT connectivity](docs/PRIVATE-CHATGPT-CONNECTIVITY.md) —
587
+ outbound-only Secure MCP Tunnel adapter
588
+
123
589
  ---
124
590
 
125
591
  ## Tools Reference
@@ -128,12 +594,14 @@ Add to `.vscode/mcp.json`:
128
594
 
129
595
  | Tool | Description |
130
596
  |------|-------------|
131
- | `sn_query` | Query any table with encoded queries, field selection, pagination, sorting |
132
- | `sn_get` | Get a single record by sys_id |
133
- | `sn_create` | Create a new record on any table |
134
- | `sn_update` | Update an existing record (PATCH) |
135
- | `sn_delete` | Delete a record (requires `confirm: true`) |
136
- | `sn_batch` | Bulk update/delete with dry-run safety (requires `confirm: true` to execute) |
597
+ | `sn_query` | Query an approved table with structured filters, field selection, pagination, and sorting; bounded raw reads require an explicit policy rule |
598
+ | `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; `incident` additionally requires a bounded `short_description` |
600
+ | `sn_update` | Update one record selected by exact `sys_id` on any table granted for writes, using only field-policy-approved writable fields; rejects `comments` and `work_notes` with dedicated-tool migration guidance |
601
+ | `sn_incident_add_comment` | Append one bounded customer-visible comment to an incident; repeated calls append again |
602
+ | `sn_incident_add_work_note` | Append one bounded internal work note to an incident; repeated calls append again |
603
+ | `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) |
137
605
 
138
606
  ### Analytics & Schema
139
607
 
@@ -148,7 +616,7 @@ Add to `.vscode/mcp.json`:
148
616
  | Tool | Description |
149
617
  |------|-------------|
150
618
  | `sn_relationships` | CMDB CI graph traversal — upstream/downstream/both, configurable depth |
151
- | `sn_attach` | List, download, upload attachments |
619
+ | `sn_attach` | List attachments, return downloads as inline base64, and upload inline base64 content; never touches a host filesystem path |
152
620
  | `sn_syslog` | Query system logs with severity/source/time filters |
153
621
  | `sn_codesearch` | Search business rules, script includes, client scripts, etc. |
154
622
  | `sn_discover` | Discover tables, scoped apps, store apps, plugins |
@@ -157,22 +625,341 @@ Add to `.vscode/mcp.json`:
157
625
 
158
626
  | Tool | Description |
159
627
  |------|-------------|
160
- | `sn_atf` | Run ATF tests and suites, get results |
161
- | `sn_nl` | Natural language → ServiceNow API calls |
162
- | `sn_script` | Execute background scripts (requires Playwright) |
628
+ | `sn_atf` | List ATF tests/suites and get results; `run`/`run-suite` currently fail closed |
629
+ | `sn_nl` | Currently fails closed until natural-language composition emits a complete typed access plan |
630
+
631
+ `sn_script` (background script execution) shipped in 1.0.0 as an unimplemented
632
+ stub and is **not published in 2.0** — it does not appear in `tools/list`. Use
633
+ `sn_query` and `sn_batch` instead. See [Roadmap](#roadmap).
634
+
635
+ ### Profile Management
636
+
637
+ | Tool | Description |
638
+ |------|-------------|
639
+ | `sn_profile` | Inspect non-secret metadata for one explicitly named profile; profile configuration is operator-managed out of band |
163
640
 
164
641
  ---
165
642
 
166
643
  ## Environment Variables
167
644
 
645
+ ### MCP runtime
646
+
647
+ | Variable | Required | Default | Description |
648
+ |----------|----------|---------|-------------|
649
+ | `MCP_OWNER_ID` | ❌ | `local-owner` | Stable non-secret owner identifier recorded in request/tool context and every audit record. A label, not a credential; it is never checked. |
650
+ | `MCP_CLIENT_ID` | ❌ | `local-client` | Stable non-secret client identifier recorded in request/tool context and every audit record. A label, not a credential; it is never checked. |
651
+
652
+ That is the whole list. There is no bind address, port, `Host`/`Origin`
653
+ allowlist, concurrency cap, connection cap, shutdown grace period, bearer
654
+ token, or rate limit, because there is no listener: a client spawns the server
655
+ and owns its lifetime.
656
+
657
+ The server reads these from its environment and falls back to
658
+ `~/.servicenow-mcp/server.env` for any it does not find there. That file is
659
+ owner-only (mode `0600`) and is where `servicenow-mcp-setup` writes the
660
+ generated identifiers and `SN_PROFILE_ENCRYPTION_KEY`. It exists because the
661
+ client that spawns the server supplies its own environment and will not have
662
+ sourced anything. A value already present in the environment always wins, so a
663
+ container or CI runner that passes configuration directly is unaffected.
664
+ `servicenow-mcp-setup doctor` reports that file's mode and contents.
665
+
666
+ ### Observability
667
+
668
+ Each completed tool call emits one JSON-line event to **stderr**, which the
669
+ spawning client captures as its server log:
670
+
671
+ ```json
672
+ {"schemaVersion":1,"type":"mcp_tool","observedAtMs":1737000000000,"latencyMs":42,
673
+ "correlationId":"stdio-<session>-<invocation>","ownerIdHash":"sha256:...",
674
+ "clientIdHash":"sha256:...","tool":"sn_query","profile":"dev",
675
+ "instance":"https://dev00001.service-now.com","outcome":"success","reason":null,
676
+ "errorCategory":null,"retry":null,"retryAfterSeconds":null}
677
+ ```
678
+
679
+ Tool audits classify request cancellation and request-deadline expiration
680
+ separately from handler failures. Configured owner/client identifiers are
681
+ represented only by SHA-256 pseudonyms; headers, URLs/query strings, bodies,
682
+ credentials, tokens, config objects, and exception text are not event fields.
683
+ Telemetry never blocks a tool result: stderr backpressure retains at most 256
684
+ pending lines, drops excess events, and emits a
685
+ `{"type":"telemetry_dropped","count":N}` summary after the stream drains.
686
+
687
+ A correlation ID is `stdio-<session>-<invocation>`. The session half is fixed
688
+ for the life of one spawned server, so every record from one client session
689
+ groups together; the invocation half is fresh per call. Neither half is derived
690
+ from anything the caller sent.
691
+
692
+ **stdout carries the protocol and nothing else.** Every diagnostic goes to
693
+ stderr. One stray byte on stdout would desynchronize the client's JSON-RPC
694
+ parser and end the session, so there is no such thing as a harmless
695
+ `console.log` on the startup or request path; `test/stdio-entrypoint.test.ts`
696
+ spawns a real server and asserts it.
697
+
698
+ Arguments that fail a tool's schema are rejected by the MCP SDK before any
699
+ handler runs, so they return an error to the caller but produce **no audit
700
+ event** — the execution context that would issue one is never opened. Every
701
+ call that reaches a tool is audited.
702
+
703
+ ### Body size and concurrency (dormant HTTP runtime only)
704
+
705
+ None of this applies to the shipped server. It describes the dormant HTTP
706
+ runtime, which no CLI path reaches — see
707
+ [the enterprise release boundary](docs/ENTERPRISE-RELEASE-BOUNDARY.md#the-dormant-http-transport)
708
+ — and binds only someone embedding this package and calling `createHttpRuntime`
709
+ directly. Over stdio there is no request-body limit and no admission ceiling.
710
+
711
+ Request body size and concurrency trade directly against each other under the
712
+ 512 MiB admission ceiling:
713
+
714
+ | `maxBodyBytes` | Highest concurrency that starts | Effect |
715
+ |---|---|---|
716
+ | 1 MiB (shipped default) | 2 | 416 MiB budgeted; the intended configuration |
717
+ | 1.75 MiB | 2 | 512 MiB — exactly at the ceiling |
718
+ | **2 MiB** | **1** | **Single-flight: every tool call serializes** |
719
+ | 5.75 MiB | 1 | the last value that starts at all |
720
+ | above 5.75 MiB | none | startup fails at any concurrency |
721
+
722
+ Two failure modes are worth knowing:
723
+
724
+ - **At 2 MiB and above the server is single-flight.** Concurrency 2 no longer
725
+ fits, so the runtime can only start at 1 and every tool call queues behind
726
+ every other one. There is no warning and no log line — it presents as "the
727
+ server got slow", and one large upload blocks every other tool for its
728
+ duration. Nothing connects the cause to the effect.
729
+ - **Above 5.75 MiB the server refuses to start.** A constructor `throw`, not a
730
+ clamp. The message names `maxConcurrentRequests` and `maxBodyBytes` but gives
731
+ neither the ceiling, the arithmetic, nor a working value; the table above is
732
+ the way forward.
733
+
734
+ **`maxBodyBytes` is not operator-configurable.** `src/http-entrypoint.ts`
735
+ builds the request policy with only `allowedHosts` and `allowedOrigins`, so the
736
+ limit is always 1 MiB and no environment variable changes it.
737
+
738
+ ### Metadata cache
739
+
740
+ Stable ServiceNow metadata reads are cached per instance and credential identity
741
+ for 24 hours by default. The default cached table patterns are
742
+ `sys_glide_object`, `sys_dictionary`, `sys_db_object`, `sys_app`, `sys_plugins`,
743
+ `sys_metadata*`, and `sys_flow*`. Set `metadataCache.ttlMs` and
744
+ `metadataCache.tables` on a file-backed profile, or `SN_METADATA_CACHE_TTL_MS`
745
+ / `SN_METADATA_CACHE_TABLES` for the explicit environment profile. `sn_query`,
746
+ `sn_get`, and `sn_schema` accept `force_recache: true` to refresh metadata. A
747
+ cache hit performs a lightweight `sys_updated_on` probe and is used only when no
748
+ matching metadata rows changed since the previous sync.
749
+
750
+ **Prerequisite: a resolvable session timezone.** The freshness probe compares
751
+ `sys_updated_on`, which ServiceNow evaluates in the *session user's* timezone,
752
+ not UTC. Resolving that zone requires the authenticating account's `user_name`
753
+ to look up `sys_user.time_zone`, falling back to the `glide.sys.default.tz`
754
+ property. When it cannot be resolved the cache **disables itself** for that
755
+ identity rather than assuming UTC — a wrong assumption would silently serve
756
+ stale metadata for the length of the offset. The server logs a warning naming
757
+ the reads it needs.
758
+
759
+ This has one consequence worth knowing before you configure it:
760
+
761
+ | Profile auth | Metadata caching |
762
+ |---|---|
763
+ | Basic | works — the profile carries a username |
764
+ | OAuth **password** grant | works — the profile carries a username |
765
+ | OAuth **client_credentials** | **disabled** — no username to resolve a timezone from |
766
+ | API key | **disabled** — no username to resolve a timezone from |
767
+
768
+ The profile also needs read access to `sys_user` (for `time_zone`) and
769
+ `sys_properties` (for `glide.sys.default.tz`) for the lookup to succeed at all.
770
+
771
+ **The honest tradeoff:** the cache only ever saved payload bytes, never round
772
+ trips — a cache hit still costs one freshness probe. So on a client-credentials
773
+ or API-key profile the practical loss is bandwidth on `sys_dictionary` reads,
774
+ not latency. If you are choosing an auth mode, this should not be the deciding
775
+ factor.
776
+
777
+ **Deletions become visible within one TTL.** The freshness probe detects
778
+ updates, not deletes, so a row deleted upstream stays served until its entry
779
+ expires and is re-fetched — up to 24 hours at the default TTL. This is accepted
780
+ behavior, not a defect; lower `SN_METADATA_CACHE_TTL_MS` or pass
781
+ `force_recache: true` if you need a deletion reflected sooner.
782
+
783
+ ### Unrestricted field selection (`fields=all`, `response_format=detailed`)
784
+
785
+ Both resolve to a wildcard selection. They previously dropped `sysparm_fields`
786
+ entirely, so ServiceNow returned every column and a wide table could breach the
787
+ 1 MiB cumulative upstream cap and **fail the call outright**. They are now
788
+ bounded to at most **100 columns**.
789
+
790
+ The cap bounds the *upstream request*, not the response — truncating after
791
+ receipt would not help, because the bytes have already crossed the wire and
792
+ already breached the limit. Columns are resolved from `sys_dictionary`, walking
793
+ `super_class` so an extended table contributes its inherited fields. Ordering is
794
+ deterministic: the table's curated default projection first in its declared
795
+ order, then every remaining column alphabetically. Defaults lead so a capped
796
+ result stays useful; alphabetical afterwards because dictionary row order is not
797
+ stable across instances. Every failure path falls back to the table's bounded
798
+ default projection, never to dropping `sysparm_fields`.
799
+
800
+ `sn_query` reports truncation through its `hint` field. `sn_get` will carry the
801
+ same notice shortly.
802
+
803
+ Two behavior changes worth stating plainly, because they change what a caller
804
+ gets back:
805
+
806
+ - **Journal fields are now returned.** `comments` and `work_notes` are included
807
+ in the resolved set for `fields=all` and `detailed`. See
808
+ [Journal content and field selection](#journal-content-and-field-selection).
809
+ - **Sensitive-looking field names are excluded from the resolved set entirely.**
810
+ A name matching the sensitive-field pattern is never *requested*, rather than
811
+ being requested and scrubbed on arrival. Under the old wildcard behavior the
812
+ value crossed the wire and was then removed; naming it in `sysparm_fields`
813
+ would have pulled it over deliberately, which is worse.
814
+
815
+ ### Journal content and field selection
816
+
817
+ Journal content on `incident` — `comments` (customer-visible) and `work_notes`
818
+ (internal) — is readable through `fields=all`, `response_format: "detailed"`, an
819
+ explicit `fields=comments`, and `sn_schema`. **The default projection still
820
+ excludes it**, so an ordinary `sn_query` or `sn_get` does not return it.
821
+
822
+ Stated as a fact rather than a warning: journal content on real instances
823
+ routinely contains customer PII, so asking for all fields on `incident` returns
824
+ customer-visible commentary along with everything else. Operators granting
825
+ `incident` reads to an agent should know that. If that is not wanted, grant a
826
+ narrower read via the field policy rather than relying on the default
827
+ projection, since the caller chooses `fields`.
828
+
829
+ ### Attachment payloads
830
+
831
+ `sn_attach` never reads from or writes to host filesystem paths. Uploads use a
832
+ safe leaf `file_name` plus `content_base64`; downloads return
833
+ `content_base64`, `file_name`, `content_type`, and `size_bytes`. Download also
834
+ requires the owning `table` and record `sys_id`, which are policy-authorized
835
+ and verified against attachment metadata before any bytes are returned.
836
+
837
+ **Size limit: 10 MiB decoded, and that is the only one.** The stdio transport
838
+ frames messages by newline with no size bound, so the tool's own limits are
839
+ what apply — 10 MiB of decoded bytes for an upload, and a separate 10 MiB raw
840
+ budget for a download. The tool's `content_base64` schema description carries
841
+ the authoritative figure.
842
+
843
+ The ~760 KiB practical ceiling documented before 2.1 came from the HTTP body
844
+ limit, which no longer applies: the client and server share a pipe, not an
845
+ envelope. Base64 still inflates a file by about a third in the message itself,
846
+ so a 10 MiB attachment is roughly a 13.3 MiB JSON frame — large, but the
847
+ transport will carry it.
848
+
849
+ Treat `sn_attach` as suitable for logs, configs, screenshots, and documents
850
+ rather than bulk transfer; a very large frame still costs memory in both the
851
+ client and the server, and ServiceNow's own UI or a dedicated integration is a
852
+ better path for bulk file movement.
853
+
854
+ ### Table access policy
855
+
856
+ 2.0 denies every ServiceNow table by default. Table access is selected per
857
+ profile, not from a process-wide implicit default. File-backed profiles define
858
+ `tableAccess` in `~/.servicenow-mcp/config.json`; the explicit `SN_PROFILE_NAME`
859
+ environment profile maps the `SN_ALLOWED_*` variables into that one profile only
860
+ when no profile file exists. If a profile has no table rules, it denies all.
861
+
862
+ Write the rules with the CLI rather than by hand — it validates the result with
863
+ the same loader the server uses at request time:
864
+
865
+ ```bash
866
+ servicenow-mcp-setup grant --profile dev --read incident,problem --write incident
867
+ servicenow-mcp-setup grant --profile dev --read cmdb_ci --tools sn_query,sn_relationships
868
+ servicenow-mcp-setup grant --profile dev --read change_request --related change_request=task
869
+ ```
870
+
871
+ Allowlist entries may be exact table names or the literal `*` to allow every
872
+ table for that operation. Table names are trimmed, lowercased, deduplicated,
873
+ and must be valid ServiceNow identifiers.
874
+
875
+ > **`tableAccess` is the sole table-level authority.** There is no longer a
876
+ > built-in list of tables the server refuses unconditionally. A profile that
877
+ > grants a table gets it, subject only to ServiceNow's own per-user ACLs — so a
878
+ > grant of `sys_script`, `sys_user_role`, or a credential table is honored.
879
+ > Writing `sys_script` is server-side script execution under the integration
880
+ > account. Least privilege now lives entirely in the grant and in the roles you
881
+ > give that account; grant the narrowest set that does the job, and prefer an
882
+ > account whose ServiceNow roles cannot reach what the grant does not need.
883
+
168
884
  | Variable | Required | Default | Description |
169
885
  |----------|----------|---------|-------------|
170
- | `SN_INSTANCE` | ✅ | — | Instance URL (e.g. `https://yourinstance.service-now.com`) |
171
- | `SN_USER` | ✅ | — | ServiceNow username |
172
- | `SN_PASSWORD` | ✅ | — | ServiceNow password |
886
+ | `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. |
887
+ | `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. |
888
+ | `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 complete backing/ancestor/descendant `relatedTables` closure. With `*`, omitted target entries use the wildcard operation grant; explicit target entries can still narrow tools and validate related-table closure. |
889
+ | `SN_FIELD_POLICY_DEFINITIONS` | Required for custom/generic table fields | built-in finite policy | Trusted JSON object keyed by table name or `*`. Each entry may define `defaults`, `readable`, and `writable`; `readable`/`writable` accept exact field arrays or `"*"`. Sensitive field names are still denied. Use `{"*":{"defaults":["sys_id"],"readable":"*","writable":[]}}` for broad read-only custom-table exploration. Use `writable:"*"` only for intentional broad mutation access. |
890
+ | `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. |
891
+
892
+ Invalid policy configuration fails startup. A composed tool is admitted only
893
+ when its complete backing-table plan is allowed before the first ServiceNow
894
+ client access. Every related target must have the same read or write
895
+ permission, so a base table, alias, view, or extension cannot bypass an
896
+ unlisted backing or descendant table.
897
+ Related permission does not make a dependency directly caller-addressable
898
+ without its own target entry. Field policy narrows what a granted table exposes; it does not deny a table the
899
+ operator granted. Sensitive-looking field names remain excluded regardless. Build the
900
+ complete target catalog from approved ServiceNow metadata and treat it as
901
+ trusted startup configuration; omit a target when reachability cannot be proven
902
+ complete. File-backed profile example:
903
+
904
+ ```json
905
+ {
906
+ "version": 2,
907
+ "profiles": {
908
+ "dev": {
909
+ "instance": "https://dev.service-now.com",
910
+ "username": "integration.user",
911
+ "credential": "env:SN_PASSWORD",
912
+ "tableAccess": {
913
+ "readTables": ["incident", "sys_dictionary"],
914
+ "writeTables": ["incident"],
915
+ "targets": [
916
+ {
917
+ "table": "incident",
918
+ "kind": "canonical",
919
+ "tools": ["sn_query", "sn_get", "sn_create", "sn_update"],
920
+ "closureComplete": true,
921
+ "relatedTables": ["incident"]
922
+ }
923
+ ]
924
+ }
925
+ }
926
+ }
927
+ }
928
+ ```
929
+ `sn_nl` and ATF `run`/`run-suite` currently fail closed because they do not emit
930
+ a complete typed side-effect plan; use the corresponding typed tool instead.
931
+ Incident journal fields are append-only: generic `sn_update` rejects `comments`
932
+ and `work_notes` before credentials or client creation. Use
933
+ `sn_incident_add_comment` or `sn_incident_add_work_note` with exactly
934
+ `profile`, incident `sys_id`, and bounded `content`; grant the selected tool
935
+ explicitly on the `incident` target as well as write access to that table.
936
+
937
+ ### ServiceNow profiles
938
+
939
+ > **Note:** A profile file is authoritative when present. Without one,
940
+ > `SN_PROFILE_NAME` must explicitly map the canonical connection variables to
941
+ > a named profile; there is no synthetic or default profile.
942
+
943
+ | Variable | Required | Default | Description |
944
+ |----------|----------|---------|-------------|
945
+ | `SN_PROFILE_NAME` | ✅* | — | Explicit name for the process-local environment profile; required before bare connection variables define any profile. |
946
+ | `SN_INSTANCE` | ✅* | — | Instance URL (e.g. `https://yourinstance.service-now.com`) |
947
+ | `SN_USER` | ✅* | — | ServiceNow username (basic auth / OAuth password grant) |
948
+ | `SN_PASSWORD` | ✅* | — | ServiceNow password (basic auth / OAuth password grant) |
949
+ | `SN_AUTH_TYPE` | ❌ | `basic` | Auth scheme: `basic`, `oauth`, or `apikey` |
950
+ | `SN_CLIENT_ID` | ❌ | — | OAuth client id (`SN_AUTH_TYPE=oauth`) |
951
+ | `SN_CLIENT_SECRET` | ❌ | — | OAuth client secret (`SN_AUTH_TYPE=oauth`) |
952
+ | `SN_GRANT_TYPE` | ❌ | `client_credentials` | OAuth grant: `client_credentials` or `password` |
953
+ | `SN_API_KEY` | ❌ | — | API key (`SN_AUTH_TYPE=apikey`) |
954
+ | `SN_API_KEY_HEADER` | ❌ | `x-sn-apikey` | Header the API key is sent in |
955
+ | `SN_TIMEOUT_MS` | ❌ | `30000` | Per-request timeout in milliseconds |
173
956
  | `SN_DISPLAY_VALUE` | ❌ | `true` | Default display value mode (`true`, `false`, `all`) |
174
957
  | `SN_REL_DEPTH` | ❌ | `3` | Default CMDB relationship traversal depth |
175
958
 
959
+ *`SN_PROFILE_NAME` and `SN_INSTANCE` are not required when using
960
+ `~/.servicenow-mcp/config.json`. Authentication-specific variables depend on
961
+ the selected auth type.
962
+
176
963
  ---
177
964
 
178
965
  ## Usage Examples
@@ -180,28 +967,34 @@ Add to `.vscode/mcp.json`:
180
967
  Once connected, your AI assistant can:
181
968
 
182
969
  **Query incidents:**
183
- > "Show me all P1 incidents assigned to the Network team"
970
+ > "On dev, show me all P1 incidents assigned to the Network team" (`profile: "dev"`)
184
971
 
185
972
  **Create a record:**
186
- > "Create an incident for VPN outage affecting 50 users, P2, assign to Network Operations"
973
+ > "On staging, create an incident for the approved VPN test" (`profile: "staging"`)
187
974
 
188
975
  **Aggregate data:**
189
- > "How many incidents are there grouped by priority?"
976
+ > "On prod, how many incidents are grouped by priority?" (`profile: "prod"`)
190
977
 
191
978
  **Check health:**
192
- > "Run a health check on our ServiceNow instance"
979
+ > "Run the dev instance health check" (`profile: "dev"`)
193
980
 
194
981
  **CMDB traversal:**
195
- > "Show all upstream dependencies for the email-server-01 CI"
982
+ > "On prod, show upstream dependencies for email-server-01" (`profile: "prod"`)
196
983
 
197
984
  **Schema introspection:**
198
- > "What fields are on the change_request table?"
985
+ > "On dev, what fields are on change_request?" (`profile: "dev"`)
199
986
 
200
987
  **Code search:**
201
- > "Find all business rules that reference GlideRecord('incident')"
988
+ > "On dev, find business rules that reference GlideRecord('incident')" (`profile: "dev"`)
202
989
 
203
990
  **ATF testing:**
204
- > "Run ATF test suite abc123 and wait for results"
991
+ > "On staging, list the approved ATF suite" (`profile: "staging"`)
992
+
993
+ **Explicit profile selection:**
994
+ > "Query incidents on dev" (the client sends `profile: "dev"` on that call)
995
+
996
+ The client must translate every example into a tool invocation containing that
997
+ exact `profile`; no prior call creates default, active, or switch-profile state.
205
998
 
206
999
  ---
207
1000
 
@@ -211,14 +1004,20 @@ This server is designed for production use with multiple safety layers:
211
1004
 
212
1005
  - **Delete operations** require explicit `confirm: true`
213
1006
  - **Batch operations** run in dry-run mode by default — shows match count without making changes
214
- - **Bulk deletes** require both `confirm` and `force` flags
215
- - **Background scripts** require `confirm` for destructive keywords (`deleteRecord`, `deleteMultiple`, etc.)
216
- - **Natural language writes** require `execute: true` (reads execute immediately)
1007
+ - **Bulk operations** require `confirm: true` to leave dry-run mode
1008
+ - **Unclassified composition is denied** — `sn_nl` and ATF execution do not run until they can emit complete typed access plans
1009
+ - **Table access is deny-by-default** with independent exact read/write allowlists and non-configurable sensitive-table denials
1010
+ - **User input is neutralized** before interpolation into encoded queries (`^` is stripped from filter values — ServiceNow's query syntax has no escape sequence)
217
1011
 
218
1012
  ---
219
1013
 
220
1014
  ## Development
221
1015
 
1016
+ Have the approved local supervisor or keychain inject the selected ServiceNow
1017
+ authentication secret before starting the process. The commands below contain
1018
+ non-secret configuration only; never prepend or append protected values on the
1019
+ command line.
1020
+
222
1021
  ```bash
223
1022
  # Clone
224
1023
  git clone https://github.com/onlyflowstech/servicenow-mcp.git
@@ -228,29 +1027,68 @@ cd servicenow-mcp
228
1027
  npm install
229
1028
  npm run build
230
1029
 
231
- # Run locally
1030
+ # Run the server directly, speaking stdio on this terminal's pipes
1031
+ MCP_OWNER_ID=local-owner \
1032
+ MCP_CLIENT_ID=local-client \
1033
+ SN_ALLOWED_READ_TABLES=incident,problem,change_request \
1034
+ SN_ALLOWED_WRITE_TABLES=incident,change_request \
1035
+ SN_TABLE_ACCESS_TARGETS='[{"table":"incident","kind":"canonical","tools":["sn_query","sn_get","sn_create","sn_update","sn_incident_add_comment","sn_incident_add_work_note","sn_delete","sn_batch"],"closureComplete":true,"relatedTables":["incident"]},{"table":"problem","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["problem"]},{"table":"change_request","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["change_request"]}]' \
1036
+ SN_PROFILE_NAME=dev \
1037
+ SN_INSTANCE=https://yourinstance.service-now.com \
1038
+ SN_USER=your_user \
1039
+ npm start
1040
+
1041
+ # Build and run with source maps for local development
1042
+ MCP_OWNER_ID=local-owner \
1043
+ MCP_CLIENT_ID=local-client \
1044
+ SN_ALLOWED_READ_TABLES=incident,problem,change_request \
1045
+ SN_ALLOWED_WRITE_TABLES=incident,change_request \
1046
+ SN_TABLE_ACCESS_TARGETS='[{"table":"incident","kind":"canonical","tools":["sn_query","sn_get","sn_create","sn_update","sn_incident_add_comment","sn_incident_add_work_note","sn_delete","sn_batch"],"closureComplete":true,"relatedTables":["incident"]},{"table":"problem","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["problem"]},{"table":"change_request","kind":"canonical","tools":["sn_query","sn_get"],"closureComplete":true,"relatedTables":["change_request"]}]' \
1047
+ SN_PROFILE_NAME=dev \
232
1048
  SN_INSTANCE=https://yourinstance.service-now.com \
233
1049
  SN_USER=your_user \
234
- SN_PASSWORD=your_pass \
235
- node dist/index.js
236
-
237
- # Watch mode
238
1050
  npm run dev
239
1051
  ```
240
1052
 
241
1053
  ### Testing with MCP Inspector
242
1054
 
1055
+ Use the isolated, exactly locked Inspector toolchain on Node.js 22.19 or newer;
1056
+ the server itself remains supported on Node.js 20. Set the non-secret
1057
+ `MCP_PROFILE`, install from `tools/inspector/package-lock.json`, and run the
1058
+ local-only launcher:
1059
+
243
1060
  ```bash
244
- npx @modelcontextprotocol/inspector node dist/index.js
1061
+ MCP_PROFILE=dev npm run inspector
245
1062
  ```
246
1063
 
1064
+ (Run `npm ci --prefix tools/inspector --engine-strict --ignore-scripts` first.)
1065
+
1066
+ The launcher prints the exact **STDIO** command and arguments to enter in the
1067
+ Inspector UI. There is no endpoint and no bearer to type. Include the explicit
1068
+ profile in every call. The Inspector spawns the server itself and inherits a
1069
+ scrubbed environment with every `MCP_*` and `SN_*` value removed; the server
1070
+ still resolves its credential, because it reads the owner-only
1071
+ `~/.servicenow-mcp/server.env` at startup rather than relying on what it was
1072
+ handed. The launcher does not expose Inspector beyond loopback or create a
1073
+ tunnel.
1074
+
1075
+ `npm run smoke` is the second client. It spawns `dist/index.js` the same way and
1076
+ needs only `MCP_PROFILE`:
1077
+
1078
+ ```bash
1079
+ MCP_PROFILE=dev npm run smoke
1080
+ ```
1081
+
1082
+ See [`docs/RELEASE-VALIDATION.md`](docs/RELEASE-VALIDATION.md) for the release
1083
+ gates, write confirmation, evidence, and rollback procedure.
1084
+
247
1085
  ---
248
1086
 
249
1087
  ## Roadmap
250
1088
 
251
- - [ ] **SSE transport** for remote hosting
252
- - [ ] **OAuth 2.0** authentication support
253
- - [ ] **sn_script** full implementation with Playwright (SNS-39)
1089
+ - [x] **stdio transport** — the client spawns the server; a Streamable HTTP runtime exists but is [dormant](docs/ENTERPRISE-RELEASE-BOUNDARY.md#the-dormant-http-transport)
1090
+ - [x] **OAuth 2.0** authentication support (client_credentials + password grants, API keys)
1091
+ - [ ] **sn_script** background-script execution (SNS-39) — future state, deliberately not shipped in 2.0; requires automating the `sys.scripts.do` UI endpoint with session auth
254
1092
  - [ ] **Streaming** for large result sets
255
1093
  - [ ] **Caching** for schema and relationship lookups
256
1094