servicenow-mcp-server 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 (52) hide show
  1. package/.claude/settings.local.json +70 -0
  2. package/CLAUDE.md +777 -0
  3. package/LICENSE +21 -0
  4. package/README.md +562 -0
  5. package/assets/logo.svg +385 -0
  6. package/config/servicenow-instances.json.example +28 -0
  7. package/docs/403_TROUBLESHOOTING.md +329 -0
  8. package/docs/API_REFERENCE.md +1142 -0
  9. package/docs/APPLICATION_SCOPE_VALIDATION.md +681 -0
  10. package/docs/CLAUDE_DESKTOP_SETUP.md +373 -0
  11. package/docs/CONVENIENCE_TOOLS.md +601 -0
  12. package/docs/CONVENIENCE_TOOLS_SUMMARY.md +371 -0
  13. package/docs/FLOW_DESIGNER_GUIDE.md +1021 -0
  14. package/docs/IMPLEMENTATION_COMPLETE.md +165 -0
  15. package/docs/INSTANCE_SWITCHING_GUIDE.md +219 -0
  16. package/docs/MULTI_INSTANCE_CONFIGURATION.md +185 -0
  17. package/docs/NATURAL_LANGUAGE_SEARCH_IMPLEMENTATION.md +221 -0
  18. package/docs/PUPPETEER_INTEGRATION_PROPOSAL.md +1322 -0
  19. package/docs/QUICK_REFERENCE.md +395 -0
  20. package/docs/README.md +75 -0
  21. package/docs/RESOURCES_ARCHITECTURE.md +392 -0
  22. package/docs/RESOURCES_IMPLEMENTATION.md +276 -0
  23. package/docs/RESOURCES_SUMMARY.md +104 -0
  24. package/docs/SETUP_GUIDE.md +104 -0
  25. package/docs/UI_OPERATIONS_ARCHITECTURE.md +1219 -0
  26. package/docs/UI_OPERATIONS_DECISION_MATRIX.md +542 -0
  27. package/docs/UI_OPERATIONS_SUMMARY.md +507 -0
  28. package/docs/UPDATE_SET_VALIDATION.md +598 -0
  29. package/docs/UPDATE_SET_VALIDATION_SUMMARY.md +209 -0
  30. package/docs/VALIDATION_SUMMARY.md +479 -0
  31. package/jest.config.js +24 -0
  32. package/package.json +61 -0
  33. package/scripts/background_script_2025-09-29T20-19-35-101Z.js +23 -0
  34. package/scripts/link_ui_policy_actions_2025-09-29T20-17-15-218Z.js +90 -0
  35. package/scripts/set_update_set_Integration_Governance_Framework_2025-09-29T19-47-06-790Z.js +30 -0
  36. package/scripts/set_update_set_Integration_Governance_Framework_2025-09-29T19-59-33-152Z.js +30 -0
  37. package/scripts/set_update_set_current_2025-09-29T20-16-59-675Z.js +24 -0
  38. package/scripts/test_sys_dictionary_403.js +85 -0
  39. package/setup/setup-report.json +5313 -0
  40. package/src/config/comprehensive-table-definitions.json +2575 -0
  41. package/src/config/instance-config.json +4693 -0
  42. package/src/config/prompts.md +59 -0
  43. package/src/config/table-definitions.json +4681 -0
  44. package/src/config-manager.js +146 -0
  45. package/src/mcp-server-consolidated.js +2894 -0
  46. package/src/natural-language.js +472 -0
  47. package/src/resources.js +326 -0
  48. package/src/script-sync.js +428 -0
  49. package/src/server.js +125 -0
  50. package/src/servicenow-client.js +1625 -0
  51. package/src/stdio-server.js +52 -0
  52. package/start-mcp.sh +7 -0
