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,1142 @@
1
+ # ServiceNow MCP Server - API Reference
2
+
3
+ **Version:** 2.1
4
+ **Last Updated:** 2025-10-06
5
+ **Total Tools:** 44
6
+
7
+ Complete reference for all MCP tools and resources available in the ServiceNow server.
8
+
9
+ ---
10
+
11
+ ## Table of Contents
12
+
13
+ 1. [Tool Categories](#tool-categories)
14
+ 2. [Generic CRUD Operations](#generic-crud-operations)
15
+ 3. [Specialized Tools](#specialized-tools)
16
+ 4. [Incident Management Convenience Tools](#incident-management-convenience-tools)
17
+ 5. [Change Request Convenience Tools](#change-request-convenience-tools)
18
+ 6. [Problem Management Convenience Tools](#problem-management-convenience-tools)
19
+ 7. [Update Set Management](#update-set-management)
20
+ 8. [Workflow Operations](#workflow-operations)
21
+ 9. [Schema & Discovery](#schema--discovery)
22
+ 10. [Batch Operations](#batch-operations)
23
+ 11. [MCP Resources](#mcp-resources)
24
+ 12. [Multi-Instance Support](#multi-instance-support)
25
+
26
+ ---
27
+
28
+ ## Tool Categories
29
+
30
+ ### 📊 **Generic CRUD Operations** (6 tools)
31
+ Work on **any** ServiceNow table (160+ supported)
32
+
33
+ ### 🎯 **Specialized Tools** (6 tools)
34
+ Table-specific list operations for core ITSM tables
35
+
36
+ ### 🎫 **Incident Management Convenience Tools** (5 tools)
37
+ User-friendly incident operations accepting incident numbers
38
+
39
+ ### 🔄 **Change Request Convenience Tools** (3 tools)
40
+ User-friendly change request operations accepting change numbers
41
+
42
+ ### ⚠️ **Problem Management Convenience Tools** (2 tools)
43
+ User-friendly problem operations accepting problem numbers
44
+
45
+ ### 📦 **Update Set Management** (6 tools)
46
+ Advanced update set operations
47
+
48
+ ### 🌊 **Workflow Operations** (4 tools)
49
+ Create and manage workflows programmatically
50
+
51
+ ### 🔍 **Schema & Discovery** (4 tools)
52
+ Table introspection and metadata
53
+
54
+ ### ⚡ **Batch Operations** (2 tools)
55
+ Efficient multi-record operations
56
+
57
+ ### 🔌 **Instance Management** (2 tools)
58
+ Multi-instance configuration and switching
59
+
60
+ ### 🛠️ **Script Execution** (2 tools)
61
+ Automated and manual background script execution
62
+
63
+ ### 📊 **Advanced Validation** (2 tools)
64
+ Configuration validation and field explanation
65
+
66
+ ---
67
+
68
+ ## Generic CRUD Operations
69
+
70
+ These tools work on **any** ServiceNow table.
71
+
72
+ ### SN-Query-Table
73
+
74
+ Query records from any table with advanced filtering.
75
+
76
+ **Parameters:**
77
+ ```javascript
78
+ {
79
+ "table_name": "incident", // Required: ServiceNow table name
80
+ "query": "state=1^priority=1", // Optional: Encoded query string
81
+ "fields": "number,short_description", // Optional: Comma-separated fields
82
+ "limit": 25, // Optional: Max records (default: 25)
83
+ "offset": 0, // Optional: Skip records for pagination
84
+ "order_by": "sys_created_on", // Optional: Sort field (prefix with - for desc)
85
+ "instance": "prod" // Optional: Target instance (uses default if omitted)
86
+ }
87
+ ```
88
+
89
+ **Example:**
90
+ ```javascript
91
+ SN-Query-Table({
92
+ "table_name": "incident",
93
+ "query": "active=true^state=1",
94
+ "fields": "number,short_description,priority",
95
+ "limit": 10
96
+ })
97
+ ```
98
+
99
+ ---
100
+
101
+ ### SN-Create-Record
102
+
103
+ Create a record in any table.
104
+
105
+ **Parameters:**
106
+ ```javascript
107
+ {
108
+ "table_name": "incident",
109
+ "data": {
110
+ "short_description": "Email server down",
111
+ "urgency": 1,
112
+ "impact": 2
113
+ },
114
+ "instance": "dev"
115
+ }
116
+ ```
117
+
118
+ **Returns:** Created record with sys_id
119
+
120
+ ---
121
+
122
+ ### SN-Get-Record
123
+
124
+ Get a single record by sys_id.
125
+
126
+ **Parameters:**
127
+ ```javascript
128
+ {
129
+ "table_name": "incident",
130
+ "sys_id": "abc123...",
131
+ "fields": "number,state,priority", // Optional
132
+ "instance": "prod"
133
+ }
134
+ ```
135
+
136
+ ---
137
+
138
+ ### SN-Update-Record
139
+
140
+ Update an existing record.
141
+
142
+ **Parameters:**
143
+ ```javascript
144
+ {
145
+ "table_name": "incident",
146
+ "sys_id": "abc123...",
147
+ "data": {
148
+ "state": 6,
149
+ "resolution_notes": "Issue resolved"
150
+ },
151
+ "instance": "prod"
152
+ }
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Specialized Tools
158
+
159
+ ### Core ITSM Tables
160
+
161
+ Each major table has specialized tools:
162
+
163
+ - **Incidents:** `SN-List-Incidents`, `SN-Create-Incident`, `SN-Get-Incident`
164
+ - **Changes:** `SN-List-ChangeRequests`
165
+ - **Problems:** `SN-List-Problems`
166
+ - **Users:** `SN-List-SysUsers`
167
+ - **Groups:** `SN-List-SysUserGroups`
168
+ - **CMDB:** `SN-List-CmdbCis`
169
+
170
+ **Example:**
171
+ ```javascript
172
+ SN-List-Incidents({
173
+ "query": "state=1^priority=1",
174
+ "limit": 10,
175
+ "instance": "prod"
176
+ })
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Incident Management Convenience Tools
182
+
183
+ User-friendly tools that accept incident numbers instead of sys_ids.
184
+
185
+ ### SN-Add-Comment
186
+
187
+ Add a comment to an incident using the incident number.
188
+
189
+ **Parameters:**
190
+ ```javascript
191
+ {
192
+ "incident_number": "INC0012345", // Required
193
+ "comment": "Investigating the issue with the user",
194
+ "instance": "prod" // Optional
195
+ }
196
+ ```
197
+
198
+ **Example:**
199
+ ```javascript
200
+ SN-Add-Comment({
201
+ "incident_number": "INC0012345",
202
+ "comment": "User confirmed the issue started after last deployment"
203
+ })
204
+ ```
205
+
206
+ ---
207
+
208
+ ### SN-Add-Work-Notes
209
+
210
+ Add work notes to an incident (internal notes not visible to users).
211
+
212
+ **Parameters:**
213
+ ```javascript
214
+ {
215
+ "incident_number": "INC0012345", // Required
216
+ "work_notes": "Checked logs, found database connection timeout",
217
+ "instance": "prod" // Optional
218
+ }
219
+ ```
220
+
221
+ **Example:**
222
+ ```javascript
223
+ SN-Add-Work-Notes({
224
+ "incident_number": "INC0012345",
225
+ "work_notes": "Applied hotfix to production server"
226
+ })
227
+ ```
228
+
229
+ ---
230
+
231
+ ### SN-Assign-Incident
232
+
233
+ Assign an incident to a user and/or group. Automatically resolves user names to sys_ids.
234
+
235
+ **Parameters:**
236
+ ```javascript
237
+ {
238
+ "incident_number": "INC0012345", // Required
239
+ "assigned_to": "John Smith", // User name or sys_id
240
+ "assignment_group": "Network Team", // Optional: Group name or sys_id
241
+ "instance": "prod" // Optional
242
+ }
243
+ ```
244
+
245
+ **Example:**
246
+ ```javascript
247
+ SN-Assign-Incident({
248
+ "incident_number": "INC0012345",
249
+ "assigned_to": "John Smith",
250
+ "assignment_group": "IT Support"
251
+ })
252
+ ```
253
+
254
+ **Features:**
255
+ - Accepts user name or sys_id for `assigned_to`
256
+ - Accepts group name or sys_id for `assignment_group`
257
+ - Automatically looks up sys_ids from names
258
+
259
+ ---
260
+
261
+ ### SN-Resolve-Incident
262
+
263
+ Resolve an incident with resolution notes.
264
+
265
+ **Parameters:**
266
+ ```javascript
267
+ {
268
+ "incident_number": "INC0012345", // Required
269
+ "resolution_notes": "Restarted service, issue resolved",
270
+ "resolution_code": "Solved (Permanently)", // Optional
271
+ "instance": "prod" // Optional
272
+ }
273
+ ```
274
+
275
+ **Example:**
276
+ ```javascript
277
+ SN-Resolve-Incident({
278
+ "incident_number": "INC0012345",
279
+ "resolution_notes": "Database connection pool was exhausted. Increased pool size from 10 to 20.",
280
+ "resolution_code": "Solved (Permanently)"
281
+ })
282
+ ```
283
+
284
+ **Resolution Codes:**
285
+ - "Solved (Permanently)"
286
+ - "Solved (Work Around)"
287
+ - "Not Solved (Not Reproducible)"
288
+ - "Not Solved (Too Costly)"
289
+
290
+ ---
291
+
292
+ ### SN-Close-Incident
293
+
294
+ Close an incident with close notes.
295
+
296
+ **Parameters:**
297
+ ```javascript
298
+ {
299
+ "incident_number": "INC0012345", // Required
300
+ "close_notes": "Confirmed fix is working in production",
301
+ "close_code": "Solved (Permanently)", // Optional
302
+ "instance": "prod" // Optional
303
+ }
304
+ ```
305
+
306
+ **Example:**
307
+ ```javascript
308
+ SN-Close-Incident({
309
+ "incident_number": "INC0012345",
310
+ "close_notes": "User confirmed issue is resolved. Monitoring for 24 hours showed no recurrence.",
311
+ "close_code": "Solved (Permanently)"
312
+ })
313
+ ```
314
+
315
+ ---
316
+
317
+ ## Change Request Convenience Tools
318
+
319
+ User-friendly tools for managing change requests.
320
+
321
+ ### SN-Add-Change-Comment
322
+
323
+ Add a comment to a change request.
324
+
325
+ **Parameters:**
326
+ ```javascript
327
+ {
328
+ "change_number": "CHG0012345", // Required
329
+ "comment": "Risk assessment completed",
330
+ "instance": "prod" // Optional
331
+ }
332
+ ```
333
+
334
+ **Example:**
335
+ ```javascript
336
+ SN-Add-Change-Comment({
337
+ "change_number": "CHG0012345",
338
+ "comment": "All CAB members have reviewed and approved the change plan"
339
+ })
340
+ ```
341
+
342
+ ---
343
+
344
+ ### SN-Assign-Change
345
+
346
+ Assign a change request to a user and/or group.
347
+
348
+ **Parameters:**
349
+ ```javascript
350
+ {
351
+ "change_number": "CHG0012345", // Required
352
+ "assigned_to": "Jane Doe", // User name or sys_id
353
+ "assignment_group": "Change Management", // Optional
354
+ "instance": "prod" // Optional
355
+ }
356
+ ```
357
+
358
+ **Example:**
359
+ ```javascript
360
+ SN-Assign-Change({
361
+ "change_number": "CHG0012345",
362
+ "assigned_to": "Jane Doe",
363
+ "assignment_group": "Change Management"
364
+ })
365
+ ```
366
+
367
+ ---
368
+
369
+ ### SN-Approve-Change
370
+
371
+ Approve a change request.
372
+
373
+ **Parameters:**
374
+ ```javascript
375
+ {
376
+ "change_number": "CHG0012345", // Required
377
+ "approval_comments": "Risk is acceptable, approved for production", // Optional
378
+ "instance": "prod" // Optional
379
+ }
380
+ ```
381
+
382
+ **Example:**
383
+ ```javascript
384
+ SN-Approve-Change({
385
+ "change_number": "CHG0012345",
386
+ "approval_comments": "CAB approved. Proceed with scheduled maintenance window."
387
+ })
388
+ ```
389
+
390
+ ---
391
+
392
+ ## Problem Management Convenience Tools
393
+
394
+ User-friendly tools for managing problems.
395
+
396
+ ### SN-Add-Problem-Comment
397
+
398
+ Add a comment to a problem record.
399
+
400
+ **Parameters:**
401
+ ```javascript
402
+ {
403
+ "problem_number": "PRB0012345", // Required
404
+ "comment": "Root cause identified in database configuration",
405
+ "instance": "prod" // Optional
406
+ }
407
+ ```
408
+
409
+ **Example:**
410
+ ```javascript
411
+ SN-Add-Problem-Comment({
412
+ "problem_number": "PRB0012345",
413
+ "comment": "RCA complete. Issue caused by insufficient connection pool size during peak hours."
414
+ })
415
+ ```
416
+
417
+ ---
418
+
419
+ ### SN-Close-Problem
420
+
421
+ Close a problem with resolution information.
422
+
423
+ **Parameters:**
424
+ ```javascript
425
+ {
426
+ "problem_number": "PRB0012345", // Required
427
+ "resolution_notes": "Database pool size increased, monitoring confirms fix",
428
+ "resolution_code": "Fix Applied", // Optional
429
+ "instance": "prod" // Optional
430
+ }
431
+ ```
432
+
433
+ **Example:**
434
+ ```javascript
435
+ SN-Close-Problem({
436
+ "problem_number": "PRB0012345",
437
+ "resolution_notes": "Permanent fix deployed: increased connection pool from 10 to 50 connections. No incidents reported in 2 weeks.",
438
+ "resolution_code": "Fix Applied"
439
+ })
440
+ ```
441
+
442
+ ---
443
+
444
+ ## Update Set Management
445
+
446
+ ### SN-Get-Current-Update-Set
447
+
448
+ Get the currently active update set.
449
+
450
+ **Parameters:**
451
+ ```javascript
452
+ {
453
+ "instance": "dev"
454
+ }
455
+ ```
456
+
457
+ **Returns:**
458
+ ```json
459
+ {
460
+ "sys_id": "abc123...",
461
+ "name": "My Update Set",
462
+ "state": "in progress"
463
+ }
464
+ ```
465
+
466
+ ---
467
+
468
+ ### SN-Set-Update-Set
469
+
470
+ Set the current update set programmatically.
471
+
472
+ **Parameters:**
473
+ ```javascript
474
+ {
475
+ "update_set_sys_id": "abc123...",
476
+ "instance": "dev"
477
+ }
478
+ ```
479
+
480
+ **Implementation:** Uses automated background script execution via `sys_trigger`
481
+
482
+ ---
483
+
484
+ ### SN-List-Update-Sets
485
+
486
+ List available update sets with filtering.
487
+
488
+ **Parameters:**
489
+ ```javascript
490
+ {
491
+ "query": "state=in progress",
492
+ "limit": 25,
493
+ "order_by": "-sys_created_on",
494
+ "instance": "dev"
495
+ }
496
+ ```
497
+
498
+ ---
499
+
500
+ ### SN-Move-Records-To-Update-Set
501
+
502
+ Move sys_update_xml records between update sets.
503
+
504
+ **Parameters:**
505
+ ```javascript
506
+ {
507
+ "update_set_id": "target_sys_id",
508
+ "source_update_set": "Default", // Optional: filter by source
509
+ "record_sys_ids": ["id1", "id2"], // Optional: specific records
510
+ "time_range": { // Optional: time filter
511
+ "start": "2025-09-29 20:00:00",
512
+ "end": "2025-09-29 20:03:31"
513
+ },
514
+ "instance": "dev"
515
+ }
516
+ ```
517
+
518
+ **Use Case:** Fix records that went to wrong update set
519
+
520
+ ---
521
+
522
+ ### SN-Clone-Update-Set
523
+
524
+ Clone an entire update set with all records.
525
+
526
+ **Parameters:**
527
+ ```javascript
528
+ {
529
+ "source_update_set_id": "abc123...",
530
+ "new_name": "Clone of Original",
531
+ "instance": "dev"
532
+ }
533
+ ```
534
+
535
+ ---
536
+
537
+ ### SN-Inspect-Update-Set
538
+
539
+ Inspect update set contents and dependencies.
540
+
541
+ **Parameters:**
542
+ ```javascript
543
+ {
544
+ "update_set": "abc123...",
545
+ "show_components": true,
546
+ "show_dependencies": false,
547
+ "instance": "dev"
548
+ }
549
+ ```
550
+
551
+ ---
552
+
553
+ ## Workflow Operations
554
+
555
+ ### SN-Create-Workflow
556
+
557
+ Create a complete workflow with activities and transitions.
558
+
559
+ **Parameters:**
560
+ ```javascript
561
+ {
562
+ "name": "Auto-Approve Change",
563
+ "table": "change_request",
564
+ "description": "Automatically approve low-risk changes",
565
+ "activities": [
566
+ {
567
+ "name": "Check Risk",
568
+ "script": "if (current.risk == '4') { answer = 'yes'; }"
569
+ },
570
+ {
571
+ "name": "Auto Approve",
572
+ "script": "current.approval = 'approved'; current.update();"
573
+ }
574
+ ],
575
+ "transitions": [
576
+ {
577
+ "from": "Check Risk",
578
+ "to": "Auto Approve",
579
+ "condition_script": "answer == 'yes'"
580
+ }
581
+ ],
582
+ "publish": false,
583
+ "instance": "dev"
584
+ }
585
+ ```
586
+
587
+ ---
588
+
589
+ ### SN-Create-Activity
590
+
591
+ Create a single workflow activity.
592
+
593
+ **Parameters:**
594
+ ```javascript
595
+ {
596
+ "workflow_version_sys_id": "abc123...",
597
+ "name": "Send Notification",
598
+ "script": "gs.eventQueue('incident.resolved', current);",
599
+ "x": 100, // Canvas position
600
+ "y": 100,
601
+ "instance": "dev"
602
+ }
603
+ ```
604
+
605
+ ---
606
+
607
+ ### SN-Publish-Workflow
608
+
609
+ Publish a workflow version.
610
+
611
+ **Parameters:**
612
+ ```javascript
613
+ {
614
+ "version_sys_id": "abc123...",
615
+ "start_activity_sys_id": "def456...",
616
+ "instance": "dev"
617
+ }
618
+ ```
619
+
620
+ ---
621
+
622
+ ## Schema & Discovery
623
+
624
+ ### SN-Get-Table-Schema
625
+
626
+ Get basic table schema information.
627
+
628
+ **Parameters:**
629
+ ```javascript
630
+ {
631
+ "table_name": "incident",
632
+ "instance": "prod"
633
+ }
634
+ ```
635
+
636
+ **Returns:** Field names, types, labels
637
+
638
+ ---
639
+
640
+ ### SN-Discover-Table-Schema
641
+
642
+ Get comprehensive table metadata with relationships.
643
+
644
+ **Parameters:**
645
+ ```javascript
646
+ {
647
+ "table_name": "sys_hub_flow",
648
+ "include_relationships": true,
649
+ "include_field_constraints": true,
650
+ "include_type_codes": true,
651
+ "include_choice_tables": true,
652
+ "include_ui_policies": false,
653
+ "include_business_rules": false,
654
+ "instance": "dev"
655
+ }
656
+ ```
657
+
658
+ **Returns:** Complete schema with:
659
+ - Field definitions
660
+ - Reference relationships
661
+ - Choice tables
662
+ - Field constraints
663
+ - Type codes
664
+
665
+ ---
666
+
667
+ ### SN-List-Available-Tables
668
+
669
+ List all available ServiceNow tables.
670
+
671
+ **Parameters:**
672
+ ```javascript
673
+ {
674
+ "category": "core_itsm", // Optional: filter by category
675
+ "instance": "prod"
676
+ }
677
+ ```
678
+
679
+ **Categories:** `core_itsm`, `platform`, `service_catalog`, `cmdb`, `all`
680
+
681
+ ---
682
+
683
+ ### SN-Explain-Field
684
+
685
+ Get detailed explanation of a specific field.
686
+
687
+ **Parameters:**
688
+ ```javascript
689
+ {
690
+ "table": "catalog_ui_policy_action",
691
+ "field": "catalog_variable",
692
+ "include_examples": true,
693
+ "instance": "dev"
694
+ }
695
+ ```
696
+
697
+ ---
698
+
699
+ ## Batch Operations
700
+
701
+ ### SN-Batch-Create
702
+
703
+ Create multiple records in a single operation.
704
+
705
+ **Parameters:**
706
+ ```javascript
707
+ {
708
+ "operations": [
709
+ {
710
+ "table": "incident",
711
+ "data": { "short_description": "Issue 1" },
712
+ "save_as": "incident1"
713
+ },
714
+ {
715
+ "table": "incident_task",
716
+ "data": {
717
+ "parent": "${incident1}", // Reference previous record
718
+ "short_description": "Task 1"
719
+ }
720
+ }
721
+ ],
722
+ "transaction": true, // All-or-nothing
723
+ "instance": "dev"
724
+ }
725
+ ```
726
+
727
+ ---
728
+
729
+ ### SN-Batch-Update
730
+
731
+ Update multiple records efficiently.
732
+
733
+ **Parameters:**
734
+ ```javascript
735
+ {
736
+ "updates": [
737
+ {
738
+ "table": "incident",
739
+ "sys_id": "abc123...",
740
+ "data": { "state": 6 }
741
+ },
742
+ {
743
+ "table": "incident",
744
+ "sys_id": "def456...",
745
+ "data": { "state": 6 }
746
+ }
747
+ ],
748
+ "stop_on_error": false,
749
+ "instance": "dev"
750
+ }
751
+ ```
752
+
753
+ ---
754
+
755
+ ## Background Script Execution
756
+
757
+ ### SN-Execute-Background-Script
758
+
759
+ Execute JavaScript server-side with automated sys_trigger execution.
760
+
761
+ **Parameters:**
762
+ ```javascript
763
+ {
764
+ "script": "gs.info('Hello from script');",
765
+ "description": "Test script execution",
766
+ "execution_method": "trigger", // trigger (default), ui, or auto
767
+ "instance": "dev"
768
+ }
769
+ ```
770
+
771
+ **Execution Methods:**
772
+ - `trigger` (recommended): Uses sys_trigger, runs in ~1 second, auto-deletes
773
+ - `ui`: Attempts direct UI endpoint execution
774
+ - `auto`: Tries trigger, then ui, then creates fix script
775
+
776
+ **Returns:** Success status and trigger details
777
+
778
+ ---
779
+
780
+ ### SN-Create-Fix-Script
781
+
782
+ Generate a script file for manual execution (fallback).
783
+
784
+ **Parameters:**
785
+ ```javascript
786
+ {
787
+ "script_name": "link_ui_policy_actions",
788
+ "script_content": "var gr = new GlideRecord('...'); gr.update();",
789
+ "description": "Link UI policy actions to policies",
790
+ "auto_delete": true, // Delete script file after execution
791
+ "instance": "dev"
792
+ }
793
+ ```
794
+
795
+ **Use Case:** When automated execution is not available
796
+
797
+ ---
798
+
799
+ ## MCP Resources
800
+
801
+ MCP Resources provide read-only access to ServiceNow metadata and configuration information. Unlike tools (which perform actions), resources return static or semi-static data that can be cached and referenced.
802
+
803
+ ### Understanding Resources vs Tools
804
+
805
+ **Tools:**
806
+ - Perform actions (create, update, delete)
807
+ - Accept parameters and return results
808
+ - Execute operations that modify state
809
+ - Example: `SN-Create-Incident`, `SN-Update-Record`
810
+
811
+ **Resources:**
812
+ - Provide read-only data access
813
+ - Can be cached by the MCP client
814
+ - Return metadata and configuration
815
+ - Example: Instance info, table schemas
816
+
817
+ ### Available Resources
818
+
819
+ #### servicenow://instance
820
+
821
+ Returns information about the currently connected ServiceNow instance.
822
+
823
+ **URI:** `servicenow://instance`
824
+
825
+ **Returns:**
826
+ ```json
827
+ {
828
+ "server_info": {
829
+ "name": "ServiceNow MCP Server (Consolidated)",
830
+ "version": "2.0.0",
831
+ "description": "Consolidated ServiceNow integration with metadata-driven schema lookups"
832
+ },
833
+ "instance_info": {
834
+ "url": "https://dev123.service-now.com",
835
+ "username": "admin"
836
+ },
837
+ "capabilities": {
838
+ "total_tables": 160,
839
+ "operations": ["create", "read", "update", "query", "schema_lookup"],
840
+ "tools": 44
841
+ }
842
+ }
843
+ ```
844
+
845
+ **Usage:**
846
+ - Check current connection status
847
+ - Verify instance configuration
848
+ - View available capabilities
849
+
850
+ ---
851
+
852
+ #### servicenow://tables/all
853
+
854
+ Returns complete metadata for all available ServiceNow tables.
855
+
856
+ **URI:** `servicenow://tables/all`
857
+
858
+ **Returns:**
859
+ ```json
860
+ {
861
+ "incident": {
862
+ "name": "incident",
863
+ "label": "Incident",
864
+ "key_field": "number",
865
+ "required_fields": ["short_description"],
866
+ "common_fields": ["number", "short_description", "description", "priority", "state"],
867
+ "description": "ITSM incident management table"
868
+ },
869
+ "change_request": {
870
+ "name": "change_request",
871
+ "label": "Change Request",
872
+ "key_field": "number",
873
+ "required_fields": ["short_description"],
874
+ "common_fields": ["number", "short_description", "risk", "impact"],
875
+ "description": "Change management requests"
876
+ }
877
+ // ... 160+ more tables
878
+ }
879
+ ```
880
+
881
+ **Usage:**
882
+ - Discover available tables
883
+ - View required and common fields
884
+ - Find key fields for each table
885
+ - Build dynamic queries and forms
886
+
887
+ ---
888
+
889
+ ### Reading Resources
890
+
891
+ **Via MCP SDK:**
892
+ ```javascript
893
+ // Read instance information
894
+ const instance = await client.readResource('servicenow://instance');
895
+
896
+ // Read all table metadata
897
+ const tables = await client.readResource('servicenow://tables/all');
898
+ ```
899
+
900
+ **Via HTTP (when using HTTP transport):**
901
+ ```bash
902
+ # List available resources
903
+ curl http://localhost:3000/mcp/resources
904
+
905
+ # Read specific resource
906
+ curl http://localhost:3000/mcp/resources/servicenow://instance
907
+ ```
908
+
909
+ ---
910
+
911
+ ## Multi-Instance Support
912
+
913
+ All tools support the `instance` parameter to route requests to specific ServiceNow instances.
914
+
915
+ ### Configuration
916
+
917
+ Set up multiple instances in `config/servicenow-instances.json`:
918
+
919
+ ```json
920
+ {
921
+ "instances": [
922
+ {
923
+ "name": "dev",
924
+ "url": "https://dev123.service-now.com",
925
+ "username": "admin",
926
+ "password": "password",
927
+ "default": true
928
+ },
929
+ {
930
+ "name": "prod",
931
+ "url": "https://prod456.service-now.com",
932
+ "username": "integration",
933
+ "password": "password"
934
+ }
935
+ ]
936
+ }
937
+ ```
938
+
939
+ ### Usage
940
+
941
+ **Default Instance:**
942
+ ```javascript
943
+ SN-List-Incidents({ "limit": 10 })
944
+ ```
945
+
946
+ **Specific Instance:**
947
+ ```javascript
948
+ SN-List-Incidents({ "limit": 10, "instance": "prod" })
949
+ ```
950
+
951
+ ### List Instances
952
+
953
+ ```bash
954
+ curl http://localhost:3000/instances
955
+ ```
956
+
957
+ ---
958
+
959
+ ## Error Handling
960
+
961
+ All tools return errors in this format:
962
+
963
+ ```json
964
+ {
965
+ "error": "Error message",
966
+ "details": "Detailed explanation",
967
+ "instance": "dev",
968
+ "table": "incident"
969
+ }
970
+ ```
971
+
972
+ **Common Errors:**
973
+ - `400` - Invalid parameters
974
+ - `401` - Authentication failed
975
+ - `403` - Permission denied
976
+ - `404` - Record/table not found
977
+ - `500` - ServiceNow API error
978
+
979
+ ---
980
+
981
+ ## Rate Limiting
982
+
983
+ ServiceNow enforces rate limits on API calls:
984
+ - **Standard:** 1000 requests per hour per user
985
+ - **Batch operations** count as multiple requests
986
+ - Use pagination with `limit` and `offset` for large datasets
987
+
988
+ ---
989
+
990
+ ## Best Practices
991
+
992
+ 1. **Use Convenience Tools** for common ITSM operations (SN-Add-Comment, SN-Assign-Incident, etc.)
993
+ - Accept human-readable identifiers (incident numbers, user names)
994
+ - Automatically resolve sys_ids
995
+ - Provide better error messages
996
+
997
+ 2. **Use Generic Tools** (`SN-Query-Table`) for flexibility and custom tables
998
+ - Works on any ServiceNow table
999
+ - Required for tables without specialized tools
1000
+
1001
+ 3. **Batch Operations** for multiple record operations
1002
+ - Up to 50+ operations in a single call
1003
+ - Transactional support for data integrity
1004
+ - Progress notifications for long-running operations
1005
+
1006
+ 4. **Field Selection** to reduce payload size
1007
+ - Use `fields` parameter to specify only needed fields
1008
+ - Reduces network transfer and improves performance
1009
+ - Example: `fields: "number,short_description,state"`
1010
+
1011
+ 5. **Pagination** for large result sets
1012
+ - Use `limit` and `offset` for controlled data retrieval
1013
+ - Default limit is 25, maximum is typically 1000
1014
+ - Implement pagination for tables with many records
1015
+
1016
+ 6. **Update Sets** to track configuration changes
1017
+ - Always set update set BEFORE making config changes
1018
+ - Use `SN-Set-Update-Set` for automated setup
1019
+ - Verify with `SN-Get-Current-Update-Set`
1020
+
1021
+ 7. **Instance Parameter** to target correct environment
1022
+ - Specify `instance` parameter for multi-instance setups
1023
+ - Default instance used if not specified
1024
+ - Use `SN-Set-Instance` or `SN-Get-Current-Instance` for management
1025
+
1026
+ 8. **Background Scripts** for complex operations
1027
+ - Use `SN-Execute-Background-Script` with trigger method
1028
+ - Executes in ~1 second, fully automated
1029
+ - Fallback to fix script if needed
1030
+
1031
+ 9. **MCP Resources** for metadata discovery
1032
+ - Cache resource data to avoid repeated queries
1033
+ - Use `servicenow://tables/all` for table discovery
1034
+ - Check `servicenow://instance` for connection verification
1035
+
1036
+ ---
1037
+
1038
+ ## Quick Reference - All Tools
1039
+
1040
+ ### Generic CRUD (6 tools)
1041
+ - `SN-Query-Table` - Query any table with filters
1042
+ - `SN-Create-Record` - Create record in any table
1043
+ - `SN-Get-Record` - Get single record by sys_id
1044
+ - `SN-Update-Record` - Update existing record
1045
+ - `SN-Get-Table-Schema` - Get basic table schema
1046
+ - `SN-List-Available-Tables` - List all available tables
1047
+
1048
+ ### Specialized List Tools (6 tools)
1049
+ - `SN-List-Incidents` - List incidents with filters
1050
+ - `SN-Create-Incident` - Create new incident
1051
+ - `SN-Get-Incident` - Get incident by sys_id
1052
+ - `SN-List-ChangeRequests` - List change requests
1053
+ - `SN-List-Problems` - List problems
1054
+ - `SN-List-SysUsers` - List users
1055
+ - `SN-List-SysUserGroups` - List user groups
1056
+ - `SN-List-CmdbCis` - List configuration items
1057
+
1058
+ ### Incident Convenience (5 tools)
1059
+ - `SN-Add-Comment` - Add comment by incident number
1060
+ - `SN-Add-Work-Notes` - Add work notes by incident number
1061
+ - `SN-Assign-Incident` - Assign incident (resolves user names)
1062
+ - `SN-Resolve-Incident` - Resolve incident with notes
1063
+ - `SN-Close-Incident` - Close incident with notes
1064
+
1065
+ ### Change Request Convenience (3 tools)
1066
+ - `SN-Add-Change-Comment` - Add comment by change number
1067
+ - `SN-Assign-Change` - Assign change request
1068
+ - `SN-Approve-Change` - Approve change request
1069
+
1070
+ ### Problem Convenience (2 tools)
1071
+ - `SN-Add-Problem-Comment` - Add comment by problem number
1072
+ - `SN-Close-Problem` - Close problem with resolution
1073
+
1074
+ ### Update Set Management (6 tools)
1075
+ - `SN-Get-Current-Update-Set` - Get active update set
1076
+ - `SN-Set-Update-Set` - Set current update set (automated)
1077
+ - `SN-List-Update-Sets` - List all update sets
1078
+ - `SN-Move-Records-To-Update-Set` - Move records between sets
1079
+ - `SN-Clone-Update-Set` - Clone entire update set
1080
+ - `SN-Inspect-Update-Set` - Inspect update set contents
1081
+
1082
+ ### Workflow Operations (4 tools)
1083
+ - `SN-Create-Workflow` - Create complete workflow
1084
+ - `SN-Create-Activity` - Add workflow activity
1085
+ - `SN-Create-Transition` - Link workflow activities
1086
+ - `SN-Publish-Workflow` - Publish workflow version
1087
+
1088
+ ### Schema & Discovery (4 tools)
1089
+ - `SN-Discover-Table-Schema` - Deep schema with relationships
1090
+ - `SN-Explain-Field` - Detailed field documentation
1091
+ - `SN-Validate-Configuration` - Validate catalog config
1092
+ - `SN-Inspect-Update-Set` - Inspect update set (also in Update Set)
1093
+
1094
+ ### Batch Operations (2 tools)
1095
+ - `SN-Batch-Create` - Create multiple records with references
1096
+ - `SN-Batch-Update` - Update multiple records efficiently
1097
+
1098
+ ### Instance Management (2 tools)
1099
+ - `SN-Set-Instance` - Switch to different instance
1100
+ - `SN-Get-Current-Instance` - Get current instance info
1101
+
1102
+ ### Script Execution (2 tools)
1103
+ - `SN-Execute-Background-Script` - Automated script execution
1104
+ - `SN-Create-Fix-Script` - Generate script for manual execution
1105
+
1106
+ ### Application Scope (1 tool)
1107
+ - `SN-Set-Current-Application` - Set current application scope
1108
+
1109
+ ---
1110
+
1111
+ ## MCP Resources (2 resources)
1112
+
1113
+ - `servicenow://instance` - Instance info and capabilities
1114
+ - `servicenow://tables/all` - Complete table metadata
1115
+
1116
+ ---
1117
+
1118
+ ## Additional Documentation
1119
+
1120
+ - **Setup Guide:** `docs/SETUP_GUIDE.md`
1121
+ - **Multi-Instance Config:** `docs/MULTI_INSTANCE_CONFIGURATION.md`
1122
+ - **Instance Switching:** `docs/INSTANCE_SWITCHING_GUIDE.md`
1123
+ - **Troubleshooting:** `docs/403_TROUBLESHOOTING.md`
1124
+ - **Research & Breakthroughs:** `docs/research/`
1125
+
1126
+ ---
1127
+
1128
+ ## Summary
1129
+
1130
+ **Total Tools:** 44
1131
+ **Total Resources:** 2
1132
+ **Supported Tables:** 160+
1133
+ **Instance Support:** Unlimited (via config)
1134
+
1135
+ **Key Features:**
1136
+ - Generic tools work on any ServiceNow table
1137
+ - Convenience tools for better UX (accept numbers/names instead of sys_ids)
1138
+ - Automated background script execution via sys_trigger
1139
+ - Multi-instance support with easy switching
1140
+ - Batch operations with progress notifications
1141
+ - MCP resources for metadata discovery
1142
+ - Comprehensive schema introspection