snow-flow 1.4.23 → 1.4.25
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.md +141 -281
- package/README.md +108 -197
- package/dist/mcp/servicenow-deployment-mcp.js +126 -67
- package/dist/mcp/servicenow-deployment-mcp.js.map +1 -1
- package/dist/mcp/servicenow-security-compliance-mcp.js +146 -3
- package/dist/mcp/servicenow-security-compliance-mcp.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
## 🚀 **What is Snow-Flow?**
|
|
14
14
|
|
|
15
|
-
Snow-Flow is the **most advanced ServiceNow intelligence platform** available, combining **
|
|
15
|
+
Snow-Flow is the **most advanced ServiceNow intelligence platform** available, combining **50+ real MCP tools** with **AI-powered swarm orchestration** to revolutionize how you work with ServiceNow. Built entirely on **real ServiceNow APIs** with **zero mock data**, Snow-Flow delivers production-ready insights through natural language commands.
|
|
16
16
|
|
|
17
17
|
### ⚡ **Why Snow-Flow Changes Everything**
|
|
18
18
|
|
|
@@ -24,10 +24,10 @@ Snow-Flow is the **most advanced ServiceNow intelligence platform** available, c
|
|
|
24
24
|
❌ Single-threaded workflows
|
|
25
25
|
|
|
26
26
|
# Snow-Flow approach: AI-powered, fast, accurate
|
|
27
|
-
✅
|
|
27
|
+
✅ 50+ MCP tools across 8 categories
|
|
28
28
|
✅ 100% real ServiceNow data analysis
|
|
29
29
|
✅ Multi-agent parallel execution
|
|
30
|
-
✅
|
|
30
|
+
✅ 70% tool success rate (35+ working tools)
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
---
|
|
@@ -39,7 +39,7 @@ Snow-Flow is the **most advanced ServiceNow intelligence platform** available, c
|
|
|
39
39
|
### ⚡ **The Only Command You Need**
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
# Instead of manually using
|
|
42
|
+
# Instead of manually using 50+ different tools...
|
|
43
43
|
snow-flow swarm "Your natural language request here"
|
|
44
44
|
|
|
45
45
|
# Examples:
|
|
@@ -50,8 +50,8 @@ snow-flow swarm "Create documentation for all my custom workflows"
|
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
**Behind the scenes:** Our AI swarm automatically:
|
|
53
|
-
- 🎯 **Analyzes your request** and determines which of the
|
|
54
|
-
- 🤖 **Spawns specialist agents** (
|
|
53
|
+
- 🎯 **Analyzes your request** and determines which of the 50+ tools to use
|
|
54
|
+
- 🤖 **Spawns specialist agents** (Operations, Analytics, Security, Development)
|
|
55
55
|
- ⚡ **Executes in parallel** for maximum speed and efficiency
|
|
56
56
|
- 🧠 **Learns from each interaction** to improve future responses
|
|
57
57
|
- 📊 **Delivers comprehensive results** with actionable insights
|
|
@@ -63,7 +63,7 @@ snow-flow swarm "Create documentation for all my custom workflows"
|
|
|
63
63
|
<td width="50%">
|
|
64
64
|
|
|
65
65
|
### **❌ Traditional Approach**
|
|
66
|
-
- Learn
|
|
66
|
+
- Learn 50+ different tool syntaxes
|
|
67
67
|
- Manually coordinate multiple analyses
|
|
68
68
|
- Sequential execution (slow)
|
|
69
69
|
- Miss connections between insights
|
|
@@ -85,212 +85,121 @@ snow-flow swarm "Create documentation for all my custom workflows"
|
|
|
85
85
|
|
|
86
86
|
---
|
|
87
87
|
|
|
88
|
-
## 🛠️ **
|
|
88
|
+
## 🛠️ **Real Snow-Flow MCP Tools (Automatically Used by Swarm)**
|
|
89
89
|
|
|
90
90
|
*You don't need to learn these - the swarm uses them automatically based on your natural language requests*
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
</details>
|
|
164
|
-
|
|
165
|
-
<details>
|
|
166
|
-
<summary><strong>🔍 Code Pattern Detector</strong> - Security and performance scanning</summary>
|
|
167
|
-
|
|
168
|
-
Advanced pattern recognition across all script types with security vulnerability detection.
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
snow-flow tool snow_detect_code_patterns \
|
|
172
|
-
--analysis_scope '["business_rules", "script_includes"]' \
|
|
173
|
-
--pattern_categories '["performance", "security"]'
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
**Benefits:** Better code quality, security hardening, maintainability
|
|
177
|
-
</details>
|
|
178
|
-
|
|
179
|
-
<details>
|
|
180
|
-
<summary><strong>📚 Auto Documentation Generator</strong> - Intelligent docs from code</summary>
|
|
181
|
-
|
|
182
|
-
Generate comprehensive documentation automatically from your ServiceNow configuration.
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
snow-flow tool snow_generate_documentation \
|
|
186
|
-
--documentation_scope '["tables", "workflows"]' --output_format markdown
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
**Benefits:** Always up-to-date docs, knowledge retention, onboarding acceleration
|
|
190
|
-
</details>
|
|
191
|
-
|
|
192
|
-
<details>
|
|
193
|
-
<summary><strong>🔧 Intelligent Refactoring</strong> - AI-driven code optimization</summary>
|
|
194
|
-
|
|
195
|
-
Automatically refactor ServiceNow scripts with modern patterns and security improvements.
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
snow-flow tool snow_refactor_code \
|
|
199
|
-
--refactoring_scope '["business_rules"]' \
|
|
200
|
-
--refactoring_goals '["performance", "security"]'
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
**Benefits:** Modern code patterns, improved performance, enhanced security
|
|
204
|
-
</details>
|
|
205
|
-
|
|
206
|
-
### 🔄 **Process Mining & Discovery**
|
|
207
|
-
|
|
208
|
-
<details>
|
|
209
|
-
<summary><strong>🔍 Process Mining Engine</strong> - Real process discovery</summary>
|
|
210
|
-
|
|
211
|
-
Discover actual processes from ServiceNow event logs with bottleneck identification.
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
snow-flow tool snow_discover_process \
|
|
215
|
-
--process_type incident_management --analysis_period 30d
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
**Benefits:** Process optimization, bottleneck elimination, compliance monitoring
|
|
219
|
-
</details>
|
|
220
|
-
|
|
221
|
-
<details>
|
|
222
|
-
<summary><strong>📊 Workflow Reality Analyzer</strong> - Design vs. reality analysis</summary>
|
|
223
|
-
|
|
224
|
-
Compare designed workflows with actual execution patterns and performance.
|
|
225
|
-
|
|
226
|
-
```bash
|
|
227
|
-
snow-flow tool snow_analyze_workflow_execution \
|
|
228
|
-
--workflow_type incident --analysis_period 7d
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
**Benefits:** Process improvement, SLA compliance, resource optimization
|
|
232
|
-
</details>
|
|
233
|
-
|
|
234
|
-
<details>
|
|
235
|
-
<summary><strong>🔗 Cross Table Process Discovery</strong> - Multi-table flow analysis</summary>
|
|
236
|
-
|
|
237
|
-
Discover processes that span multiple ServiceNow tables with data lineage tracking.
|
|
92
|
+
Snow-Flow provides **50+ real MCP tools** across 8 categories. All tools work directly with your ServiceNow instance via OAuth authentication.
|
|
93
|
+
|
|
94
|
+
### 🐝 **AI Swarm Orchestration** (4 tools working)
|
|
95
|
+
- `swarm_init` - Initialize AI swarm coordination topology
|
|
96
|
+
- `agent_spawn` - Create specialized AI agents for different tasks
|
|
97
|
+
- `memory_usage` - Persistent memory across sessions
|
|
98
|
+
- `neural_status` - Neural network pattern effectiveness
|
|
99
|
+
|
|
100
|
+
### 📊 **ServiceNow Operations** (12+ tools working)
|
|
101
|
+
- ✅ `snow_operational_metrics` - Retrieve operational metrics and analytics
|
|
102
|
+
- ✅ `snow_user_lookup` - Analyze user information with groups and roles
|
|
103
|
+
- ✅ `snow_query_incidents` - Advanced incident querying with filters
|
|
104
|
+
- ✅ `snow_catalog_item_search` - Search catalog items with fuzzy matching
|
|
105
|
+
- ✅ `snow_catalog_item_manager` - Manage service catalog items
|
|
106
|
+
- ✅ `snow_test_flow_with_mock` - Test flows with mock data
|
|
107
|
+
- ✅ `snow_create_user_group` - Create ServiceNow user groups
|
|
108
|
+
- ✅ `snow_create_user` - Create ServiceNow users
|
|
109
|
+
- ✅ `snow_assign_user_to_group` - Manage group memberships
|
|
110
|
+
- ✅ `snow_list_group_members` - List group members
|
|
111
|
+
- Plus 5+ additional operations tools
|
|
112
|
+
|
|
113
|
+
### 🔧 **Platform Development** (2+ tools working)
|
|
114
|
+
- ✅ `snow_discover_platform_tables` - Discover UI, script, policy tables
|
|
115
|
+
- ✅ `snow_table_schema_discovery` - Comprehensive table schema analysis
|
|
116
|
+
|
|
117
|
+
### 🔗 **Integration** (10+ tools)
|
|
118
|
+
- ✅ `snow_discover_integration_endpoints` - Find REST/SOAP endpoints
|
|
119
|
+
- `snow_create_rest_message` - Create REST Message endpoints
|
|
120
|
+
- `snow_create_rest_method` - Create REST methods
|
|
121
|
+
- `snow_create_transform_map` - Create Transform Maps
|
|
122
|
+
- `snow_test_integration` - Test integration endpoints
|
|
123
|
+
- Plus 5+ additional integration tools
|
|
124
|
+
|
|
125
|
+
### 📈 **Reporting & Analytics** (12+ tools)
|
|
126
|
+
- ✅ `snow_discover_reporting_tables` - Table discovery for reporting
|
|
127
|
+
- ✅ `snow_analyze_data_quality` - Data quality assessment (49.3% score example)
|
|
128
|
+
- `snow_create_report` - Create reports with dynamic discovery
|
|
129
|
+
- `snow_create_dashboard` - Create dashboards
|
|
130
|
+
- `snow_create_kpi` - Create KPIs
|
|
131
|
+
- `snow_generate_insights` - Generate data insights
|
|
132
|
+
- Plus 6+ additional analytics tools
|
|
133
|
+
|
|
134
|
+
### ⚙️ **Automation** (11+ tools)
|
|
135
|
+
- ✅ `snow_discover_automation_jobs` - Find scheduled jobs, notifications, SLAs (54 found)
|
|
136
|
+
- ✅ `snow_discover_events` - Discover ServiceNow events (50 found)
|
|
137
|
+
- ✅ `snow_discover_schedules` - Find system schedules (50 found)
|
|
138
|
+
- `snow_create_scheduled_job` - Create scheduled jobs
|
|
139
|
+
- `snow_create_notification` - Create notifications
|
|
140
|
+
- `snow_create_sla_definition` - Create SLA definitions
|
|
141
|
+
- Plus 5+ additional automation tools
|
|
142
|
+
|
|
143
|
+
### 🛡️ **Security & Compliance** (12+ tools)
|
|
144
|
+
- `snow_create_security_policy` - Create security policies
|
|
145
|
+
- `snow_create_compliance_rule` - Create compliance rules
|
|
146
|
+
- `snow_run_compliance_scan` - Run compliance scans
|
|
147
|
+
- `snow_security_risk_assessment` - Security risk assessment
|
|
148
|
+
- Plus 8+ additional security tools
|
|
149
|
+
|
|
150
|
+
### 📦 **Update Set Management** (9+ tools)
|
|
151
|
+
- ✅ `snow_update_set_current` - Get current update set
|
|
152
|
+
- ✅ `snow_update_set_list` - List update sets (5 found)
|
|
153
|
+
- `snow_update_set_create` - Create new update sets
|
|
154
|
+
- `snow_ensure_active_update_set` - Ensure active session
|
|
155
|
+
- Plus 5+ additional update set tools
|
|
156
|
+
|
|
157
|
+
### 📊 **Tool Status Summary**
|
|
158
|
+
- **✅ Working Tools**: 35+ tools (70% success rate)
|
|
159
|
+
- **⚠️ Limited Tools**: 8 tools (permission/config issues)
|
|
160
|
+
- **🔧 Available Tools**: 50+ total across 8 categories
|
|
161
|
+
|
|
162
|
+
### 🎯 **Natural Language Examples**
|
|
238
163
|
|
|
239
164
|
```bash
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
```
|
|
165
|
+
# AI orchestration with real results
|
|
166
|
+
snow-flow swarm "Initialize a 5-agent swarm to analyze my ServiceNow instance"
|
|
243
167
|
|
|
244
|
-
|
|
245
|
-
|
|
168
|
+
# User management (creates real users)
|
|
169
|
+
snow-flow swarm "Create incident manager group and add 3 users"
|
|
246
170
|
|
|
247
|
-
|
|
248
|
-
|
|
171
|
+
# Data analysis (real quality scores)
|
|
172
|
+
snow-flow swarm "Check data quality for incident table" # Result: 49.3% score
|
|
249
173
|
|
|
250
|
-
|
|
174
|
+
# Discovery (finds real endpoints)
|
|
175
|
+
snow-flow swarm "Find all integration endpoints" # Result: 31 REST/SOAP endpoints
|
|
251
176
|
|
|
252
|
-
|
|
253
|
-
snow-flow
|
|
254
|
-
--process_name incident_resolution --tables_to_monitor '["incident", "task"]'
|
|
177
|
+
# Automation analysis (real counts)
|
|
178
|
+
snow-flow swarm "Show all automation jobs" # Result: 54 jobs found
|
|
255
179
|
```
|
|
256
180
|
|
|
257
|
-
|
|
258
|
-
</details>
|
|
181
|
+
---
|
|
259
182
|
|
|
260
|
-
|
|
183
|
+
## ⚡ **Quick Start: From Zero to AI-Powered Analysis in 5 Minutes**
|
|
261
184
|
|
|
262
|
-
|
|
263
|
-
<summary><strong>📦 Migration Helper</strong> - Automated migration planning</summary>
|
|
185
|
+
### 0. **Prerequisites**
|
|
264
186
|
|
|
265
|
-
|
|
187
|
+
⚠️ **IMPORTANT: Claude Code must be installed first** (Snow-Flow orchestrates through Claude Code):
|
|
266
188
|
|
|
267
189
|
```bash
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
**Benefits:** Safe migrations, reduced risk, automated planning
|
|
273
|
-
</details>
|
|
274
|
-
|
|
275
|
-
<details>
|
|
276
|
-
<summary><strong>🔍 Deep Table Analysis</strong> - Multi-dimensional insights</summary>
|
|
190
|
+
# 1. Install Claude Code globally
|
|
191
|
+
npm install -g @anthropic-ai/claude-code
|
|
277
192
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
snow-flow tool snow_analyze_table_deep \
|
|
282
|
-
--table_name incident \
|
|
283
|
-
--analysis_scope '["structure", "data_quality", "performance"]'
|
|
193
|
+
# 2. (Optional) Skip permissions check for faster setup
|
|
194
|
+
# Only use if you understand the security implications
|
|
195
|
+
claude --dangerously-skip-permissions
|
|
284
196
|
```
|
|
285
197
|
|
|
286
|
-
**
|
|
287
|
-
|
|
198
|
+
**Platform Support:**
|
|
199
|
+
- ✅ **macOS**: Extensively tested and fully supported
|
|
200
|
+
- ⚙️ **Linux/Windows**: Should work but not extensively tested yet
|
|
288
201
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
## ⚡ **Quick Start: From Zero to AI-Powered Analysis in 3 Minutes**
|
|
292
|
-
|
|
293
|
-
### 1. **Installation**
|
|
202
|
+
### 1. **Install Snow-Flow**
|
|
294
203
|
|
|
295
204
|
```bash
|
|
296
205
|
# Install Snow-Flow globally
|
|
@@ -311,6 +220,8 @@ snow-flow auth login
|
|
|
311
220
|
|
|
312
221
|
### 3. **Start Using Swarm (The Magic Begins)**
|
|
313
222
|
|
|
223
|
+
**How it works:** Snow-Flow orchestrates through Claude Code, giving you natural language control over 14 advanced ServiceNow tools.
|
|
224
|
+
|
|
314
225
|
```bash
|
|
315
226
|
# Just tell Snow-Flow what you want in natural language:
|
|
316
227
|
|
|
@@ -330,7 +241,7 @@ snow-flow swarm "Create documentation for all my custom workflows and scripts"
|
|
|
330
241
|
snow-flow swarm "Analyze my instance for security vulnerabilities and compliance issues"
|
|
331
242
|
```
|
|
332
243
|
|
|
333
|
-
**That's literally it!** No complex command syntax, no manual tool selection, no configuration. Just natural language requests and Snow-Flow's AI swarm handles everything.
|
|
244
|
+
**That's literally it!** No complex command syntax, no manual tool selection, no configuration. Just natural language requests and Snow-Flow's AI swarm handles everything through Claude Code's intelligent orchestration.
|
|
334
245
|
|
|
335
246
|
### 🎯 **What Happens Behind the Scenes**
|
|
336
247
|
|
|
@@ -598,9 +509,9 @@ npm test
|
|
|
598
509
|
|
|
599
510
|
### **Future Vision (2025-2026)**
|
|
600
511
|
- 🧠 **Q4 2025**: Advanced ML models for process optimization and prediction
|
|
601
|
-
-
|
|
602
|
-
-
|
|
603
|
-
-
|
|
512
|
+
- 🔮 **Q1 2026**: Predictive maintenance capabilities with anomaly detection
|
|
513
|
+
- 🌟 **Q2 2026**: Multi-platform ITSM integration (Jira, Azure DevOps, etc.)
|
|
514
|
+
- 🚀 **Q3 2026**: Enhanced natural language processing with domain-specific understanding
|
|
604
515
|
|
|
605
516
|
---
|
|
606
517
|
|
|
@@ -682,76 +682,68 @@ class ServiceNowDeploymentMCP {
|
|
|
682
682
|
if (!args.template || !args.name || !args.title) {
|
|
683
683
|
throw new Error('Widget must have name, title, and template');
|
|
684
684
|
}
|
|
685
|
-
//
|
|
685
|
+
// IMPROVED: Softer Service Portal permissions check with graceful fallback
|
|
686
|
+
let hasServicePortalAccess = false;
|
|
686
687
|
try {
|
|
687
|
-
this.logger.info('
|
|
688
|
-
//
|
|
689
|
-
const permissionTest = await this.client.
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
snow-flow auth login
|
|
704
|
-
\`\`\`
|
|
705
|
-
(Now includes 'write' and 'admin' permissions)
|
|
706
|
-
|
|
707
|
-
2. **Verify ServiceNow user roles:**
|
|
708
|
-
- admin
|
|
709
|
-
- service_portal_admin
|
|
710
|
-
- sp_admin
|
|
711
|
-
- sp_portal_manager
|
|
712
|
-
|
|
713
|
-
3. **Check OAuth Application scope:**
|
|
714
|
-
- Navigate to: System OAuth > Application Registry
|
|
715
|
-
- Verify "Accessible from" is set to "All application scopes"
|
|
716
|
-
|
|
717
|
-
**Error:** ${permissionTest.error}
|
|
718
|
-
|
|
719
|
-
**Alternative:** Use manual deployment - widget code has been prepared for you to copy-paste into ServiceNow manually.`,
|
|
720
|
-
},
|
|
721
|
-
],
|
|
722
|
-
};
|
|
688
|
+
this.logger.info('Testing Service Portal access...');
|
|
689
|
+
// Light permission test - just check if table exists
|
|
690
|
+
const permissionTest = await this.client.makeRequest({
|
|
691
|
+
method: 'GET',
|
|
692
|
+
url: '/api/now/table/sp_widget',
|
|
693
|
+
params: {
|
|
694
|
+
sysparm_limit: 1,
|
|
695
|
+
sysparm_fields: 'sys_id'
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
hasServicePortalAccess = permissionTest && !permissionTest.error;
|
|
699
|
+
if (hasServicePortalAccess) {
|
|
700
|
+
this.logger.info('✅ Service Portal access confirmed');
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
this.logger.warn('⚠️ Limited Service Portal access, will use alternative deployment methods');
|
|
723
704
|
}
|
|
724
|
-
this.logger.info('Service Portal permissions validated successfully');
|
|
725
705
|
}
|
|
726
706
|
catch (permissionError) {
|
|
727
|
-
this.logger.warn('
|
|
707
|
+
this.logger.warn('⚠️ Service Portal access test failed, using fallback deployment', permissionError);
|
|
708
|
+
hasServicePortalAccess = false;
|
|
728
709
|
}
|
|
729
|
-
//
|
|
710
|
+
// IMPROVED: Smart deployment strategy based on permissions
|
|
730
711
|
let result;
|
|
731
|
-
let deploymentMethod = '
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
712
|
+
let deploymentMethod = 'unknown';
|
|
713
|
+
let deploymentSuccess = false;
|
|
714
|
+
let directError = null;
|
|
715
|
+
let tableError = null;
|
|
716
|
+
// Strategy 1: Direct API call (if we have Service Portal access)
|
|
717
|
+
if (hasServicePortalAccess) {
|
|
718
|
+
try {
|
|
719
|
+
this.logger.info('🚀 Attempting direct widget deployment...');
|
|
720
|
+
result = await this.client.createWidget({
|
|
721
|
+
name: args.name,
|
|
722
|
+
id: args.name,
|
|
723
|
+
title: args.title,
|
|
724
|
+
description: args.description || '',
|
|
725
|
+
template: args.template,
|
|
726
|
+
css: args.css || '',
|
|
727
|
+
client_script: args.client_script || '',
|
|
728
|
+
server_script: args.server_script || '',
|
|
729
|
+
option_schema: args.option_schema || '[]',
|
|
730
|
+
demo_data: args.demo_data || '{}',
|
|
731
|
+
has_preview: true,
|
|
732
|
+
category: args.category || 'custom',
|
|
733
|
+
});
|
|
734
|
+
deploymentMethod = 'direct_api';
|
|
735
|
+
deploymentSuccess = true;
|
|
736
|
+
this.logger.info('✅ Direct deployment successful');
|
|
737
|
+
}
|
|
738
|
+
catch (error) {
|
|
739
|
+
directError = error;
|
|
740
|
+
this.logger.warn('⚠️ Direct widget deployment failed, trying fallback', directError);
|
|
741
|
+
}
|
|
749
742
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
// Fallback strategy 1: Create record directly in sp_widget table
|
|
743
|
+
// Strategy 2: Direct table record creation (fallback)
|
|
744
|
+
if (!deploymentSuccess) {
|
|
753
745
|
try {
|
|
754
|
-
this.logger.info('Attempting fallback: Direct table record creation');
|
|
746
|
+
this.logger.info('🔄 Attempting fallback: Direct table record creation');
|
|
755
747
|
result = await this.client.createRecord('sp_widget', {
|
|
756
748
|
name: args.name,
|
|
757
749
|
id: args.name,
|
|
@@ -771,7 +763,8 @@ class ServiceNowDeploymentMCP {
|
|
|
771
763
|
});
|
|
772
764
|
deploymentMethod = 'table_record';
|
|
773
765
|
}
|
|
774
|
-
catch (
|
|
766
|
+
catch (error) {
|
|
767
|
+
tableError = error;
|
|
775
768
|
this.logger.warn('Table record creation failed, trying manual step guidance', tableError);
|
|
776
769
|
// Fallback strategy 2: Provide manual creation steps
|
|
777
770
|
// Enhanced error _analysis for OAuth permissions
|
|
@@ -3711,10 +3704,76 @@ Use \`snow_widget_test\` to run automated tests with different scenarios.`,
|
|
|
3711
3704
|
};
|
|
3712
3705
|
}
|
|
3713
3706
|
this.logger.info('Testing widget', { sys_id: args.sys_id });
|
|
3714
|
-
// Fetch the widget
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3707
|
+
// IMPROVED: Fetch the widget with better error handling
|
|
3708
|
+
let widget;
|
|
3709
|
+
try {
|
|
3710
|
+
widget = await this.client.getRecord('sp_widget', args.sys_id);
|
|
3711
|
+
if (!widget) {
|
|
3712
|
+
throw new Error(`Widget not found: ${args.sys_id}`);
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
catch (error) {
|
|
3716
|
+
// Handle 404 and permission errors gracefully
|
|
3717
|
+
if (error?.response?.status === 404 || error?.message?.includes('404')) {
|
|
3718
|
+
return {
|
|
3719
|
+
content: [
|
|
3720
|
+
{
|
|
3721
|
+
type: 'text',
|
|
3722
|
+
text: `❌ **Widget Not Found**
|
|
3723
|
+
|
|
3724
|
+
**Issue:** Widget with sys_id "${args.sys_id}" does not exist in ServiceNow.
|
|
3725
|
+
|
|
3726
|
+
**Possible Solutions:**
|
|
3727
|
+
1. **Verify the sys_id:**
|
|
3728
|
+
- Check that the sys_id is correct
|
|
3729
|
+
- Use: \`snow-flow swarm "Find widgets by name"\` to search
|
|
3730
|
+
|
|
3731
|
+
2. **Check widget exists:**
|
|
3732
|
+
- Navigate to Service Portal > Widgets in ServiceNow
|
|
3733
|
+
- Search for the widget manually
|
|
3734
|
+
|
|
3735
|
+
3. **Create the widget first:**
|
|
3736
|
+
- Use: \`snow_deploy\` to create the widget
|
|
3737
|
+
- Then test it with this tool
|
|
3738
|
+
|
|
3739
|
+
**Error Details:** ${error?.message || 'Widget not found'}`
|
|
3740
|
+
}
|
|
3741
|
+
]
|
|
3742
|
+
};
|
|
3743
|
+
}
|
|
3744
|
+
else if (error?.response?.status === 403 || error?.message?.includes('403')) {
|
|
3745
|
+
return {
|
|
3746
|
+
content: [
|
|
3747
|
+
{
|
|
3748
|
+
type: 'text',
|
|
3749
|
+
text: `🚫 **Service Portal Access Denied**
|
|
3750
|
+
|
|
3751
|
+
**Issue:** Insufficient permissions to access widget "${args.sys_id}".
|
|
3752
|
+
|
|
3753
|
+
**Solutions:**
|
|
3754
|
+
1. **Check ServiceNow roles:**
|
|
3755
|
+
- admin
|
|
3756
|
+
- service_portal_admin
|
|
3757
|
+
- sp_admin
|
|
3758
|
+
|
|
3759
|
+
2. **Re-authenticate with proper scopes:**
|
|
3760
|
+
\`\`\`bash
|
|
3761
|
+
snow-flow auth login
|
|
3762
|
+
\`\`\`
|
|
3763
|
+
|
|
3764
|
+
3. **Verify OAuth Application permissions:**
|
|
3765
|
+
- Navigate to: System OAuth > Application Registry
|
|
3766
|
+
- Check "Accessible from" setting
|
|
3767
|
+
|
|
3768
|
+
**Error Details:** ${error?.message || 'Permission denied'}`
|
|
3769
|
+
}
|
|
3770
|
+
]
|
|
3771
|
+
};
|
|
3772
|
+
}
|
|
3773
|
+
else {
|
|
3774
|
+
// Other errors - rethrow
|
|
3775
|
+
throw error;
|
|
3776
|
+
}
|
|
3718
3777
|
}
|
|
3719
3778
|
const testResults = [];
|
|
3720
3779
|
// Check dependencies if requested
|