@@ -0,0 +1,601 @@
1
+ # ServiceNow MCP Convenience Tools
2
+
3
+ ## Overview
4
+
5
+ Convenience tools provide a better user experience by accepting human-readable identifiers (like incident numbers) instead of technical sys_ids. These tools are wrappers around the generic `SN-Update-Record` tool with built-in validation and user/group resolution.
6
+
7
+ **Total Convenience Tools Added:** 10
8
+ **New Total MCP Tools:** 44 (up from 34)
9
+
10
+ ---
11
+
12
+ ## Incident Convenience Tools (5)
13
+
14
+ ### SN-Add-Comment
15
+ Add a customer-visible comment to an incident.
16
+
17
+ **Parameters:**
18
+ - `incident_number` (required): Incident number (e.g., "INC0012345")
19
+ - `comment` (required): Comment text to add
20
+ - `instance` (optional): Instance name
21
+
22
+ **Example:**
23
+ ```javascript
24
+ SN-Add-Comment({
25
+ incident_number: "INC0012345",
26
+ comment: "Issue has been identified and fix is being deployed"
27
+ })
28
+ ```
29
+
30
+ **Returns:**
31
+ - Incident number and sys_id
32
+ - Comment text
33
+ - Timestamp of update
34
+ - Confirmation message
35
+
36
+ ---
37
+
38
+ ### SN-Add-Work-Notes
39
+ Add internal work notes to an incident (not visible to customer).
40
+
41
+ **Parameters:**
42
+ - `incident_number` (required): Incident number (e.g., "INC0012345")
43
+ - `work_notes` (required): Work notes text to add
44
+ - `instance` (optional): Instance name
45
+
46
+ **Example:**
47
+ ```javascript
48
+ SN-Add-Work-Notes({
49
+ incident_number: "INC0012345",
50
+ work_notes: "Restarted application server, issue resolved"
51
+ })
52
+ ```
53
+
54
+ **Returns:**
55
+ - Incident number and sys_id
56
+ - Work notes text
57
+ - Timestamp of update
58
+ - Confirmation message
59
+
60
+ ---
61
+
62
+ ### SN-Assign-Incident
63
+ Assign an incident to a user and/or group. Automatically resolves user names to sys_ids.
64
+
65
+ **Parameters:**
66
+ - `incident_number` (required): Incident number (e.g., "INC0012345")
67
+ - `assigned_to` (required): User name or sys_id to assign to
68
+ - `assignment_group` (optional): Assignment group name or sys_id
69
+ - `instance` (optional): Instance name
70
+
71
+ **Features:**
72
+ - Accepts user name or sys_id for `assigned_to`
73
+ - Accepts group name or sys_id for `assignment_group`
74
+ - Automatically resolves names to sys_ids
75
+ - Validates user/group exists before assignment
76
+
77
+ **Example:**
78
+ ```javascript
79
+ SN-Assign-Incident({
80
+ incident_number: "INC0012345",
81
+ assigned_to: "John Smith", // Or sys_id
82
+ assignment_group: "Network Support" // Or sys_id
83
+ })
84
+ ```
85
+
86
+ **Returns:**
87
+ - Incident number and sys_id
88
+ - Assigned user (with display value)
89
+ - Assignment group (with display value)
90
+ - Timestamp of update
91
+ - Confirmation message
92
+
93
+ ---
94
+
95
+ ### SN-Resolve-Incident
96
+ Resolve an incident with resolution notes and optional resolution code.
97
+
98
+ **Parameters:**
99
+ - `incident_number` (required): Incident number (e.g., "INC0012345")
100
+ - `resolution_notes` (required): Resolution notes describing the fix
101
+ - `resolution_code` (optional): Resolution code (e.g., "Solved (Permanently)")
102
+ - `instance` (optional): Instance name
103
+
104
+ **Example:**
105
+ ```javascript
106
+ SN-Resolve-Incident({
107
+ incident_number: "INC0012345",
108
+ resolution_notes: "Application server restarted, service restored",
109
+ resolution_code: "Solved (Permanently)"
110
+ })
111
+ ```
112
+
113
+ **State Change:** Sets state to 6 (Resolved)
114
+
115
+ **Returns:**
116
+ - Incident number and sys_id
117
+ - State value (6)
118
+ - Resolution notes
119
+ - Resolution code (if provided)
120
+ - Timestamp of update
121
+ - Confirmation message
122
+
123
+ ---
124
+
125
+ ### SN-Close-Incident
126
+ Close an incident with close notes and optional close code.
127
+
128
+ **Parameters:**
129
+ - `incident_number` (required): Incident number (e.g., "INC0012345")
130
+ - `close_notes` (required): Close notes
131
+ - `close_code` (optional): Close code (e.g., "Solved (Work Around)")
132
+ - `instance` (optional): Instance name
133
+
134
+ **Example:**
135
+ ```javascript
136
+ SN-Close-Incident({
137
+ incident_number: "INC0012345",
138
+ close_notes: "Incident resolved, customer confirmed fix",
139
+ close_code: "Solved (Permanently)"
140
+ })
141
+ ```
142
+
143
+ **State Change:** Sets state to 7 (Closed)
144
+
145
+ **Returns:**
146
+ - Incident number and sys_id
147
+ - State value (7)
148
+ - Close notes
149
+ - Close code (if provided)
150
+ - Timestamp of update
151
+ - Confirmation message
152
+
153
+ ---
154
+
155
+ ## Change Request Convenience Tools (3)
156
+
157
+ ### SN-Add-Change-Comment
158
+ Add a comment to a change request.
159
+
160
+ **Parameters:**
161
+ - `change_number` (required): Change request number (e.g., "CHG0012345")
162
+ - `comment` (required): Comment text to add
163
+ - `instance` (optional): Instance name
164
+
165
+ **Example:**
166
+ ```javascript
167
+ SN-Add-Change-Comment({
168
+ change_number: "CHG0012345",
169
+ comment: "Change implementation completed successfully"
170
+ })
171
+ ```
172
+
173
+ **Returns:**
174
+ - Change request number and sys_id
175
+ - Comment text
176
+ - Timestamp of update
177
+ - Confirmation message
178
+
179
+ ---
180
+
181
+ ### SN-Assign-Change
182
+ Assign a change request to a user and/or group.
183
+
184
+ **Parameters:**
185
+ - `change_number` (required): Change request number (e.g., "CHG0012345")
186
+ - `assigned_to` (required): User name or sys_id to assign to
187
+ - `assignment_group` (optional): Assignment group name or sys_id
188
+ - `instance` (optional): Instance name
189
+
190
+ **Features:**
191
+ - Accepts user name or sys_id for `assigned_to`
192
+ - Accepts group name or sys_id for `assignment_group`
193
+ - Automatically resolves names to sys_ids
194
+ - Validates user/group exists before assignment
195
+
196
+ **Example:**
197
+ ```javascript
198
+ SN-Assign-Change({
199
+ change_number: "CHG0012345",
200
+ assigned_to: "Jane Doe",
201
+ assignment_group: "Change Management"
202
+ })
203
+ ```
204
+
205
+ **Returns:**
206
+ - Change request number and sys_id
207
+ - Assigned user (with display value)
208
+ - Assignment group (with display value)
209
+ - Timestamp of update
210
+ - Confirmation message
211
+
212
+ ---
213
+
214
+ ### SN-Approve-Change
215
+ Approve a change request.
216
+
217
+ **Parameters:**
218
+ - `change_number` (required): Change request number (e.g., "CHG0012345")
219
+ - `approval_comments` (optional): Comments for the approval
220
+ - `instance` (optional): Instance name
221
+
222
+ **Example:**
223
+ ```javascript
224
+ SN-Approve-Change({
225
+ change_number: "CHG0012345",
226
+ approval_comments: "All requirements met, approved for implementation"
227
+ })
228
+ ```
229
+
230
+ **Returns:**
231
+ - Change request number and sys_id
232
+ - Approval status (approved)
233
+ - Approval comments (if provided)
234
+ - Timestamp of update
235
+ - Confirmation message
236
+
237
+ ---
238
+
239
+ ## Problem Convenience Tools (2)
240
+
241
+ ### SN-Add-Problem-Comment
242
+ Add a comment to a problem record.
243
+
244
+ **Parameters:**
245
+ - `problem_number` (required): Problem number (e.g., "PRB0012345")
246
+ - `comment` (required): Comment text to add
247
+ - `instance` (optional): Instance name
248
+
249
+ **Example:**
250
+ ```javascript
251
+ SN-Add-Problem-Comment({
252
+ problem_number: "PRB0012345",
253
+ comment: "Root cause identified: memory leak in application"
254
+ })
255
+ ```
256
+
257
+ **Returns:**
258
+ - Problem number and sys_id
259
+ - Comment text
260
+ - Timestamp of update
261
+ - Confirmation message
262
+
263
+ ---
264
+
265
+ ### SN-Close-Problem
266
+ Close a problem with resolution information.
267
+
268
+ **Parameters:**
269
+ - `problem_number` (required): Problem number (e.g., "PRB0012345")
270
+ - `resolution_notes` (required): Resolution notes
271
+ - `resolution_code` (optional): Resolution code
272
+ - `instance` (optional): Instance name
273
+
274
+ **Example:**
275
+ ```javascript
276
+ SN-Close-Problem({
277
+ problem_number: "PRB0012345",
278
+ resolution_notes: "Memory leak fixed in application version 2.1",
279
+ resolution_code: "Permanent Fix"
280
+ })
281
+ ```
282
+
283
+ **State Change:** Sets state to 3 (Resolved/Closed)
284
+
285
+ **Returns:**
286
+ - Problem number and sys_id
287
+ - State value (3)
288
+ - Resolution notes
289
+ - Resolution code (if provided)
290
+ - Timestamp of update
291
+ - Confirmation message
292
+
293
+ ---
294
+
295
+ ## Implementation Details
296
+
297
+ ### Architecture
298
+
299
+ All convenience tools follow a common pattern:
300
+
301
+ 1. **Lookup by Number**: Query the table using the human-readable number
302
+ ```javascript
303
+ const records = await serviceNowClient.getRecords('incident', {
304
+ sysparm_query: `number=${incident_number}`,
305
+ sysparm_limit: 1
306
+ });
307
+ ```
308
+
309
+ 2. **Validation**: Check if record exists
310
+ ```javascript
311
+ if (!records || records.length === 0) {
312
+ throw new Error(`Incident ${incident_number} not found`);
313
+ }
314
+ ```
315
+
316
+ 3. **User/Group Resolution**: For assignment tools, resolve names to sys_ids
317
+ ```javascript
318
+ // Check if input is already a sys_id (32 char hex)
319
+ if (!/^[0-9a-f]{32}$/i.test(assigned_to)) {
320
+ // Look up user by name
321
+ const users = await serviceNowClient.getRecords('sys_user', {
322
+ sysparm_query: `name=${assigned_to}^ORuser_name=${assigned_to}`,
323
+ sysparm_limit: 1
324
+ });
325
+ assignedToId = users[0].sys_id;
326
+ }
327
+ ```
328
+
329
+ 4. **Update Record**: Use generic SN-Update-Record under the hood
330
+ ```javascript
331
+ const result = await serviceNowClient.updateRecord('incident', sys_id, data);
332
+ ```
333
+
334
+ 5. **Friendly Response**: Return human-readable confirmation
335
+ ```javascript
336
+ return {
337
+ content: [{
338
+ type: 'text',
339
+ text: `✅ ${incident_number} assigned successfully
340
+
341
+ Incident: ${incident_number}
342
+ sys_id: ${sys_id}
343
+ Assigned To: ${user_display_value}
344
+ Updated: ${timestamp}`
345
+ }]
346
+ };
347
+ ```
348
+
349
+ ### Error Handling
350
+
351
+ All tools include comprehensive error handling:
352
+
353
+ - **Record Not Found**: Clear error message with record number
354
+ - **User Not Found**: Validation before assignment
355
+ - **Group Not Found**: Validation before assignment
356
+ - **API Errors**: Propagated from underlying ServiceNow client
357
+
358
+ ### Multi-Instance Support
359
+
360
+ All convenience tools support the optional `instance` parameter for routing to specific ServiceNow instances:
361
+
362
+ ```javascript
363
+ SN-Add-Comment({
364
+ incident_number: "INC0012345",
365
+ comment: "Test comment",
366
+ instance: "dev" // Routes to dev instance
367
+ })
368
+ ```
369
+
370
+ ---
371
+
372
+ ## Benefits vs Generic Tools
373
+
374
+ ### Before (Generic Tool)
375
+ ```javascript
376
+ // Step 1: Look up incident
377
+ SN-Query-Table({
378
+ table_name: "incident",
379
+ query: "number=INC0012345",
380
+ limit: 1
381
+ })
382
+
383
+ // Step 2: Extract sys_id from response
384
+ // sys_id: abc123def456...
385
+
386
+ // Step 3: Update record
387
+ SN-Update-Record({
388
+ table_name: "incident",
389
+ sys_id: "abc123def456...",
390
+ data: { comments: "This is a comment" }
391
+ })
392
+ ```
393
+
394
+ ### After (Convenience Tool)
395
+ ```javascript
396
+ // One call, no sys_id needed
397
+ SN-Add-Comment({
398
+ incident_number: "INC0012345",
399
+ comment: "This is a comment"
400
+ })
401
+ ```
402
+
403
+ **Advantages:**
404
+ - 66% fewer tool calls (1 vs 3)
405
+ - No need to extract sys_ids from responses
406
+ - Clear intent in tool name
407
+ - User/group name resolution built-in
408
+ - Better error messages
409
+ - Validation included
410
+
411
+ ---
412
+
413
+ ## Testing
414
+
415
+ ### Test Scenarios
416
+
417
+ 1. **Add Comment**
418
+ - Valid incident number → Success
419
+ - Invalid incident number → Error "Incident not found"
420
+
421
+ 2. **Assign Incident**
422
+ - User by name → Resolves to sys_id, assigns
423
+ - User by sys_id → Direct assignment
424
+ - Invalid user → Error "User not found"
425
+ - Group by name → Resolves to sys_id, assigns
426
+ - Invalid group → Error "Group not found"
427
+
428
+ 3. **State Transitions**
429
+ - Resolve incident → State changes to 6
430
+ - Close incident → State changes to 7
431
+ - Close problem → State changes to 3
432
+
433
+ 4. **Multi-Instance**
434
+ - Default instance → Uses config default
435
+ - Specific instance → Routes to specified instance
436
+
437
+ ---
438
+
439
+ ## Usage Examples
440
+
441
+ ### Complete Incident Workflow
442
+
443
+ ```javascript
444
+ // 1. List open incidents
445
+ SN-List-Incidents({ state: "1", limit: 10 })
446
+
447
+ // 2. Add work notes
448
+ SN-Add-Work-Notes({
449
+ incident_number: "INC0012345",
450
+ work_notes: "Investigating root cause"
451
+ })
452
+
453
+ // 3. Assign to engineer
454
+ SN-Assign-Incident({
455
+ incident_number: "INC0012345",
456
+ assigned_to: "John Smith",
457
+ assignment_group: "Network Support"
458
+ })
459
+
460
+ // 4. Add customer comment
461
+ SN-Add-Comment({
462
+ incident_number: "INC0012345",
463
+ comment: "We are working on a fix"
464
+ })
465
+
466
+ // 5. Resolve when fixed
467
+ SN-Resolve-Incident({
468
+ incident_number: "INC0012345",
469
+ resolution_notes: "Network configuration corrected",
470
+ resolution_code: "Solved (Permanently)"
471
+ })
472
+
473
+ // 6. Close after confirmation
474
+ SN-Close-Incident({
475
+ incident_number: "INC0012345",
476
+ close_notes: "Customer confirmed resolution",
477
+ close_code: "Solved (Permanently)"
478
+ })
479
+ ```
480
+
481
+ ### Change Management Workflow
482
+
483
+ ```javascript
484
+ // 1. List pending changes
485
+ SN-List-ChangeRequests({ state: "Pending Approval", limit: 10 })
486
+
487
+ // 2. Assign for review
488
+ SN-Assign-Change({
489
+ change_number: "CHG0012345",
490
+ assigned_to: "Jane Doe",
491
+ assignment_group: "Change Advisory Board"
492
+ })
493
+
494
+ // 3. Add review comment
495
+ SN-Add-Change-Comment({
496
+ change_number: "CHG0012345",
497
+ comment: "Technical review completed, no issues found"
498
+ })
499
+
500
+ // 4. Approve change
501
+ SN-Approve-Change({
502
+ change_number: "CHG0012345",
503
+ approval_comments: "Approved for implementation on 2025-10-10"
504
+ })
505
+ ```
506
+
507
+ ### Problem Management Workflow
508
+
509
+ ```javascript
510
+ // 1. List active problems
511
+ SN-List-Problems({ state: "Open", limit: 10 })
512
+
513
+ // 2. Add analysis comment
514
+ SN-Add-Problem-Comment({
515
+ problem_number: "PRB0012345",
516
+ comment: "Root cause: memory leak in v1.0 application"
517
+ })
518
+
519
+ // 3. Close when resolved
520
+ SN-Close-Problem({
521
+ problem_number: "PRB0012345",
522
+ resolution_notes: "Upgraded to v2.0 with memory leak fix",
523
+ resolution_code: "Permanent Fix"
524
+ })
525
+ ```
526
+
527
+ ---
528
+
529
+ ## Future Enhancements
530
+
531
+ Potential additional convenience tools:
532
+
533
+ 1. **SN-Reopen-Incident** - Reopen a closed incident
534
+ 2. **SN-Escalate-Incident** - Escalate priority and notify management
535
+ 3. **SN-Link-Incidents** - Link related incidents (parent/child)
536
+ 4. **SN-Schedule-Change** - Schedule change with start/end times
537
+ 5. **SN-Add-Task** - Add task to incident/change/problem
538
+ 6. **SN-Attach-File** - Attach file to record
539
+ 7. **SN-Subscribe** - Subscribe user to record updates
540
+ 8. **SN-Merge-Incidents** - Merge duplicate incidents
541
+
542
+ ---
543
+
544
+ ## Comparison: Generic vs Convenience Tools
545
+
546
+ | Feature | Generic Tools | Convenience Tools |
547
+ |---------|--------------|-------------------|
548
+ | **Record Lookup** | Manual (SN-Query-Table) | Automatic (by number) |
549
+ | **sys_id Handling** | Required | Hidden |
550
+ | **User Resolution** | Manual lookup | Automatic |
551
+ | **Group Resolution** | Manual lookup | Automatic |
552
+ | **Validation** | Manual | Built-in |
553
+ | **Error Messages** | Generic | Context-specific |
554
+ | **Tool Calls** | 2-3 per operation | 1 per operation |
555
+ | **Intent Clarity** | Low ("Update Record") | High ("Resolve Incident") |
556
+ | **Learning Curve** | High | Low |
557
+
558
+ ---
559
+
560
+ ## Tool Count Summary
561
+
562
+ **Before:**
563
+ - Total MCP Tools: 34
564
+
565
+ **After:**
566
+ - Incident Tools: 5
567
+ - Change Request Tools: 3
568
+ - Problem Tools: 2
569
+ - **Total New Tools: 10**
570
+ - **Total MCP Tools: 44**
571
+
572
+ **Tool Categories:**
573
+ - Generic CRUD: 6 tools (Query, Create, Get, Update, Schema, List Tables)
574
+ - Update Set Management: 6 tools
575
+ - Workflow Tools: 4 tools
576
+ - Batch Operations: 2 tools
577
+ - ITSM Convenience: 10 tools (NEW)
578
+ - Other Specialized: 16 tools
579
+
580
+ ---
581
+
582
+ ## Documentation
583
+
584
+ - **API Reference**: `/docs/API_REFERENCE.md` (update in progress)
585
+ - **Setup Guide**: `/docs/SETUP_GUIDE.md`
586
+ - **This Guide**: `/docs/CONVENIENCE_TOOLS.md`
587
+
588
+ ---
589
+
590
+ ## Conclusion
591
+
592
+ The convenience tools dramatically improve the user experience for common ITSM operations by:
593
+
594
+ 1. **Hiding Technical Complexity**: No need to work with sys_ids
595
+ 2. **Reducing Tool Calls**: 66% fewer calls per operation
596
+ 3. **Better Intent Communication**: Tool names clearly indicate purpose
597
+ 4. **Automatic Resolution**: User and group names automatically resolved
598
+ 5. **Built-in Validation**: Error handling and record existence checks
599
+ 6. **Human-Friendly Responses**: Clear confirmation messages with context
600
+
601
+ These tools make ServiceNow operations accessible to users who may not be familiar with ServiceNow's internal data model while still leveraging the powerful generic tools under the hood.