@sonisoft/now-sdk-ext-mcp 4.8.0 → 4.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -63
- package/dist/common/connection.d.ts.map +1 -1
- package/dist/common/connection.js +6 -2
- package/dist/common/connection.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,21 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
An MCP (Model Context Protocol) server that enables AI assistants to interact directly with ServiceNow instances — executing background scripts, querying data, running ATF tests, tailing logs, and more.
|
|
4
4
|
|
|
5
|
-
Built on [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk) and [`@sonisoft/now-sdk-ext-core`](https://
|
|
5
|
+
Built on [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk) and [`@sonisoft/now-sdk-ext-core`](https://github.com/sonisoft-cnanda/now-sdk-ext-core).
|
|
6
6
|
|
|
7
|
-
Use [table behavior discovery](
|
|
7
|
+
Use [table behavior discovery](#table-behavior-discovery) to inspect automation, field requirements, and related artifact details. Available in MCP **4.8.0**, using core **6.4.1**.
|
|
8
8
|
|
|
9
9
|
## Quick Start
|
|
10
10
|
|
|
11
11
|
### Prerequisites
|
|
12
12
|
|
|
13
|
-
- **Node.js** >=
|
|
13
|
+
- **Node.js** >= 26
|
|
14
14
|
- **ServiceNow CLI credentials** configured via `now-sdk auth --add`
|
|
15
15
|
|
|
16
|
-
###
|
|
16
|
+
### Use the Published Package
|
|
17
|
+
|
|
18
|
+
Configure your MCP client to launch `npx --yes @sonisoft/now-sdk-ext-mcp`:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"mcpServers": {
|
|
23
|
+
"servicenow": {
|
|
24
|
+
"command": "npx",
|
|
25
|
+
"args": ["--yes", "@sonisoft/now-sdk-ext-mcp"],
|
|
26
|
+
"env": {
|
|
27
|
+
"SN_AUTH_ALIAS": "dev",
|
|
28
|
+
"MCP_TOOL_PACKAGE": "readonly"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The `readonly` package includes schema and behavior discovery. Omit `MCP_TOOL_PACKAGE` for all tools, or select a [tool package](TOOLS.md#tool-packages) for your workflow.
|
|
36
|
+
|
|
37
|
+
### Build from Source
|
|
17
38
|
|
|
18
39
|
```bash
|
|
19
|
-
git clone
|
|
40
|
+
git clone https://github.com/sonisoft-cnanda/now-sdk-ext-mcp.git
|
|
20
41
|
cd now-sdk-ext-mcp
|
|
21
42
|
npm install
|
|
22
43
|
npm run build
|
|
@@ -27,10 +48,11 @@ npm run build
|
|
|
27
48
|
This server uses the same credential store as the ServiceNow CLI. If you haven't already, configure your instance credentials:
|
|
28
49
|
|
|
29
50
|
```bash
|
|
30
|
-
|
|
51
|
+
npm install -g @servicenow/sdk
|
|
52
|
+
now-sdk auth --add https://dev12345.service-now.com --alias dev --type oauth
|
|
31
53
|
```
|
|
32
54
|
|
|
33
|
-
This stores credentials locally
|
|
55
|
+
This stores credentials locally. For clients that cannot unlock the OS keyring, import credentials into `@sonisoft/sn-credstore` and set `SN_CRED_STORE_ENABLE=1` in the server environment; see [credential storage](CLAUDE.md#credential-storage).
|
|
34
56
|
|
|
35
57
|
> **Breaking Change in v2.0.0 (ServiceNow SDK 4.3.0)**
|
|
36
58
|
>
|
|
@@ -45,7 +67,7 @@ This stores credentials locally so the MCP server can authenticate without promp
|
|
|
45
67
|
> npm install -g @servicenow/sdk@4.3.0
|
|
46
68
|
>
|
|
47
69
|
> # 2. Re-add each instance alias
|
|
48
|
-
> now-sdk auth --add
|
|
70
|
+
> now-sdk auth --add https://dev12345.service-now.com --alias dev --type oauth
|
|
49
71
|
>
|
|
50
72
|
> # 3. Verify your aliases work
|
|
51
73
|
> now-sdk auth --list
|
|
@@ -112,7 +134,7 @@ Add to your `.vscode/mcp.json` or Cursor MCP settings:
|
|
|
112
134
|
|
|
113
135
|
### Claude Code
|
|
114
136
|
|
|
115
|
-
Add to your
|
|
137
|
+
Add to your project-level `.mcp.json`:
|
|
116
138
|
|
|
117
139
|
```json
|
|
118
140
|
{
|
|
@@ -157,13 +179,93 @@ Once connected, you can talk to your AI assistant naturally:
|
|
|
157
179
|
|
|
158
180
|
> "Query the sys_user table for users with the admin role on prod"
|
|
159
181
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
3. Return the results in a readable format
|
|
182
|
+
> "Inspect change_request behavior on dev. Identify transition requirements and flow conditions needed for Change Management ATF coverage."
|
|
183
|
+
|
|
184
|
+
The assistant selects the appropriate tools, supplies the instance alias, and interprets their results. Schema tools describe fields; behavior tools retrieve automation configuration and dependencies. Script execution is available when the task calls for server-side JavaScript.
|
|
164
185
|
|
|
165
186
|
The `instance` parameter can be passed explicitly per-request or defaulted via the `SN_AUTH_ALIAS` environment variable, so if you only work with one instance you can set-and-forget.
|
|
166
187
|
|
|
188
|
+
## Table Behavior Discovery
|
|
189
|
+
|
|
190
|
+
Use `discover_table_behavior` to inventory configuration affecting a table and `get_behavior_details` to retrieve known artifacts without rescanning. Both tools are read-only and available in the `full`, `readonly`, `developer`, and `flow_developer` packages.
|
|
191
|
+
|
|
192
|
+
| Category | Functional context |
|
|
193
|
+
| --- | --- |
|
|
194
|
+
| `business_rules` | Before/after/async timing, operation flags, order, conditions and scripts |
|
|
195
|
+
| `ui_actions` | Form/list/workspace placement, roles, conditions and scripts |
|
|
196
|
+
| `client_scripts` | Client events, target fields, views and inherited applicability |
|
|
197
|
+
| `ui_policies` | Conditions and mandatory, visible or read-only field actions |
|
|
198
|
+
| `data_policies` | Server field requirements and enforcement settings |
|
|
199
|
+
| `workflows` | Legacy workflow versions, start conditions, activities and transitions |
|
|
200
|
+
| `flows` | Record triggers, conditions and optional current flow definitions |
|
|
201
|
+
| `state_models` | State fields, transition gates and required fields in supported generic layouts |
|
|
202
|
+
|
|
203
|
+
Pass these **tool arguments** to `discover_table_behavior` for a compact inventory:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"instance": "dev",
|
|
208
|
+
"table": "change_request"
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Defaults: active configuration, applicable ancestors, all eight categories, 50 items per category and a 65,536-byte JSON budget. Summaries include conditions and declarative field actions. Request scripts, definitions and dependencies in the first call when needed:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"instance": "dev",
|
|
217
|
+
"table": "change_request",
|
|
218
|
+
"categories": ["business_rules", "flows", "state_models"],
|
|
219
|
+
"details": ["scripts", "definitions", "dependencies"],
|
|
220
|
+
"dependency_depth": 1,
|
|
221
|
+
"max_bytes": 262144
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
For known artifacts, pass 1–50 `references` to `get_behavior_details`. Replace example IDs with real source IDs. Reference objects preserve the core API's camelCase keys even though tool options use snake_case:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"instance": "dev",
|
|
230
|
+
"references": [
|
|
231
|
+
{
|
|
232
|
+
"kind": "flows",
|
|
233
|
+
"sourceTable": "sys_hub_flow",
|
|
234
|
+
"sysId": "0123456789abcdef0123456789abcdef"
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
"details": ["definitions", "dependencies"],
|
|
238
|
+
"dependency_depth": 1,
|
|
239
|
+
"max_bytes": 262144
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
References from discovery can be passed through unchanged. Flow discovery can return trigger references; a known flow ID uses `kind: "flows"` and `sourceTable: "sys_hub_flow"`. Detail retrieval also supports subflows, actions, Script Includes and decision tables.
|
|
244
|
+
|
|
245
|
+
**Controls and continuation:**
|
|
246
|
+
|
|
247
|
+
- Filter discovery with `categories`, metadata `name`, or up to 50 `sys_ids`. Use `include_inherited: false` for direct table associations and `include_inactive: true` for inactive/draft candidates where available.
|
|
248
|
+
- `limit` accepts 1–200 items per category. `max_bytes` accepts 4,096–1,048,576 bytes on either tool.
|
|
249
|
+
- `dependency_depth` defaults to 0; 1 requires `details` containing `dependencies` and expands at most 50 unique dependency references. `scope` selects the transaction scope for flow definition reads.
|
|
250
|
+
- Pass each category's `nextCursor` in `cursors`, retaining the original table, filters and detail selection. For example, after a `business_rules`-only inventory:
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"instance": "dev",
|
|
255
|
+
"table": "change_request",
|
|
256
|
+
"categories": ["business_rules"],
|
|
257
|
+
"cursors": {
|
|
258
|
+
"business_rules": "<nextCursor from the previous response>"
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Both tools return the core result in `structuredContent` and a short text summary. Discovery includes category `status` (`complete`, `partial`, `unavailable`, or `failed`), `items`, `warnings` and optional `nextCursor`. Detail batches include `remainingReferences`. Oversized details are omitted whole with `omittedDetails` and warnings; increase the budget or narrow the batch. Empty pages can still need continuation, and empty results only describe the account's accessible configuration.
|
|
264
|
+
|
|
265
|
+
**Change Management ATF workflow:** combine schema fields and choices with behavior conditions, required fields, state transitions, approval steps and dependent artifacts. Keep UI behavior separate from server enforcement. Preserve source references and runtime/design provenance: current flow definitions can differ from the version associated with runtime trigger metadata. Conditions are not evaluated and execution order is not predicted. Validate the resulting test assumptions with ATF results, logs and flow contexts.
|
|
266
|
+
|
|
267
|
+
Live behavior validation used an Australia instance; Zurich validation remains outstanding. See the [behavior guide](docs/table-behavior.md), [tool parameters](TOOLS.md#discover_table_behavior), and [core API reference](https://github.com/sonisoft-cnanda/now-sdk-ext-core/blob/main/docs/TableBehaviorDiscovery.md).
|
|
268
|
+
|
|
167
269
|
## Available Tools
|
|
168
270
|
|
|
169
271
|
See **[TOOLS.md](TOOLS.md)** for the full list of available tools with parameters and examples.
|
|
@@ -173,6 +275,9 @@ See **[TOOLS.md](TOOLS.md)** for the full list of available tools with parameter
|
|
|
173
275
|
| Variable | Default | Description |
|
|
174
276
|
|----------|---------|-------------|
|
|
175
277
|
| `SN_AUTH_ALIAS` | _(none)_ | Default ServiceNow auth alias. Used when a tool call doesn't specify an `instance` parameter. |
|
|
278
|
+
| `MCP_TOOL_PACKAGE` | `full` | Tool package or comma-separated union; see [tool packages](TOOLS.md#tool-packages). |
|
|
279
|
+
| `SN_CRED_STORE_ENABLE` | _(unset)_ | Set to `1` to use the imported headless credential store; see [credential storage](CLAUDE.md#credential-storage). |
|
|
280
|
+
| `NEX_LOG_LEVEL` | `info` | Diagnostic log level; logs go to stderr. See [debugging](#debugging) for file logging. |
|
|
176
281
|
|
|
177
282
|
## Development
|
|
178
283
|
|
|
@@ -181,8 +286,10 @@ See **[TOOLS.md](TOOLS.md)** for the full list of available tools with parameter
|
|
|
181
286
|
```
|
|
182
287
|
src/
|
|
183
288
|
├── index.ts # Server entry point — registers tools, starts stdio transport
|
|
184
|
-
├── tools/ #
|
|
185
|
-
│ └──
|
|
289
|
+
├── tools/ # Tool implementations and registry.ts
|
|
290
|
+
│ └── behavior.ts # Discovery and batched behavior detail tools
|
|
291
|
+
├── config/tool-packages.ts # Role package definitions
|
|
292
|
+
├── resources/ # Read-only servicenow:// resources
|
|
186
293
|
└── common/
|
|
187
294
|
└── connection.ts # ServiceNow connection manager (credential resolution + caching)
|
|
188
295
|
|
|
@@ -209,52 +316,16 @@ test/
|
|
|
209
316
|
|
|
210
317
|
### Adding a New Tool
|
|
211
318
|
|
|
212
|
-
1.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
import { z } from "zod";
|
|
219
|
-
import { getServiceNowInstance } from "../common/connection.js";
|
|
220
|
-
|
|
221
|
-
export function registerQueryTableTool(server: McpServer): void {
|
|
222
|
-
server.registerTool(
|
|
223
|
-
"query_table",
|
|
224
|
-
{
|
|
225
|
-
title: "Query Table",
|
|
226
|
-
description: "Query records from a ServiceNow table.",
|
|
227
|
-
inputSchema: {
|
|
228
|
-
instance: z.string().optional().describe("ServiceNow instance auth alias"),
|
|
229
|
-
table: z.string().describe("Table name to query"),
|
|
230
|
-
// ... more params
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
async ({ instance, table }) => {
|
|
234
|
-
const snInstance = await getServiceNowInstance(instance);
|
|
235
|
-
// ... use core library to query
|
|
236
|
-
return {
|
|
237
|
-
content: [{ type: "text" as const, text: "results here" }],
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
3. Register it in `src/index.ts`:
|
|
245
|
-
|
|
246
|
-
```typescript
|
|
247
|
-
import { registerQueryTableTool } from "./tools/query-table.js";
|
|
248
|
-
|
|
249
|
-
registerQueryTableTool(server);
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
4. Add tests in `test/unit/tools/` following the existing pattern.
|
|
253
|
-
5. Document the tool in [`TOOLS.md`](TOOLS.md).
|
|
319
|
+
1. Add a registration function under `src/tools/`; [behavior.ts](src/tools/behavior.ts) demonstrates input validation, structured output and error handling.
|
|
320
|
+
2. Route ServiceNow calls through `withConnectionRetry` and delegate reusable behavior to core.
|
|
321
|
+
3. Add the tool to `TOOL_REGISTRY` in [registry.ts](src/tools/registry.ts) and classify its effects in [annotations.ts](src/common/annotations.ts). Registration rejects unclassified tools.
|
|
322
|
+
4. Add it to relevant role packages in [tool-packages.ts](src/config/tool-packages.ts). The full package uses the registry; the readonly package uses annotations.
|
|
323
|
+
5. Test listing and invocation through the MCP client in `test/unit/tools/`, and cover package membership where relevant.
|
|
324
|
+
6. Document parameters and examples in [TOOLS.md](TOOLS.md) and update user-facing README guidance.
|
|
254
325
|
|
|
255
326
|
### Testing Approach
|
|
256
327
|
|
|
257
|
-
|
|
328
|
+
Tool tests use the MCP SDK's `InMemoryTransport` for linked client/server pairs and exercise JSON-RPC, schema validation and handler dispatch without ServiceNow calls. Logging tests also spawn the real server to verify stdout purity, stderr redaction and shutdown flushing.
|
|
258
329
|
|
|
259
330
|
- **Unit tests** (`test/unit/`): Mock external dependencies (`@sonisoft/now-sdk-ext-core`, `@servicenow/sdk-cli`) using `jest.unstable_mockModule()` for ESM compatibility. Test tool behavior through the MCP client.
|
|
260
331
|
- **Integration tests** (`test/integration/`): Verify the MCP protocol lifecycle (handshake, tool listing, sequential calls) without mocking.
|
|
@@ -263,8 +334,8 @@ Tests use the MCP SDK's `InMemoryTransport` to create linked client+server pairs
|
|
|
263
334
|
|
|
264
335
|
This MCP server wraps the same core library used by the CLI:
|
|
265
336
|
|
|
266
|
-
- **Core library**: [`@sonisoft/now-sdk-ext-core`](
|
|
267
|
-
- **CLI**: [`@sonisoft/now-sdk-ext-cli`](
|
|
337
|
+
- **Core library**: [`@sonisoft/now-sdk-ext-core`](https://github.com/sonisoft-cnanda/now-sdk-ext-core) — all ServiceNow communication (auth, HTTP, WebSocket, script execution, ATF, syslog)
|
|
338
|
+
- **CLI**: [`@sonisoft/now-sdk-ext-cli`](https://github.com/sonisoft-cnanda/now-sdk-ext-cli) — the `nex` CLI that wraps the core library with oclif
|
|
268
339
|
|
|
269
340
|
When adding new MCP tools, reference the corresponding CLI command in `now-sdk-ext-cli/src/commands/` for the expected behavior and data flow.
|
|
270
341
|
|
|
@@ -305,7 +376,7 @@ There are three layers of testing for this project:
|
|
|
305
376
|
|
|
306
377
|
#### 1. Automated Tests (Jest)
|
|
307
378
|
|
|
308
|
-
|
|
379
|
+
Protocol tests use `InMemoryTransport`; logging checks also launch the real server. Automated tests do not require ServiceNow credentials or call a live instance.
|
|
309
380
|
|
|
310
381
|
```bash
|
|
311
382
|
npm test # Unit tests (default, fast)
|
|
@@ -427,7 +498,7 @@ printf '%s\n%s\n%s\n' \
|
|
|
427
498
|
|
|
428
499
|
Since stdout is reserved for JSON-RPC, **never use `console.log()` in server code** — it corrupts the protocol stream. Use these approaches instead:
|
|
429
500
|
|
|
430
|
-
-
|
|
501
|
+
- **Shared logger** — use `getLogger()` from `src/common/logging.ts`. It sends diagnostics to stderr and redacts structured metadata and recognized credential patterns. Avoid raw `console.error()` with errors or session data.
|
|
431
502
|
- **MCP Inspector** — run the server under the inspector to see all JSON-RPC messages and stderr output in real time.
|
|
432
503
|
- **File logging** — off by default. This server's working directory is chosen by whoever launched it, so it writes no files unless asked. Configure with environment variables:
|
|
433
504
|
|
|
@@ -439,7 +510,7 @@ Since stdout is reserved for JSON-RPC, **never use `console.log()` in server cod
|
|
|
439
510
|
| `NEX_POLICY_DENY` | `write`, `execute`, or `all` — refuses matching instance changes. Malformed values **fail closed** |
|
|
440
511
|
| `NEX_POLICY_ALLOW` | Grants verbs. Inert while changes are permitted by default |
|
|
441
512
|
|
|
442
|
-
Diagnostics always go to **stderr**, never stdout — stdout carries JSON-RPC.
|
|
513
|
+
Diagnostics always go to **stderr**, never stdout — stdout carries JSON-RPC. SDK diagnostics use the same redacting logger. Redaction covers structured credential fields and recognized message patterns; never interpolate arbitrary secrets into log messages. SIGINT and SIGTERM wait for log flushing within a two-second shutdown bound. Core 6.4.1 also waits for the underlying file stream to finish pending writes.
|
|
443
514
|
|
|
444
515
|
### Code Conventions
|
|
445
516
|
|
|
@@ -453,3 +524,18 @@ Since stdout is reserved for JSON-RPC, **never use `console.log()` in server cod
|
|
|
453
524
|
## License
|
|
454
525
|
|
|
455
526
|
MIT
|
|
527
|
+
|
|
528
|
+
## OAuth renewal
|
|
529
|
+
|
|
530
|
+
Alias-bound connections provide core with a credential resolver. Core can refresh
|
|
531
|
+
OAuth and rebuild session cookies during long-running operations; the 30-minute
|
|
532
|
+
connection cache is not an authentication lifetime.
|
|
533
|
+
|
|
534
|
+
Core owns authentication retries. MCP does not retry `NEX_AUTH_*` or
|
|
535
|
+
`NEX_SESSION_*` errors again. Writes and stateful sessions require an explicit safe
|
|
536
|
+
restart after expiry. Rejected refresh credentials require a new login; temporary
|
|
537
|
+
store/network failures do not establish that interactive reauthentication is needed.
|
|
538
|
+
|
|
539
|
+
When upgrading a shared store, stop all clients first, upgrade every client
|
|
540
|
+
(including standalone `now-sdk-x`) to sn-credstore 1.1.1 or later, then restart.
|
|
541
|
+
The new lock protocol cannot safely run alongside older clients.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/common/connection.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAEnB,MAAM,4BAA4B,CAAC;AA+BpC;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/common/connection.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAEnB,MAAM,4BAA4B,CAAC;AA+BpC;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,kBAAkB,CAAC,CAiD7B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAKtD;AAED,0EAA0E;AAC1E,4EAA4E;AAC5E,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAiBD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GACpE,OAAO,CAIT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,GACtD,OAAO,CAAC,CAAC,CAAC,CAeZ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveSessionCredentials } from "@sonisoft/now-sdk-ext-core";
|
|
2
2
|
import { ServiceNowInstance, } from "@sonisoft/now-sdk-ext-core";
|
|
3
3
|
import { getLogger } from "./logging.js";
|
|
4
4
|
const log = getLogger("connection");
|
|
@@ -41,7 +41,7 @@ export async function getServiceNowInstance(authAlias) {
|
|
|
41
41
|
log.debug("Cache TTL expired, refreshing session", { alias: resolvedAlias });
|
|
42
42
|
instanceCache.delete(resolvedAlias);
|
|
43
43
|
}
|
|
44
|
-
const credential = await
|
|
44
|
+
const credential = await resolveSessionCredentials(resolvedAlias);
|
|
45
45
|
if (!credential) {
|
|
46
46
|
// The previous text told users to run "snc configure", which is not a
|
|
47
47
|
// command this SDK has ever shipped — so the one actionable line in the
|
|
@@ -64,6 +64,7 @@ export async function getServiceNowInstance(authAlias) {
|
|
|
64
64
|
const snSettings = {
|
|
65
65
|
alias: resolvedAlias,
|
|
66
66
|
credential,
|
|
67
|
+
credentialProvider: () => resolveSessionCredentials(resolvedAlias),
|
|
67
68
|
};
|
|
68
69
|
const instance = new ServiceNowInstance(snSettings);
|
|
69
70
|
instanceCache.set(resolvedAlias, {
|
|
@@ -102,6 +103,9 @@ const RETRYABLE_PATTERNS = /ECONNREFUSED|ECONNRESET|ETIMEDOUT|EPIPE|socket hang
|
|
|
102
103
|
function isRetryableError(error) {
|
|
103
104
|
if (!error)
|
|
104
105
|
return false;
|
|
106
|
+
if (typeof error === "object" && "code" in error &&
|
|
107
|
+
typeof error.code === "string" && /^(NEX_AUTH_|NEX_SESSION_)/.test(error.code))
|
|
108
|
+
return false;
|
|
105
109
|
const msg = error instanceof Error ? error.message : String(error);
|
|
106
110
|
return RETRYABLE_PATTERNS.test(msg);
|
|
107
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/common/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/common/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EACL,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,GAAG,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;AAQpC,oFAAoF;AACpF,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEpC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAC;AAEpD;;;GAGG;AACH,SAAS,YAAY,CAAC,SAAkB;IACtC,MAAM,QAAQ,GAAG,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,uDAAuD;YACrD,oFAAoF,CACvF,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,SAAkB;IAElB,MAAM,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAE9C,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAChD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;QAC1C,IAAI,GAAG,GAAG,YAAY,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,QAAQ,CAAC;QACzB,CAAC;QACD,uCAAuC;QACvC,GAAG,CAAC,KAAK,CAAC,uCAAuC,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CA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+E;YAC/E,sEAAsE;YACtE,GAAG,CAAC,IAAI,CAAC,kDAAkD,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACxE,aAAa,CAAC,SAAS,CAAC,CAAC;YACzB,MAAM,aAAa,GAAG,MAAM,qBAAqB,CAAC,SAAS,CAAC,CAAC;YAC7D,OAAO,MAAM,SAAS,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonisoft/now-sdk-ext-mcp",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.1",
|
|
4
4
|
"description": "MCP server for interacting with ServiceNow instances via @sonisoft/now-sdk-ext-core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"servicenow",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@servicenow/sdk-cli": "4.9.2",
|
|
49
49
|
"@servicenow/sdk-cli-core": "3.0.3",
|
|
50
50
|
"@servicenow/sdk-core": "4.9.2",
|
|
51
|
-
"@sonisoft/now-sdk-ext-core": "^6.
|
|
52
|
-
"@sonisoft/sn-credstore": "1.1.
|
|
51
|
+
"@sonisoft/now-sdk-ext-core": "^6.5.1",
|
|
52
|
+
"@sonisoft/sn-credstore": "1.1.1",
|
|
53
53
|
"zod": "^3.23.8"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|