@onlyflows/servicenow-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +267 -0
- package/dist/client.d.ts +40 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +145 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +46 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/aggregate.d.ts +67 -0
- package/dist/tools/aggregate.d.ts.map +1 -0
- package/dist/tools/aggregate.js +77 -0
- package/dist/tools/aggregate.js.map +1 -0
- package/dist/tools/atf.d.ts +95 -0
- package/dist/tools/atf.d.ts.map +1 -0
- package/dist/tools/atf.js +357 -0
- package/dist/tools/atf.js.map +1 -0
- package/dist/tools/attach.d.ts +74 -0
- package/dist/tools/attach.d.ts.map +1 -0
- package/dist/tools/attach.js +156 -0
- package/dist/tools/attach.js.map +1 -0
- package/dist/tools/batch.d.ts +68 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +120 -0
- package/dist/tools/batch.js.map +1 -0
- package/dist/tools/codesearch.d.ts +52 -0
- package/dist/tools/codesearch.d.ts.map +1 -0
- package/dist/tools/codesearch.js +87 -0
- package/dist/tools/codesearch.js.map +1 -0
- package/dist/tools/create.d.ts +39 -0
- package/dist/tools/create.d.ts.map +1 -0
- package/dist/tools/create.js +44 -0
- package/dist/tools/create.js.map +1 -0
- package/dist/tools/delete.d.ts +45 -0
- package/dist/tools/delete.d.ts.map +1 -0
- package/dist/tools/delete.js +53 -0
- package/dist/tools/delete.js.map +1 -0
- package/dist/tools/discover.d.ts +53 -0
- package/dist/tools/discover.d.ts.map +1 -0
- package/dist/tools/discover.js +137 -0
- package/dist/tools/discover.js.map +1 -0
- package/dist/tools/get.d.ts +52 -0
- package/dist/tools/get.d.ts.map +1 -0
- package/dist/tools/get.js +52 -0
- package/dist/tools/get.js.map +1 -0
- package/dist/tools/health.d.ts +32 -0
- package/dist/tools/health.d.ts.map +1 -0
- package/dist/tools/health.js +172 -0
- package/dist/tools/health.js.map +1 -0
- package/dist/tools/index.d.ts +43 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +110 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/nl.d.ts +52 -0
- package/dist/tools/nl.d.ts.map +1 -0
- package/dist/tools/nl.js +433 -0
- package/dist/tools/nl.js.map +1 -0
- package/dist/tools/query.d.ts +73 -0
- package/dist/tools/query.d.ts.map +1 -0
- package/dist/tools/query.js +75 -0
- package/dist/tools/query.js.map +1 -0
- package/dist/tools/relationships.d.ts +74 -0
- package/dist/tools/relationships.d.ts.map +1 -0
- package/dist/tools/relationships.js +228 -0
- package/dist/tools/relationships.js.map +1 -0
- package/dist/tools/schema.d.ts +38 -0
- package/dist/tools/schema.d.ts.map +1 -0
- package/dist/tools/schema.js +60 -0
- package/dist/tools/schema.js.map +1 -0
- package/dist/tools/script.d.ts +52 -0
- package/dist/tools/script.d.ts.map +1 -0
- package/dist/tools/script.js +51 -0
- package/dist/tools/script.js.map +1 -0
- package/dist/tools/syslog.d.ts +74 -0
- package/dist/tools/syslog.d.ts.map +1 -0
- package/dist/tools/syslog.js +93 -0
- package/dist/tools/syslog.js.map +1 -0
- package/dist/tools/update.d.ts +46 -0
- package/dist/tools/update.d.ts.map +1 -0
- package/dist/tools/update.js +44 -0
- package/dist/tools/update.js.map +1 -0
- package/dist/utils.d.ts +44 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +72 -0
- package/dist/utils.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = exports.definition = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
exports.definition = {
|
|
8
|
+
name: "sn_syslog",
|
|
9
|
+
description: "Query ServiceNow system logs (syslog table) with severity, source, and time-based filters. Results ordered newest first.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
level: {
|
|
14
|
+
type: "string",
|
|
15
|
+
enum: ["error", "warning", "info", "debug"],
|
|
16
|
+
description: "Filter by severity level",
|
|
17
|
+
},
|
|
18
|
+
source: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Filter by source field (LIKE match)",
|
|
21
|
+
},
|
|
22
|
+
message: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Filter message contains text (LIKE match)",
|
|
25
|
+
},
|
|
26
|
+
query: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Raw encoded query (overrides individual filters)",
|
|
29
|
+
},
|
|
30
|
+
limit: {
|
|
31
|
+
type: "number",
|
|
32
|
+
description: "Max records (default 25)",
|
|
33
|
+
},
|
|
34
|
+
since: {
|
|
35
|
+
type: "number",
|
|
36
|
+
description: "Show logs from last N minutes (default 60)",
|
|
37
|
+
},
|
|
38
|
+
fields: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Fields to return (default: sys_id,level,source,message,sys_created_on)",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
required: [],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
exports.schema = zod_1.z.object({
|
|
47
|
+
level: zod_1.z.enum(["error", "warning", "info", "debug"]).optional(),
|
|
48
|
+
source: zod_1.z.string().optional(),
|
|
49
|
+
message: zod_1.z.string().optional(),
|
|
50
|
+
query: zod_1.z.string().optional(),
|
|
51
|
+
limit: zod_1.z.number().optional().default(25),
|
|
52
|
+
since: zod_1.z.number().optional().default(60),
|
|
53
|
+
fields: zod_1.z.string().optional(),
|
|
54
|
+
});
|
|
55
|
+
async function handler(args, client, _config) {
|
|
56
|
+
try {
|
|
57
|
+
const fields = args.fields || "sys_id,level,source,message,sys_created_on";
|
|
58
|
+
let sysparmQuery;
|
|
59
|
+
if (args.query) {
|
|
60
|
+
sysparmQuery = args.query;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const parts = [];
|
|
64
|
+
if (args.level)
|
|
65
|
+
parts.push(`level=${args.level}`);
|
|
66
|
+
if (args.source)
|
|
67
|
+
parts.push(`sourceLIKE${args.source}`);
|
|
68
|
+
if (args.message)
|
|
69
|
+
parts.push(`messageLIKE${args.message}`);
|
|
70
|
+
parts.push(`sys_created_on>=javascript:gs.minutesAgoStart(${args.since})`);
|
|
71
|
+
sysparmQuery = parts.join("^");
|
|
72
|
+
}
|
|
73
|
+
// Always order newest first
|
|
74
|
+
sysparmQuery += "^ORDERBYDESCsys_created_on";
|
|
75
|
+
const resp = await client.get("/api/now/table/syslog", {
|
|
76
|
+
sysparm_query: sysparmQuery,
|
|
77
|
+
sysparm_fields: fields,
|
|
78
|
+
sysparm_limit: String(args.limit),
|
|
79
|
+
});
|
|
80
|
+
const results = (resp.result || []).map((r) => ({
|
|
81
|
+
sys_id: r.sys_id,
|
|
82
|
+
timestamp: r.sys_created_on,
|
|
83
|
+
level: r.level,
|
|
84
|
+
source: r.source,
|
|
85
|
+
message: r.message ? (0, utils_js_1.truncate)(r.message, 300) : undefined,
|
|
86
|
+
}));
|
|
87
|
+
return (0, utils_js_1.ok)(results);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return (0, utils_js_1.err)((0, utils_js_1.formatError)(error));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=syslog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syslog.js","sourceRoot":"","sources":["../../src/tools/syslog.ts"],"names":[],"mappings":";;;AAwDA,0BAyCC;AAjGD,6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,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAyB,EAAE,EAAE,CAAC,CAAC;YACtE,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,SAAS,EAAE,CAAC,CAAC,cAAc;YAC3B,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,mBAAQ,EAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;SAC1D,CAAC,CAAC,CAAC;QAEJ,OAAO,IAAA,aAAE,EAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,cAAG,EAAC,IAAA,sBAAW,EAAC,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ServiceNowClient } from "../client.js";
|
|
3
|
+
import { ServiceNowConfig } from "../config.js";
|
|
4
|
+
export declare const definition: {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: "object";
|
|
9
|
+
properties: {
|
|
10
|
+
table: {
|
|
11
|
+
type: string;
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
sys_id: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
fields: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
additionalProperties: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
required: string[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const schema: z.ZodObject<{
|
|
28
|
+
table: z.ZodString;
|
|
29
|
+
sys_id: z.ZodString;
|
|
30
|
+
fields: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
table: string;
|
|
33
|
+
fields: Record<string, unknown>;
|
|
34
|
+
sys_id: string;
|
|
35
|
+
}, {
|
|
36
|
+
table: string;
|
|
37
|
+
fields: Record<string, unknown>;
|
|
38
|
+
sys_id: string;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function handler(args: z.infer<typeof schema>, client: ServiceNowClient, _config: ServiceNowConfig): Promise<{
|
|
41
|
+
content: Array<{
|
|
42
|
+
type: "text";
|
|
43
|
+
text: string;
|
|
44
|
+
}>;
|
|
45
|
+
}>;
|
|
46
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/tools/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;CAwBtB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;EAIjB,CAAC;AAEH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,EAC5B,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,gBAAgB;;;;;GAW1B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = exports.definition = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
exports.definition = {
|
|
8
|
+
name: "sn_update",
|
|
9
|
+
description: "Update an existing ServiceNow record. Pass the sys_id and field values to change.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
table: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "ServiceNow table name (e.g. incident)",
|
|
16
|
+
},
|
|
17
|
+
sys_id: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "The sys_id of the record to update",
|
|
20
|
+
},
|
|
21
|
+
fields: {
|
|
22
|
+
type: "object",
|
|
23
|
+
description: 'JSON object of field name/value pairs to update (e.g. {"state":"6","close_notes":"Fixed"})',
|
|
24
|
+
additionalProperties: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: ["table", "sys_id", "fields"],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
exports.schema = zod_1.z.object({
|
|
31
|
+
table: zod_1.z.string(),
|
|
32
|
+
sys_id: zod_1.z.string(),
|
|
33
|
+
fields: zod_1.z.record(zod_1.z.unknown()),
|
|
34
|
+
});
|
|
35
|
+
async function handler(args, client, _config) {
|
|
36
|
+
try {
|
|
37
|
+
const resp = await client.patch(`/api/now/table/${args.table}/${args.sys_id}`, args.fields);
|
|
38
|
+
return (0, utils_js_1.ok)(resp.result);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return (0, utils_js_1.err)((0, utils_js_1.formatError)(error));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/tools/update.ts"],"names":[],"mappings":";;;AAqCA,0BAcC;AAnDD,6BAAwB;AAGxB,0CAAmD;AAEtC,QAAA,UAAU,GAAG;IACxB,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,mFAAmF;IACrF,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uCAAuC;aACrD;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oCAAoC;aAClD;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,4FAA4F;gBAC9F,oBAAoB,EAAE,IAAI;aAC3B;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;KACxC;CACF,CAAC;AAEW,QAAA,MAAM,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC;CAC9B,CAAC,CAAC;AAEI,KAAK,UAAU,OAAO,CAC3B,IAA4B,EAC5B,MAAwB,EACxB,OAAyB;IAEzB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAC7B,kBAAkB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,EAC7C,IAAI,CAAC,MAAM,CACZ,CAAC;QACF,OAAO,IAAA,aAAE,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,cAAG,EAAC,IAAA,sBAAW,EAAC,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for tool handlers.
|
|
3
|
+
*
|
|
4
|
+
* @module utils
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Format a successful tool result as MCP text content.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ok(data: unknown): {
|
|
10
|
+
content: Array<{
|
|
11
|
+
type: "text";
|
|
12
|
+
text: string;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Format an error tool result as MCP text content.
|
|
17
|
+
*/
|
|
18
|
+
export declare function err(message: string): {
|
|
19
|
+
content: Array<{
|
|
20
|
+
type: "text";
|
|
21
|
+
text: string;
|
|
22
|
+
}>;
|
|
23
|
+
isError: true;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Safely format a ServiceNow error for display.
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatError(error: unknown): string;
|
|
29
|
+
/**
|
|
30
|
+
* Build a query parameter map for table API requests.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildTableParams(opts: {
|
|
33
|
+
query?: string;
|
|
34
|
+
fields?: string;
|
|
35
|
+
limit?: number;
|
|
36
|
+
offset?: number;
|
|
37
|
+
orderby?: string;
|
|
38
|
+
displayValue?: string;
|
|
39
|
+
}): Record<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* Truncate a string if it exceeds maxLen, appending "...".
|
|
42
|
+
*/
|
|
43
|
+
export declare function truncate(str: string, maxLen: number): string;
|
|
44
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,wBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAGpF;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG;IACpC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,IAAI,CAAC;CACf,CAEA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAYlD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASzB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAG5D"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared utilities for tool handlers.
|
|
4
|
+
*
|
|
5
|
+
* @module utils
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ok = ok;
|
|
9
|
+
exports.err = err;
|
|
10
|
+
exports.formatError = formatError;
|
|
11
|
+
exports.buildTableParams = buildTableParams;
|
|
12
|
+
exports.truncate = truncate;
|
|
13
|
+
/**
|
|
14
|
+
* Format a successful tool result as MCP text content.
|
|
15
|
+
*/
|
|
16
|
+
function ok(data) {
|
|
17
|
+
const text = typeof data === "string" ? data : JSON.stringify(data, null, 2);
|
|
18
|
+
return { content: [{ type: "text", text }] };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Format an error tool result as MCP text content.
|
|
22
|
+
*/
|
|
23
|
+
function err(message) {
|
|
24
|
+
return { content: [{ type: "text", text: `ERROR: ${message}` }], isError: true };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Safely format a ServiceNow error for display.
|
|
28
|
+
*/
|
|
29
|
+
function formatError(error) {
|
|
30
|
+
if (error && typeof error === "object") {
|
|
31
|
+
const e = error;
|
|
32
|
+
if (e.message) {
|
|
33
|
+
let msg = String(e.message);
|
|
34
|
+
if (e.detail)
|
|
35
|
+
msg += `\nDetail: ${e.detail}`;
|
|
36
|
+
if (e.status)
|
|
37
|
+
msg += ` (HTTP ${e.status})`;
|
|
38
|
+
return msg;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (error instanceof Error)
|
|
42
|
+
return error.message;
|
|
43
|
+
return String(error);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build a query parameter map for table API requests.
|
|
47
|
+
*/
|
|
48
|
+
function buildTableParams(opts) {
|
|
49
|
+
const params = {};
|
|
50
|
+
if (opts.limit !== undefined)
|
|
51
|
+
params.sysparm_limit = String(opts.limit);
|
|
52
|
+
if (opts.query)
|
|
53
|
+
params.sysparm_query = opts.query;
|
|
54
|
+
if (opts.fields)
|
|
55
|
+
params.sysparm_fields = opts.fields;
|
|
56
|
+
if (opts.offset !== undefined)
|
|
57
|
+
params.sysparm_offset = String(opts.offset);
|
|
58
|
+
if (opts.orderby)
|
|
59
|
+
params.sysparm_orderby = opts.orderby;
|
|
60
|
+
if (opts.displayValue)
|
|
61
|
+
params.sysparm_display_value = opts.displayValue;
|
|
62
|
+
return params;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Truncate a string if it exceeds maxLen, appending "...".
|
|
66
|
+
*/
|
|
67
|
+
function truncate(str, maxLen) {
|
|
68
|
+
if (str.length <= maxLen)
|
|
69
|
+
return str;
|
|
70
|
+
return str.slice(0, maxLen) + "...";
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAKH,gBAGC;AAKD,kBAKC;AAKD,kCAYC;AAKD,4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AK,KAAK,SAAS;QAAE,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,IAAI,CAAC,KAAK;QAAE,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC;IAClD,IAAI,IAAI,CAAC,MAAM;QAAE,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACrD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3E,IAAI,IAAI,CAAC,OAAO;QAAE,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC;IACxD,IAAI,IAAI,CAAC,YAAY;QAAE,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC,YAAY,CAAC;IACxE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,MAAc;IAClD,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,GAAG,CAAC;IACrC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;AACtC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onlyflows/servicenow-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The most comprehensive ServiceNow MCP server. 17 tools for full CRUD, CMDB graph traversal, background scripts, ATF testing, and more.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"servicenow-mcp": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"prepare": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"servicenow",
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"itsm",
|
|
21
|
+
"itom",
|
|
22
|
+
"cmdb",
|
|
23
|
+
"claude",
|
|
24
|
+
"cursor",
|
|
25
|
+
"windsurf",
|
|
26
|
+
"ai-tools"
|
|
27
|
+
],
|
|
28
|
+
"author": "OnlyFlows <support@onlyflows.tech> (https://onlyflows.tech)",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/onlyflowstech/servicenow-mcp"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/onlyflowstech/servicenow-mcp#readme",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/onlyflowstech/servicenow-mcp/issues"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
43
|
+
"zod": "^3.23.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^20.11.0",
|
|
47
|
+
"typescript": "^5.3.0"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"README.md",
|
|
52
|
+
"LICENSE"
|
|
53
|
+
]
|
|
54
|
+
}
|