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.
- package/.claude/settings.local.json +70 -0
- package/CLAUDE.md +777 -0
- package/LICENSE +21 -0
- package/README.md +562 -0
- package/assets/logo.svg +385 -0
- package/config/servicenow-instances.json.example +28 -0
- package/docs/403_TROUBLESHOOTING.md +329 -0
- package/docs/API_REFERENCE.md +1142 -0
- package/docs/APPLICATION_SCOPE_VALIDATION.md +681 -0
- package/docs/CLAUDE_DESKTOP_SETUP.md +373 -0
- package/docs/CONVENIENCE_TOOLS.md +601 -0
- package/docs/CONVENIENCE_TOOLS_SUMMARY.md +371 -0
- package/docs/FLOW_DESIGNER_GUIDE.md +1021 -0
- package/docs/IMPLEMENTATION_COMPLETE.md +165 -0
- package/docs/INSTANCE_SWITCHING_GUIDE.md +219 -0
- package/docs/MULTI_INSTANCE_CONFIGURATION.md +185 -0
- package/docs/NATURAL_LANGUAGE_SEARCH_IMPLEMENTATION.md +221 -0
- package/docs/PUPPETEER_INTEGRATION_PROPOSAL.md +1322 -0
- package/docs/QUICK_REFERENCE.md +395 -0
- package/docs/README.md +75 -0
- package/docs/RESOURCES_ARCHITECTURE.md +392 -0
- package/docs/RESOURCES_IMPLEMENTATION.md +276 -0
- package/docs/RESOURCES_SUMMARY.md +104 -0
- package/docs/SETUP_GUIDE.md +104 -0
- package/docs/UI_OPERATIONS_ARCHITECTURE.md +1219 -0
- package/docs/UI_OPERATIONS_DECISION_MATRIX.md +542 -0
- package/docs/UI_OPERATIONS_SUMMARY.md +507 -0
- package/docs/UPDATE_SET_VALIDATION.md +598 -0
- package/docs/UPDATE_SET_VALIDATION_SUMMARY.md +209 -0
- package/docs/VALIDATION_SUMMARY.md +479 -0
- package/jest.config.js +24 -0
- package/package.json +61 -0
- package/scripts/background_script_2025-09-29T20-19-35-101Z.js +23 -0
- package/scripts/link_ui_policy_actions_2025-09-29T20-17-15-218Z.js +90 -0
- package/scripts/set_update_set_Integration_Governance_Framework_2025-09-29T19-47-06-790Z.js +30 -0
- package/scripts/set_update_set_Integration_Governance_Framework_2025-09-29T19-59-33-152Z.js +30 -0
- package/scripts/set_update_set_current_2025-09-29T20-16-59-675Z.js +24 -0
- package/scripts/test_sys_dictionary_403.js +85 -0
- package/setup/setup-report.json +5313 -0
- package/src/config/comprehensive-table-definitions.json +2575 -0
- package/src/config/instance-config.json +4693 -0
- package/src/config/prompts.md +59 -0
- package/src/config/table-definitions.json +4681 -0
- package/src/config-manager.js +146 -0
- package/src/mcp-server-consolidated.js +2894 -0
- package/src/natural-language.js +472 -0
- package/src/resources.js +326 -0
- package/src/script-sync.js +428 -0
- package/src/server.js +125 -0
- package/src/servicenow-client.js +1625 -0
- package/src/stdio-server.js +52 -0
- package/start-mcp.sh +7 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Natural Language Search Tool - Implementation Summary
|
|
2
|
+
|
|
3
|
+
## ✅ IMPLEMENTATION COMPLETE
|
|
4
|
+
|
|
5
|
+
All components have been successfully implemented and tested.
|
|
6
|
+
|
|
7
|
+
## Files Created
|
|
8
|
+
|
|
9
|
+
### `/src/natural-language.js` - COMPLETED
|
|
10
|
+
Pattern-based natural language query parser with the following features:
|
|
11
|
+
|
|
12
|
+
**Supported Patterns:**
|
|
13
|
+
1. **Priority**: "high priority", "P1", "priority 2", "critical priority" → `priority=1`
|
|
14
|
+
2. **Assignment**: "assigned to me", "unassigned", "assigned to John Smith" → `assigned_to=javascript:gs.getUserID()` or `assigned_toISEMPTY`
|
|
15
|
+
3. **State**: "new", "open", "closed", "in progress" → `state=1` (table-dependent mappings)
|
|
16
|
+
4. **Dates**: "created today", "last 7 days", "recent", "opened yesterday" → `sys_created_on>javascript:gs.daysAgo(7)`
|
|
17
|
+
5. **Content**: "about SAP", "containing error" → `short_descriptionLIKESAP^ORdescriptionLIKESAP`
|
|
18
|
+
6. **Impact/Urgency**: "high impact", "medium urgency" → `impact=1`, `urgency=2`
|
|
19
|
+
7. **Numbers**: "number is INC0012345" → `number=INC0012345`
|
|
20
|
+
8. **Caller**: "caller is John Smith" → `caller_id.nameLIKEJohn Smith`
|
|
21
|
+
9. **Category**: "category is Software" → `categoryLIKESoftware`
|
|
22
|
+
10. **Assignment Group**: "assignment group is Network Team" → `assignment_group.nameLIKENetwork Team`
|
|
23
|
+
|
|
24
|
+
**Exports:**
|
|
25
|
+
- `parseNaturalLanguage(query, table)` - Main parser function
|
|
26
|
+
- `getSupportedPatterns()` - Documentation of supported patterns
|
|
27
|
+
- `testParser(table)` - Test function with example queries
|
|
28
|
+
|
|
29
|
+
## Implementation Details
|
|
30
|
+
|
|
31
|
+
### Tool Definition Added to `/src/mcp-server-consolidated.js` - ✅ COMPLETED
|
|
32
|
+
|
|
33
|
+
**Location**: After line 514 (after SN-List-Problems tool definition)
|
|
34
|
+
|
|
35
|
+
**Tool Definition Added:**
|
|
36
|
+
```javascript
|
|
37
|
+
{
|
|
38
|
+
name: 'SN-Natural-Language-Search',
|
|
39
|
+
description: 'Search ServiceNow records using natural language queries. Converts human-readable queries into ServiceNow encoded queries and executes them. Supports: Priority (P1-P5, high/low), Assignment (assigned to me, unassigned, assigned to <name>), Dates (created today, last 7 days, recent), States (new/open/closed/in progress), Content (about SAP, containing error), Impact/Urgency (high/medium/low), Numbers (number is INC0012345). Examples: "find all P1 incidents", "show recent problems assigned to me", "high priority changes created last week", "open incidents about SAP", "unassigned P2 incidents created today". Returns both the parsed encoded query and matching records with pattern analysis.',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
query: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'Natural language query (e.g., "high priority incidents assigned to me", "recent problems about database") (required)'
|
|
46
|
+
},
|
|
47
|
+
table: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'Target ServiceNow table name (default: "incident"). Common tables: incident, problem, change_request, sys_user, cmdb_ci',
|
|
50
|
+
default: 'incident'
|
|
51
|
+
},
|
|
52
|
+
limit: {
|
|
53
|
+
type: 'number',
|
|
54
|
+
description: 'Maximum number of records to return (default: 25)',
|
|
55
|
+
default: 25
|
|
56
|
+
},
|
|
57
|
+
fields: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'Comma-separated list of fields to return (optional)'
|
|
60
|
+
},
|
|
61
|
+
order_by: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: 'Field to sort by (e.g., "sys_created_on" or "-priority" for descending) (optional)'
|
|
64
|
+
},
|
|
65
|
+
show_patterns: {
|
|
66
|
+
type: 'boolean',
|
|
67
|
+
description: 'Include pattern matching details in response (default: true)',
|
|
68
|
+
default: true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
required: ['query']
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Tool Handler Added to Switch Statement - ✅ COMPLETED
|
|
77
|
+
|
|
78
|
+
**Location**: After line 1652 (after SN-List-Problems handler)
|
|
79
|
+
|
|
80
|
+
**Handler Added:**
|
|
81
|
+
```javascript
|
|
82
|
+
case 'SN-Natural-Language-Search': {
|
|
83
|
+
const { query, table = 'incident', limit = 25, fields, order_by, show_patterns = true } = args;
|
|
84
|
+
|
|
85
|
+
console.error(`🔍 Natural language search: "${query}" on ${table}`);
|
|
86
|
+
|
|
87
|
+
// Parse natural language query
|
|
88
|
+
const parseResult = parseNaturalLanguage(query, table);
|
|
89
|
+
|
|
90
|
+
// Check if parsing succeeded
|
|
91
|
+
if (!parseResult.encodedQuery) {
|
|
92
|
+
return {
|
|
93
|
+
content: [{
|
|
94
|
+
type: 'text',
|
|
95
|
+
text: `❌ Unable to parse query: "${query}"
|
|
96
|
+
|
|
97
|
+
${parseResult.suggestions.join('\n')}
|
|
98
|
+
|
|
99
|
+
Unmatched text: "${parseResult.unmatchedText}"
|
|
100
|
+
|
|
101
|
+
${show_patterns ? `\n## Supported Patterns:\n${JSON.stringify(getSupportedPatterns(), null, 2)}` : ''}`
|
|
102
|
+
}]
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Execute the encoded query
|
|
107
|
+
const queryParams = {
|
|
108
|
+
sysparm_limit: limit,
|
|
109
|
+
sysparm_query: parseResult.encodedQuery,
|
|
110
|
+
sysparm_fields: fields,
|
|
111
|
+
sysparm_offset: 0
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (order_by) {
|
|
115
|
+
queryParams.sysparm_order_by = order_by;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const results = await serviceNowClient.getRecords(table, queryParams);
|
|
119
|
+
|
|
120
|
+
// Build response
|
|
121
|
+
let responseText = `✅ Natural Language Search Results
|
|
122
|
+
|
|
123
|
+
**Original Query:** "${query}"
|
|
124
|
+
**Target Table:** ${table}
|
|
125
|
+
**Parsed Encoded Query:** \`${parseResult.encodedQuery}\`
|
|
126
|
+
**Records Found:** ${results.length}/${limit}
|
|
127
|
+
|
|
128
|
+
`;
|
|
129
|
+
|
|
130
|
+
// Add pattern matching details if requested
|
|
131
|
+
if (show_patterns && parseResult.matchedPatterns.length > 0) {
|
|
132
|
+
responseText += `## Matched Patterns:\n`;
|
|
133
|
+
parseResult.matchedPatterns.forEach((p, idx) => {
|
|
134
|
+
responseText += `${idx + 1}. **"${p.matched}"** → \`${p.condition}\`\n`;
|
|
135
|
+
});
|
|
136
|
+
responseText += `\n`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Add warnings for unmatched text
|
|
140
|
+
if (parseResult.unmatchedText && parseResult.unmatchedText.length > 3) {
|
|
141
|
+
responseText += `⚠️ **Unrecognized:** "${parseResult.unmatchedText}"\n\n`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Add results
|
|
145
|
+
if (results.length > 0) {
|
|
146
|
+
responseText += `## Results:\n\`\`\`json\n${JSON.stringify(results, null, 2)}\n\`\`\``;
|
|
147
|
+
} else {
|
|
148
|
+
responseText += `## No records found matching the query.\n\nTry adjusting your search criteria or use SN-Query-Table for more control.`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
content: [{
|
|
153
|
+
type: 'text',
|
|
154
|
+
text: responseText
|
|
155
|
+
}]
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Example Queries
|
|
161
|
+
|
|
162
|
+
Once implemented, the tool will support queries like:
|
|
163
|
+
|
|
164
|
+
1. **"find all P1 incidents"**
|
|
165
|
+
- Parsed: `priority=1`
|
|
166
|
+
|
|
167
|
+
2. **"show recent problems assigned to me"**
|
|
168
|
+
- Parsed: `sys_created_on>javascript:gs.daysAgo(7)^assigned_to=javascript:gs.getUserID()`
|
|
169
|
+
|
|
170
|
+
3. **"high priority changes created last week"**
|
|
171
|
+
- Parsed: `priority=2^sys_created_on>javascript:gs.daysAgo(7)`
|
|
172
|
+
|
|
173
|
+
4. **"open incidents about SAP"**
|
|
174
|
+
- Parsed: `state=1^ORstate=2^ORstate=3^short_descriptionLIKESAP^ORdescriptionLIKESAP`
|
|
175
|
+
|
|
176
|
+
5. **"unassigned P2 incidents created today"**
|
|
177
|
+
- Parsed: `assigned_toISEMPTY^priority=2^sys_created_on>javascript:gs.daysAgoStart(0)`
|
|
178
|
+
|
|
179
|
+
## Testing
|
|
180
|
+
|
|
181
|
+
### Unit Tests - ✅ PASSED
|
|
182
|
+
|
|
183
|
+
Parser tested successfully with 5 sample queries:
|
|
184
|
+
- ✅ "high priority incidents assigned to me" → `assigned_to=javascript:gs.getUserID()^priority=2`
|
|
185
|
+
- ✅ "P1 incidents" → `priority=1`
|
|
186
|
+
- ✅ "recent problems" → `sys_created_on>javascript:gs.daysAgo(7)`
|
|
187
|
+
- ✅ "open incidents about SAP" → Complex state and content query
|
|
188
|
+
- ✅ "unassigned P2 incidents created today" → 3-pattern combination
|
|
189
|
+
|
|
190
|
+
### Integration Testing
|
|
191
|
+
|
|
192
|
+
To test the full tool integration:
|
|
193
|
+
|
|
194
|
+
1. Restart the MCP server
|
|
195
|
+
2. Use the tool via Claude Code:
|
|
196
|
+
```
|
|
197
|
+
SN-Natural-Language-Search({
|
|
198
|
+
query: "high priority incidents assigned to me",
|
|
199
|
+
table: "incident",
|
|
200
|
+
limit: 10
|
|
201
|
+
})
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
3. Verify the parsed query and results are correct
|
|
205
|
+
|
|
206
|
+
## Future Enhancements
|
|
207
|
+
|
|
208
|
+
Documented in `/src/natural-language.js`:
|
|
209
|
+
- LLM-based parsing for complex queries
|
|
210
|
+
- User name resolution (fuzzy matching)
|
|
211
|
+
- Advanced date parsing ("before January", "Q1 2024")
|
|
212
|
+
- Multi-condition combining with precedence
|
|
213
|
+
- Custom pattern extensions per instance
|
|
214
|
+
|
|
215
|
+
## File Locations
|
|
216
|
+
|
|
217
|
+
- **Parser**: `/Users/nczitzer/WebstormProjects/mcp-servicenow-nodejs/src/natural-language.js`
|
|
218
|
+
- **MCP Server**: `/Users/nczitzer/WebstormProjects/mcp-servicenow-nodejs/src/mcp-server-consolidated.js`
|
|
219
|
+
- Import added at line 7
|
|
220
|
+
- Tool definition to add after line 514
|
|
221
|
+
- Handler to add after line 1117
|