snow-flow 2.0.2 → 2.0.3
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/mcp-config.json → .mcp.json} +13 -12
- package/.releaserc.json +47 -0
- package/README.md +6 -0
- package/package.json +1 -1
- package/.claude/claude-settings.json +0 -15
- package/.claude/commands/analysis/README.md +0 -9
- package/.claude/commands/automation/README.md +0 -9
- package/.claude/commands/github/README.md +0 -11
- package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
- package/.claude/commands/hooks/README.md +0 -11
- package/.claude/commands/monitoring/README.md +0 -9
- package/.claude/commands/optimization/README.md +0 -9
- package/.claude/commands/training/README.md +0 -9
- package/.claude/commands/workflows/README.md +0 -9
- package/.claude/config.json +0 -36
- package/.claude/helpers/github-setup.sh +0 -28
- package/.claude/helpers/quick-start.sh +0 -19
- package/.claude/helpers/setup-mcp.sh +0 -18
- package/.claude/settings.json +0 -114
- package/.claude/settings.local.json +0 -33
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -9
- package/.claude-flow/metrics/system-metrics.json +0 -15986
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/.roo/README.md +0 -402
- package/.roo/mcp-list.txt +0 -257
- package/.roo/mcp.json +0 -32
- package/.roo/workflows/basic-tdd.json +0 -32
- package/.roomodes +0 -201
- package/CLAUDE.md +0 -393
- package/bin/snow-flow.js +0 -3
- package/dist/cli.js.bak +0 -2052
- package/dist/config/snow-flow-config.d.ts +0 -1492
- package/dist/config/snow-flow-config.js +0 -938
- package/scripts/create-env.js +0 -91
- package/scripts/postinstall.js +0 -30
- package/scripts/register-mcp-servers.js +0 -210
- package/scripts/reset-mcp-servers.js +0 -246
- package/scripts/setup-mcp.js +0 -106
- package/scripts/update-version.js +0 -31
- package/src/agents/README.md +0 -192
- package/src/agents/base-agent.ts +0 -251
- package/src/agents/coordinator.ts +0 -971
- package/src/agents/index.ts +0 -18
- package/src/agents/queen-403-handler.ts +0 -230
- package/src/agents/queen-agent.ts +0 -1399
- package/src/agents/script-writer-agent.ts +0 -769
- package/src/agents/security-agent.ts +0 -726
- package/src/agents/widget-creator-agent.ts +0 -568
- package/src/api/error-handling.ts +0 -1758
- package/src/api/natural-language-mapper.ts +0 -630
- package/src/api/performance-optimizer.ts +0 -891
- package/src/api/transaction-manager.ts +0 -754
- package/src/cli/deploy-artifact.ts +0 -304
- package/src/cli/snow-flow-cli-integration.ts +0 -434
- package/src/cli.ts +0 -4455
- package/src/cli.ts.bak +0 -5616
- package/src/compliance/advanced-compliance-system.ts +0 -1268
- package/src/compliance/index.ts +0 -19
- package/src/config/snow-flow-config.ts +0 -1019
- package/src/documentation/index.ts +0 -16
- package/src/documentation/self-documenting-system.ts +0 -1421
- package/src/dynamic-version.ts +0 -44
- package/src/healing/index.ts +0 -20
- package/src/healing/self-healing-system.ts +0 -1435
- package/src/health/README.md +0 -161
- package/src/health/system-health.ts +0 -995
- package/src/index.ts +0 -60
- package/src/intelligence/acl-analyzer.ts +0 -377
- package/src/intelligence/auto-resolution-engine.ts +0 -643
- package/src/intelligence/gap-analysis-engine.ts +0 -488
- package/src/intelligence/manual-instructions-generator.ts +0 -744
- package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
- package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
- package/src/intelligence/performance-recommendations-engine.ts +0 -1223
- package/src/intelligence/requirements-analyzer.ts +0 -1148
- package/src/intelligence/task-analyzer.ts +0 -628
- package/src/managers/scope-manager.ts +0 -555
- package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
- package/src/mcp/base-mcp-server.ts +0 -660
- package/src/mcp/http-transport-wrapper.ts +0 -426
- package/src/mcp/service-discovery-client.ts +0 -312
- package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
- package/src/mcp/servicenow-automation-mcp.ts +0 -838
- package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
- package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
- package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
- package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
- package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
- package/src/mcp/servicenow-integration-mcp.ts +0 -819
- package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
- package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
- package/src/mcp/servicenow-mcp-server.ts +0 -728
- package/src/mcp/servicenow-memory-mcp.ts +0 -474
- package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
- package/src/mcp/servicenow-operations-mcp.ts +0 -3384
- package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
- package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
- package/src/mcp/servicenow-progressive-indexer.ts +0 -370
- package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
- package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
- package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
- package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
- package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
- package/src/mcp/servicenow-update-set-mcp.ts +0 -811
- package/src/mcp/shared/agent-context-provider.ts +0 -365
- package/src/mcp/shared/base-mcp-server.ts +0 -2463
- package/src/mcp/shared/mcp-memory-manager.ts +0 -540
- package/src/mcp/shared/mcp-resource-manager.ts +0 -367
- package/src/mcp/snow-flow-mcp.ts +0 -911
- package/src/mcp/start-all-mcp-servers.ts +0 -102
- package/src/mcp/start-servicenow-mcp.ts +0 -67
- package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
- package/src/monitoring/performance-tracker.ts +0 -777
- package/src/optimization/cost-optimization-engine.ts +0 -1125
- package/src/optimization/index.ts +0 -10
- package/src/queen/README.md +0 -403
- package/src/queen/agent-factory.ts +0 -574
- package/src/queen/index.ts +0 -94
- package/src/queen/mcp-execution-bridge.ts +0 -681
- package/src/queen/neural-learning.ts +0 -319
- package/src/queen/parallel-agent-engine.ts +0 -848
- package/src/queen/queen-memory-system.ts +0 -490
- package/src/queen/queen-memory.ts +0 -456
- package/src/queen/servicenow-queen.ts +0 -1029
- package/src/queen/types.ts +0 -87
- package/src/rollback/smart-rollback-system.ts +0 -866
- package/src/schemas/deployment.schema.json +0 -58
- package/src/schemas/flow.schema.json +0 -79
- package/src/schemas/widget.schema.json +0 -72
- package/src/snow-flow-system.ts +0 -541
- package/src/sparc/sparc-help.ts +0 -49
- package/src/sparc/team-sparc.ts +0 -88
- package/src/strategies/global-scope-strategy.ts +0 -736
- package/src/templates/base/application.template.json +0 -45
- package/src/templates/base/business_rule.template.json +0 -33
- package/src/templates/base/script_include.template.json +0 -18
- package/src/templates/base/table.template.json +0 -64
- package/src/templates/base/widget.template.json +0 -25
- package/src/templates/patterns/composite.incident-management.template.json +0 -140
- package/src/templates/patterns/widget.dashboard.template.json +0 -238
- package/src/templates/patterns/widget.datatable.template.json +0 -292
- package/src/testing/integration-test-suite.ts +0 -1276
- package/src/types/index.ts +0 -183
- package/src/types/neo4j-driver.d.ts +0 -23
- package/src/types/servicenow.types.ts +0 -307
- package/src/types/snow-flow.types.ts +0 -186
- package/src/types/todo.types.ts +0 -70
- package/src/utils/action-type-cache.ts +0 -286
- package/src/utils/agent-detector.ts +0 -573
- package/src/utils/artifact-tracker.ts +0 -379
- package/src/utils/dependency-detector.ts +0 -233
- package/src/utils/deployment-metadata-handler.ts +0 -518
- package/src/utils/error-recovery.ts +0 -680
- package/src/utils/logger.ts +0 -60
- package/src/utils/mcp-auth-middleware.ts +0 -262
- package/src/utils/mcp-config-manager.ts +0 -270
- package/src/utils/mcp-server-manager.ts +0 -446
- package/src/utils/mcp-tool-registry.ts +0 -298
- package/src/utils/migrate-snow-flow.ts +0 -98
- package/src/utils/oauth-html-templates.ts +0 -188
- package/src/utils/scope-utils.ts +0 -443
- package/src/utils/servicenow-client.ts +0 -3321
- package/src/utils/servicenow-id-generator.ts +0 -181
- package/src/utils/snow-memory-manager.ts +0 -605
- package/src/utils/snow-oauth.ts +0 -797
- package/src/utils/template-engine.ts +0 -463
- package/src/utils/theme-manager.ts +0 -295
- package/src/utils/unified-auth-store.ts +0 -222
- package/src/utils/update-set-importer.ts +0 -422
- package/src/utils/update-set-xml-packager.ts +0 -371
- package/src/utils/widget-template-generator.ts +0 -1744
- package/src/version.ts +0 -1950
|
@@ -1,678 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* servicenow-automation MCP Server - REFACTORED
|
|
4
|
-
* Uses BaseMCPServer to eliminate code duplication
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { BaseMCPServer, ToolResult } from './base-mcp-server.js';
|
|
8
|
-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
-
|
|
10
|
-
export class ServiceNowAutomationMCP extends BaseMCPServer {
|
|
11
|
-
constructor() {
|
|
12
|
-
super({
|
|
13
|
-
name: 'servicenow-automation',
|
|
14
|
-
version: '2.0.0',
|
|
15
|
-
description: 'Handles scheduled tasks, events, and automated processes'
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
protected setupTools(): void {
|
|
20
|
-
// Tools are defined in getTools() method
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
protected getTools(): Tool[] {
|
|
24
|
-
return [
|
|
25
|
-
{
|
|
26
|
-
name: 'snow_create_scheduled_job',
|
|
27
|
-
description: 'Create Scheduled Job with dynamic schedule discovery - NO hardcoded values',
|
|
28
|
-
inputSchema: {
|
|
29
|
-
type: 'object',
|
|
30
|
-
properties: {
|
|
31
|
-
name: { type: 'string', description: 'Scheduled Job name' },
|
|
32
|
-
script: { type: 'string', description: 'JavaScript code to execute' },
|
|
33
|
-
description: { type: 'string', description: 'Job description' },
|
|
34
|
-
schedule: { type: 'string', description: 'Schedule pattern (daily, weekly, monthly, or cron)' },
|
|
35
|
-
active: { type: 'boolean', description: 'Job active status' },
|
|
36
|
-
runAsUser: { type: 'string', description: 'User to run job as' },
|
|
37
|
-
timeZone: { type: 'string', description: 'Time zone for execution' }
|
|
38
|
-
},
|
|
39
|
-
required: ['name', 'script', 'schedule']
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'snow_create_event_rule',
|
|
44
|
-
description: 'Create Event Rule with dynamic event discovery - NO hardcoded values',
|
|
45
|
-
inputSchema: {
|
|
46
|
-
type: 'object',
|
|
47
|
-
properties: {
|
|
48
|
-
name: { type: 'string', description: 'Event Rule name' },
|
|
49
|
-
eventName: { type: 'string', description: 'Event name to listen for' },
|
|
50
|
-
condition: { type: 'string', description: 'Event condition script' },
|
|
51
|
-
script: { type: 'string', description: 'Action script to execute' },
|
|
52
|
-
description: { type: 'string', description: 'Rule description' },
|
|
53
|
-
active: { type: 'boolean', description: 'Rule active status' },
|
|
54
|
-
order: { type: 'number', description: 'Execution order' }
|
|
55
|
-
},
|
|
56
|
-
required: ['name', 'eventName', 'script']
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'snow_create_notification',
|
|
61
|
-
description: 'Create Notification with dynamic template discovery - NO hardcoded values',
|
|
62
|
-
inputSchema: {
|
|
63
|
-
type: 'object',
|
|
64
|
-
properties: {
|
|
65
|
-
name: { type: 'string', description: 'Notification name' },
|
|
66
|
-
table: { type: 'string', description: 'Table to monitor' },
|
|
67
|
-
when: { type: 'string', description: 'When to send (inserted, updated, deleted)' },
|
|
68
|
-
condition: { type: 'string', description: 'Condition script' },
|
|
69
|
-
recipients: { type: 'string', description: 'Recipient specification' },
|
|
70
|
-
subject: { type: 'string', description: 'Email subject' },
|
|
71
|
-
message: { type: 'string', description: 'Email message body' },
|
|
72
|
-
active: { type: 'boolean', description: 'Notification active status' }
|
|
73
|
-
},
|
|
74
|
-
required: ['name', 'table', 'when', 'recipients', 'subject', 'message']
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'snow_create_sla_definition',
|
|
79
|
-
description: 'Create SLA Definition with dynamic field discovery - NO hardcoded values',
|
|
80
|
-
inputSchema: {
|
|
81
|
-
type: 'object',
|
|
82
|
-
properties: {
|
|
83
|
-
name: { type: 'string', description: 'SLA Definition name' },
|
|
84
|
-
table: { type: 'string', description: 'Table to apply SLA to' },
|
|
85
|
-
condition: { type: 'string', description: 'SLA condition script' },
|
|
86
|
-
duration: { type: 'string', description: 'Duration specification' },
|
|
87
|
-
durationType: { type: 'string', description: 'Duration type (business, calendar)' },
|
|
88
|
-
schedule: { type: 'string', description: 'Schedule to use' },
|
|
89
|
-
active: { type: 'boolean', description: 'SLA active status' },
|
|
90
|
-
description: { type: 'string', description: 'SLA description' }
|
|
91
|
-
},
|
|
92
|
-
required: ['name', 'table', 'condition', 'duration']
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: 'snow_create_escalation_rule',
|
|
97
|
-
description: 'Create Escalation Rule with dynamic escalation discovery - NO hardcoded values',
|
|
98
|
-
inputSchema: {
|
|
99
|
-
type: 'object',
|
|
100
|
-
properties: {
|
|
101
|
-
name: { type: 'string', description: 'Escalation Rule name' },
|
|
102
|
-
table: { type: 'string', description: 'Table to monitor' },
|
|
103
|
-
condition: { type: 'string', description: 'Escalation condition' },
|
|
104
|
-
escalationTime: { type: 'number', description: 'Escalation time in minutes' },
|
|
105
|
-
escalationScript: { type: 'string', description: 'Escalation action script' },
|
|
106
|
-
active: { type: 'boolean', description: 'Rule active status' },
|
|
107
|
-
order: { type: 'number', description: 'Execution order' },
|
|
108
|
-
description: { type: 'string', description: 'Rule description' }
|
|
109
|
-
},
|
|
110
|
-
required: ['name', 'table', 'condition', 'escalationTime', 'escalationScript']
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: 'snow_create_workflow_activity',
|
|
115
|
-
description: 'Create Workflow Activity with dynamic workflow discovery - NO hardcoded values',
|
|
116
|
-
inputSchema: {
|
|
117
|
-
type: 'object',
|
|
118
|
-
properties: {
|
|
119
|
-
name: { type: 'string', description: 'Activity name' },
|
|
120
|
-
workflowName: { type: 'string', description: 'Parent workflow name' },
|
|
121
|
-
activityType: { type: 'string', description: 'Activity type' },
|
|
122
|
-
script: { type: 'string', description: 'Activity script' },
|
|
123
|
-
condition: { type: 'string', description: 'Activity condition' },
|
|
124
|
-
order: { type: 'number', description: 'Activity order' },
|
|
125
|
-
description: { type: 'string', description: 'Activity description' }
|
|
126
|
-
},
|
|
127
|
-
required: ['name', 'workflowName', 'activityType']
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: 'snow_discover_schedules',
|
|
132
|
-
description: 'Discover all available schedules dynamically',
|
|
133
|
-
inputSchema: {
|
|
134
|
-
type: 'object',
|
|
135
|
-
properties: {
|
|
136
|
-
type: { type: 'string', description: 'Filter by schedule type' }
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
name: 'snow_discover_events',
|
|
142
|
-
description: 'Discover all available events dynamically',
|
|
143
|
-
inputSchema: {
|
|
144
|
-
type: 'object',
|
|
145
|
-
properties: {
|
|
146
|
-
table: { type: 'string', description: 'Filter by table' }
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: 'snow_discover_automation_jobs',
|
|
152
|
-
description: 'Discover all automation jobs dynamically',
|
|
153
|
-
inputSchema: {
|
|
154
|
-
type: 'object',
|
|
155
|
-
properties: {
|
|
156
|
-
status: { type: 'string', description: 'Filter by status: active, inactive, all' }
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
name: 'snow_test_scheduled_job',
|
|
162
|
-
description: 'Test scheduled job execution',
|
|
163
|
-
inputSchema: {
|
|
164
|
-
type: 'object',
|
|
165
|
-
properties: {
|
|
166
|
-
jobName: { type: 'string', description: 'Scheduled job name to test' }
|
|
167
|
-
},
|
|
168
|
-
required: ['jobName']
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
protected async executeTool(name: string, args: any): Promise<ToolResult> {
|
|
175
|
-
const startTime = Date.now();
|
|
176
|
-
|
|
177
|
-
switch (name) {
|
|
178
|
-
case 'snow_create_scheduled_job':
|
|
179
|
-
return await this.handleSnowCreateScheduledJob(args);
|
|
180
|
-
case 'snow_create_event_rule':
|
|
181
|
-
return await this.handleSnowCreateEventRule(args);
|
|
182
|
-
case 'snow_create_notification':
|
|
183
|
-
return await this.handleSnowCreateNotification(args);
|
|
184
|
-
case 'snow_create_sla_definition':
|
|
185
|
-
return await this.handleSnowCreateSlaDefinition(args);
|
|
186
|
-
case 'snow_create_escalation_rule':
|
|
187
|
-
return await this.handleSnowCreateEscalationRule(args);
|
|
188
|
-
case 'snow_create_workflow_activity':
|
|
189
|
-
return await this.handleSnowCreateWorkflowActivity(args);
|
|
190
|
-
case 'snow_discover_schedules':
|
|
191
|
-
return await this.handleSnowDiscoverSchedules(args);
|
|
192
|
-
case 'snow_discover_events':
|
|
193
|
-
return await this.handleSnowDiscoverEvents(args);
|
|
194
|
-
case 'snow_discover_automation_jobs':
|
|
195
|
-
return await this.handleSnowDiscoverAutomationJobs(args);
|
|
196
|
-
case 'snow_test_scheduled_job':
|
|
197
|
-
return await this.handleSnowTestScheduledJob(args);
|
|
198
|
-
default:
|
|
199
|
-
return {
|
|
200
|
-
success: false,
|
|
201
|
-
error: `Unknown tool: ${name}`
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Tool handlers
|
|
207
|
-
private async handleSnowCreateScheduledJob(args: any): Promise<ToolResult> {
|
|
208
|
-
const startTime = Date.now();
|
|
209
|
-
try {
|
|
210
|
-
const jobData = {
|
|
211
|
-
name: args.name,
|
|
212
|
-
script: args.script,
|
|
213
|
-
description: args.description || '',
|
|
214
|
-
run_type: this.parseScheduleType(args.schedule),
|
|
215
|
-
run_time: this.parseScheduleTime(args.schedule),
|
|
216
|
-
active: args.active !== false,
|
|
217
|
-
run_as: args.runAsUser || 'system',
|
|
218
|
-
time_zone: args.timeZone || 'UTC'
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const result = await this.client.createRecord('sysauto_script', jobData);
|
|
222
|
-
|
|
223
|
-
return {
|
|
224
|
-
success: result.success,
|
|
225
|
-
result: result.result,
|
|
226
|
-
error: result.success ? undefined : 'Failed to create scheduled job',
|
|
227
|
-
executionTime: Date.now() - startTime
|
|
228
|
-
};
|
|
229
|
-
} catch (error) {
|
|
230
|
-
return {
|
|
231
|
-
success: false,
|
|
232
|
-
error: error instanceof Error ? error.message : 'Failed to create scheduled job',
|
|
233
|
-
executionTime: Date.now() - startTime
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
private async handleSnowCreateEventRule(args: any): Promise<ToolResult> {
|
|
239
|
-
const startTime = Date.now();
|
|
240
|
-
try {
|
|
241
|
-
const ruleData = {
|
|
242
|
-
name: args.name,
|
|
243
|
-
event_name: args.eventName,
|
|
244
|
-
condition: args.condition || '',
|
|
245
|
-
script: args.script,
|
|
246
|
-
description: args.description || '',
|
|
247
|
-
active: args.active !== false,
|
|
248
|
-
order: args.order || 100
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const result = await this.client.createRecord('sysevent_script', ruleData);
|
|
252
|
-
|
|
253
|
-
return {
|
|
254
|
-
success: result.success,
|
|
255
|
-
result: result.result,
|
|
256
|
-
error: result.success ? undefined : 'Failed to create event rule',
|
|
257
|
-
executionTime: Date.now() - startTime
|
|
258
|
-
};
|
|
259
|
-
} catch (error) {
|
|
260
|
-
return {
|
|
261
|
-
success: false,
|
|
262
|
-
error: error instanceof Error ? error.message : 'Failed to create event rule',
|
|
263
|
-
executionTime: Date.now() - startTime
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
private async handleSnowCreateNotification(args: any): Promise<ToolResult> {
|
|
269
|
-
const startTime = Date.now();
|
|
270
|
-
try {
|
|
271
|
-
const notificationData = {
|
|
272
|
-
name: args.name,
|
|
273
|
-
collection: args.table,
|
|
274
|
-
when: args.when,
|
|
275
|
-
condition: args.condition || '',
|
|
276
|
-
recipients: args.recipients,
|
|
277
|
-
subject: args.subject,
|
|
278
|
-
message_html: args.message,
|
|
279
|
-
active: args.active !== false
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
const result = await this.client.createRecord('sysevent_email_action', notificationData);
|
|
283
|
-
|
|
284
|
-
return {
|
|
285
|
-
success: result.success,
|
|
286
|
-
result: result.result,
|
|
287
|
-
error: result.success ? undefined : 'Failed to create notification',
|
|
288
|
-
executionTime: Date.now() - startTime
|
|
289
|
-
};
|
|
290
|
-
} catch (error) {
|
|
291
|
-
return {
|
|
292
|
-
success: false,
|
|
293
|
-
error: error instanceof Error ? error.message : 'Failed to create notification',
|
|
294
|
-
executionTime: Date.now() - startTime
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
private async handleSnowCreateSlaDefinition(args: any): Promise<ToolResult> {
|
|
300
|
-
const startTime = Date.now();
|
|
301
|
-
try {
|
|
302
|
-
const slaData = {
|
|
303
|
-
name: args.name,
|
|
304
|
-
collection: args.table,
|
|
305
|
-
start_condition: args.condition,
|
|
306
|
-
duration: args.duration,
|
|
307
|
-
duration_type: args.durationType || 'business',
|
|
308
|
-
schedule: args.schedule || '',
|
|
309
|
-
active: args.active !== false,
|
|
310
|
-
short_description: args.description || ''
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
const result = await this.client.createRecord('contract_sla', slaData);
|
|
314
|
-
|
|
315
|
-
return {
|
|
316
|
-
success: result.success,
|
|
317
|
-
result: result.result,
|
|
318
|
-
error: result.success ? undefined : 'Failed to create SLA definition',
|
|
319
|
-
executionTime: Date.now() - startTime
|
|
320
|
-
};
|
|
321
|
-
} catch (error) {
|
|
322
|
-
return {
|
|
323
|
-
success: false,
|
|
324
|
-
error: error instanceof Error ? error.message : 'Failed to create SLA definition',
|
|
325
|
-
executionTime: Date.now() - startTime
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
private async handleSnowCreateEscalationRule(args: any): Promise<ToolResult> {
|
|
331
|
-
const startTime = Date.now();
|
|
332
|
-
try {
|
|
333
|
-
const escalationData = {
|
|
334
|
-
name: args.name,
|
|
335
|
-
table: args.table,
|
|
336
|
-
condition: args.condition,
|
|
337
|
-
escalation_time: args.escalationTime,
|
|
338
|
-
script: args.escalationScript,
|
|
339
|
-
active: args.active !== false,
|
|
340
|
-
order: args.order || 100,
|
|
341
|
-
description: args.description || ''
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
// Note: ServiceNow might use different tables for escalations
|
|
345
|
-
const result = await this.client.createRecord('sys_trigger', escalationData);
|
|
346
|
-
|
|
347
|
-
return {
|
|
348
|
-
success: result.success,
|
|
349
|
-
result: result.result,
|
|
350
|
-
error: result.success ? undefined : 'Failed to create escalation rule',
|
|
351
|
-
executionTime: Date.now() - startTime
|
|
352
|
-
};
|
|
353
|
-
} catch (error) {
|
|
354
|
-
return {
|
|
355
|
-
success: false,
|
|
356
|
-
error: error instanceof Error ? error.message : 'Failed to create escalation rule',
|
|
357
|
-
executionTime: Date.now() - startTime
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
private async handleSnowCreateWorkflowActivity(args: any): Promise<ToolResult> {
|
|
363
|
-
const startTime = Date.now();
|
|
364
|
-
try {
|
|
365
|
-
// First find the parent workflow
|
|
366
|
-
const workflowResponse = await this.client.searchRecords(
|
|
367
|
-
'wf_workflow',
|
|
368
|
-
`name=${args.workflowName}`,
|
|
369
|
-
1
|
|
370
|
-
);
|
|
371
|
-
|
|
372
|
-
if (!workflowResponse.success || !workflowResponse.data?.result?.length) {
|
|
373
|
-
throw new Error(`Workflow not found: ${args.workflowName}`);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
const workflowId = workflowResponse.data.result[0].sys_id;
|
|
377
|
-
|
|
378
|
-
const activityData = {
|
|
379
|
-
workflow_version: workflowId,
|
|
380
|
-
name: args.name,
|
|
381
|
-
activity_type: args.activityType,
|
|
382
|
-
script: args.script || '',
|
|
383
|
-
condition: args.condition || '',
|
|
384
|
-
order: args.order || 100,
|
|
385
|
-
description: args.description || ''
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
const result = await this.client.createRecord('wf_activity', activityData);
|
|
389
|
-
|
|
390
|
-
return {
|
|
391
|
-
success: result.success,
|
|
392
|
-
result: result.result,
|
|
393
|
-
error: result.success ? undefined : 'Failed to create workflow activity',
|
|
394
|
-
executionTime: Date.now() - startTime
|
|
395
|
-
};
|
|
396
|
-
} catch (error) {
|
|
397
|
-
return {
|
|
398
|
-
success: false,
|
|
399
|
-
error: error instanceof Error ? error.message : 'Failed to create workflow activity',
|
|
400
|
-
executionTime: Date.now() - startTime
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
private async handleSnowDiscoverSchedules(args: any): Promise<ToolResult> {
|
|
406
|
-
const startTime = Date.now();
|
|
407
|
-
try {
|
|
408
|
-
const schedules: any[] = [];
|
|
409
|
-
|
|
410
|
-
// Discover schedules
|
|
411
|
-
const scheduleResponse = await this.client.searchRecords('cmn_schedule', '', 50);
|
|
412
|
-
if (scheduleResponse.success && scheduleResponse.data) {
|
|
413
|
-
schedules.push(...scheduleResponse.data.result.map((schedule: any) => ({
|
|
414
|
-
name: schedule.name,
|
|
415
|
-
type: schedule.type,
|
|
416
|
-
time_zone: schedule.time_zone,
|
|
417
|
-
description: schedule.description
|
|
418
|
-
})));
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
return {
|
|
422
|
-
success: true,
|
|
423
|
-
result: { schedules },
|
|
424
|
-
executionTime: Date.now() - startTime
|
|
425
|
-
};
|
|
426
|
-
} catch (error) {
|
|
427
|
-
return {
|
|
428
|
-
success: false,
|
|
429
|
-
error: error instanceof Error ? error.message : 'Failed to discover schedules',
|
|
430
|
-
executionTime: Date.now() - startTime
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
private async handleSnowDiscoverEvents(args: any): Promise<ToolResult> {
|
|
436
|
-
const startTime = Date.now();
|
|
437
|
-
try {
|
|
438
|
-
const events: any[] = [];
|
|
439
|
-
|
|
440
|
-
// Build query based on table filter
|
|
441
|
-
let query = '';
|
|
442
|
-
if (args.table) {
|
|
443
|
-
query = `table=${args.table}`;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// Discover event definitions
|
|
447
|
-
const eventResponse = await this.client.searchRecords('sysevent', query, 50);
|
|
448
|
-
if (eventResponse.success && eventResponse.data) {
|
|
449
|
-
events.push(...eventResponse.data.result.map((event: any) => ({
|
|
450
|
-
name: event.name,
|
|
451
|
-
table: event.table,
|
|
452
|
-
description: event.description,
|
|
453
|
-
parm1_label: event.parm1,
|
|
454
|
-
parm2_label: event.parm2
|
|
455
|
-
})));
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return {
|
|
459
|
-
success: true,
|
|
460
|
-
result: { events },
|
|
461
|
-
executionTime: Date.now() - startTime
|
|
462
|
-
};
|
|
463
|
-
} catch (error) {
|
|
464
|
-
return {
|
|
465
|
-
success: false,
|
|
466
|
-
error: error instanceof Error ? error.message : 'Failed to discover events',
|
|
467
|
-
executionTime: Date.now() - startTime
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
private async handleSnowDiscoverAutomationJobs(args: any): Promise<ToolResult> {
|
|
473
|
-
const startTime = Date.now();
|
|
474
|
-
try {
|
|
475
|
-
const jobs: any[] = [];
|
|
476
|
-
const status = args?.status || 'all';
|
|
477
|
-
|
|
478
|
-
// Build query based on status filter
|
|
479
|
-
let query = '';
|
|
480
|
-
if (status === 'active') {
|
|
481
|
-
query = 'active=true';
|
|
482
|
-
} else if (status === 'inactive') {
|
|
483
|
-
query = 'active=false';
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// Discover scheduled jobs
|
|
487
|
-
const scheduledResponse = await this.client.searchRecords('sysauto_script', query, 50);
|
|
488
|
-
if (scheduledResponse.success && scheduledResponse.data) {
|
|
489
|
-
jobs.push(...scheduledResponse.data.result.map((job: any) => ({
|
|
490
|
-
type: 'scheduled_job',
|
|
491
|
-
name: job.name,
|
|
492
|
-
active: job.active,
|
|
493
|
-
run_type: job.run_type,
|
|
494
|
-
last_run: job.last_run_time
|
|
495
|
-
})));
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
// Discover event scripts
|
|
499
|
-
const eventResponse = await this.client.searchRecords('sysevent_script', query, 50);
|
|
500
|
-
if (eventResponse.success && eventResponse.data) {
|
|
501
|
-
jobs.push(...eventResponse.data.result.map((job: any) => ({
|
|
502
|
-
type: 'event_script',
|
|
503
|
-
name: job.name,
|
|
504
|
-
active: job.active,
|
|
505
|
-
event_name: job.event_name
|
|
506
|
-
})));
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return {
|
|
510
|
-
success: true,
|
|
511
|
-
result: { jobs },
|
|
512
|
-
executionTime: Date.now() - startTime
|
|
513
|
-
};
|
|
514
|
-
} catch (error) {
|
|
515
|
-
return {
|
|
516
|
-
success: false,
|
|
517
|
-
error: error instanceof Error ? error.message : 'Failed to discover automation jobs',
|
|
518
|
-
executionTime: Date.now() - startTime
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
private async handleSnowTestScheduledJob(args: any): Promise<ToolResult> {
|
|
524
|
-
const startTime = Date.now();
|
|
525
|
-
try {
|
|
526
|
-
// Find the scheduled job
|
|
527
|
-
const jobResponse = await this.client.searchRecords(
|
|
528
|
-
'sysauto_script',
|
|
529
|
-
`name=${args.jobName}`,
|
|
530
|
-
1
|
|
531
|
-
);
|
|
532
|
-
|
|
533
|
-
if (!jobResponse.success || !jobResponse.data?.result?.length) {
|
|
534
|
-
throw new Error(`Scheduled job not found: ${args.jobName}`);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
const job = jobResponse.data.result[0];
|
|
538
|
-
|
|
539
|
-
// Execute the scheduled job and monitor its execution
|
|
540
|
-
const executionStartTime = Date.now();
|
|
541
|
-
let testResult: any;
|
|
542
|
-
|
|
543
|
-
try {
|
|
544
|
-
// Trigger the scheduled job execution
|
|
545
|
-
this.logger.info('Triggering scheduled job execution', {
|
|
546
|
-
jobName: job.name,
|
|
547
|
-
jobId: job.sys_id
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
// Method 1: Try to execute via sys_trigger endpoint
|
|
551
|
-
const triggerResponse = await this.client.post('/api/now/table/sys_trigger', {
|
|
552
|
-
script: `gs.eventQueue('sysauto.script.execute', null, '${job.sys_id}', '');`,
|
|
553
|
-
name: `Test execution of ${job.name}`,
|
|
554
|
-
next_action: new Date(Date.now() + 5000).toISOString() // Execute in 5 seconds
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
if (triggerResponse.result) {
|
|
558
|
-
this.logger.info('Job execution trigger created', {
|
|
559
|
-
triggerId: triggerResponse.result.sys_id
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
// Wait a brief moment for execution to begin
|
|
563
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
564
|
-
|
|
565
|
-
// Check for recent execution history
|
|
566
|
-
const executionHistoryResponse = await this.client.get(
|
|
567
|
-
`/api/now/table/sys_execution_tracker?sysparm_query=source=${job.sys_id}^ORDERBYDESCsys_created_on&sysparm_limit=1`
|
|
568
|
-
);
|
|
569
|
-
|
|
570
|
-
const realExecutionTime = Date.now() - executionStartTime;
|
|
571
|
-
|
|
572
|
-
if (executionHistoryResponse.result && executionHistoryResponse.result.length > 0) {
|
|
573
|
-
const execution = executionHistoryResponse.result[0];
|
|
574
|
-
testResult = {
|
|
575
|
-
job_name: job.name,
|
|
576
|
-
job_id: job.sys_id,
|
|
577
|
-
test_status: 'executed',
|
|
578
|
-
execution_time: realExecutionTime,
|
|
579
|
-
trigger_id: triggerResponse.result.sys_id,
|
|
580
|
-
execution_tracker_id: execution.sys_id,
|
|
581
|
-
execution_state: execution.state,
|
|
582
|
-
execution_progress: execution.completion_percentage || 0,
|
|
583
|
-
message: `Job execution initiated successfully. Trigger created: ${triggerResponse.result.sys_id}`,
|
|
584
|
-
details: {
|
|
585
|
-
job_active: job.active,
|
|
586
|
-
job_script: job.script ? 'Present' : 'Missing',
|
|
587
|
-
job_condition: job.condition_script || 'None',
|
|
588
|
-
execution_history_found: true
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
} else {
|
|
592
|
-
testResult = {
|
|
593
|
-
job_name: job.name,
|
|
594
|
-
job_id: job.sys_id,
|
|
595
|
-
test_status: 'triggered',
|
|
596
|
-
execution_time: realExecutionTime,
|
|
597
|
-
trigger_id: triggerResponse.result.sys_id,
|
|
598
|
-
message: `Job execution trigger created successfully. Check sys_execution_tracker for progress.`,
|
|
599
|
-
details: {
|
|
600
|
-
job_active: job.active,
|
|
601
|
-
job_script: job.script ? 'Present' : 'Missing',
|
|
602
|
-
job_condition: job.condition_script || 'None',
|
|
603
|
-
execution_history_found: false
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
} else {
|
|
609
|
-
throw new Error('Failed to create execution trigger');
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
} catch (executionError) {
|
|
613
|
-
// If direct execution fails, perform validation instead
|
|
614
|
-
this.logger.warn('Job execution failed, performing validation instead', {
|
|
615
|
-
jobName: job.name,
|
|
616
|
-
error: executionError instanceof Error ? executionError.message : String(executionError)
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
const realExecutionTime = Date.now() - executionStartTime;
|
|
620
|
-
|
|
621
|
-
testResult = {
|
|
622
|
-
job_name: job.name,
|
|
623
|
-
job_id: job.sys_id,
|
|
624
|
-
test_status: 'validated',
|
|
625
|
-
execution_time: realExecutionTime,
|
|
626
|
-
message: `Job validation completed. Execution failed: ${executionError instanceof Error ? executionError.message : String(executionError)}`,
|
|
627
|
-
details: {
|
|
628
|
-
job_active: job.active,
|
|
629
|
-
job_script: job.script ? 'Present' : 'Missing',
|
|
630
|
-
job_condition: job.condition_script || 'None',
|
|
631
|
-
job_run_as: job.run_as || 'system',
|
|
632
|
-
job_schedule: job.run_period || 'Not scheduled',
|
|
633
|
-
validation_performed: true,
|
|
634
|
-
execution_attempted: true,
|
|
635
|
-
execution_error: executionError instanceof Error ? executionError.message : String(executionError)
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
return {
|
|
641
|
-
success: true,
|
|
642
|
-
result: testResult,
|
|
643
|
-
executionTime: Date.now() - startTime
|
|
644
|
-
};
|
|
645
|
-
} catch (error) {
|
|
646
|
-
return {
|
|
647
|
-
success: false,
|
|
648
|
-
error: error instanceof Error ? error.message : 'Failed to test scheduled job',
|
|
649
|
-
executionTime: Date.now() - startTime
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
// Helper methods
|
|
655
|
-
private parseScheduleType(schedule: string): string {
|
|
656
|
-
const scheduleLower = schedule.toLowerCase();
|
|
657
|
-
if (scheduleLower.includes('daily')) return 'daily';
|
|
658
|
-
if (scheduleLower.includes('weekly')) return 'weekly';
|
|
659
|
-
if (scheduleLower.includes('monthly')) return 'monthly';
|
|
660
|
-
if (scheduleLower.includes('cron')) return 'cron';
|
|
661
|
-
return 'periodically';
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
private parseScheduleTime(schedule: string): string {
|
|
665
|
-
// Simple parsing - in real implementation would be more sophisticated
|
|
666
|
-
const timeMatch = schedule.match(/(\d{1,2}):(\d{2})/);
|
|
667
|
-
if (timeMatch) {
|
|
668
|
-
return `${timeMatch[1]}:${timeMatch[2]}:00`;
|
|
669
|
-
}
|
|
670
|
-
return '00:00:00';
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
// Create and run the server
|
|
675
|
-
if (require.main === module) {
|
|
676
|
-
const server = new ServiceNowAutomationMCP();
|
|
677
|
-
server.start().catch(console.error);
|
|
678
|
-
}
|