snow-flow 1.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/.env.example +49 -0
- package/.mcp.json +106 -0
- package/.mcp.json.template +106 -0
- package/LICENSE +21 -0
- package/README.md +236 -0
- package/bin/snow-flow +4 -0
- package/bin/snow-flow.js +3 -0
- package/claude-flow +79 -0
- package/claude-flow.bat +18 -0
- package/claude-flow.config.json +20 -0
- package/claude-flow.ps1 +24 -0
- package/dist/agents/app-creator.agent.d.ts +55 -0
- package/dist/agents/app-creator.agent.d.ts.map +1 -0
- package/dist/agents/app-creator.agent.js +1292 -0
- package/dist/agents/app-creator.agent.js.map +1 -0
- package/dist/agents/base-snow-agent.d.ts +63 -0
- package/dist/agents/base-snow-agent.d.ts.map +1 -0
- package/dist/agents/base-snow-agent.js +296 -0
- package/dist/agents/base-snow-agent.js.map +1 -0
- package/dist/agents/script-generator.agent.d.ts +32 -0
- package/dist/agents/script-generator.agent.d.ts.map +1 -0
- package/dist/agents/script-generator.agent.js +772 -0
- package/dist/agents/script-generator.agent.js.map +1 -0
- package/dist/agents/ui-builder.agent.d.ts +50 -0
- package/dist/agents/ui-builder.agent.d.ts.map +1 -0
- package/dist/agents/ui-builder.agent.js +1539 -0
- package/dist/agents/ui-builder.agent.js.map +1 -0
- package/dist/agents/widget-builder.agent.d.ts +32 -0
- package/dist/agents/widget-builder.agent.d.ts.map +1 -0
- package/dist/agents/widget-builder.agent.js +439 -0
- package/dist/agents/widget-builder.agent.js.map +1 -0
- package/dist/agents/workflow-designer.agent.d.ts +31 -0
- package/dist/agents/workflow-designer.agent.d.ts.map +1 -0
- package/dist/agents/workflow-designer.agent.js +583 -0
- package/dist/agents/workflow-designer.agent.js.map +1 -0
- package/dist/api/error-handling.d.ts +214 -0
- package/dist/api/error-handling.d.ts.map +1 -0
- package/dist/api/error-handling.js +594 -0
- package/dist/api/error-handling.js.map +1 -0
- package/dist/api/flow-designer-api.d.ts +167 -0
- package/dist/api/flow-designer-api.d.ts.map +1 -0
- package/dist/api/flow-designer-api.js +555 -0
- package/dist/api/flow-designer-api.js.map +1 -0
- package/dist/api/natural-language-mapper.d.ts +126 -0
- package/dist/api/natural-language-mapper.d.ts.map +1 -0
- package/dist/api/natural-language-mapper.js +498 -0
- package/dist/api/natural-language-mapper.js.map +1 -0
- package/dist/api/performance-optimizer.d.ts +240 -0
- package/dist/api/performance-optimizer.d.ts.map +1 -0
- package/dist/api/performance-optimizer.js +701 -0
- package/dist/api/performance-optimizer.js.map +1 -0
- package/dist/api/transaction-manager.d.ts +189 -0
- package/dist/api/transaction-manager.d.ts.map +1 -0
- package/dist/api/transaction-manager.js +576 -0
- package/dist/api/transaction-manager.js.map +1 -0
- package/dist/cli/deploy-artifact.d.ts +7 -0
- package/dist/cli/deploy-artifact.d.ts.map +1 -0
- package/dist/cli/deploy-artifact.js +279 -0
- package/dist/cli/deploy-artifact.js.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +2057 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/managers/scope-manager.d.ts +75 -0
- package/dist/managers/scope-manager.d.ts.map +1 -0
- package/dist/managers/scope-manager.js +448 -0
- package/dist/managers/scope-manager.js.map +1 -0
- package/dist/mcp/mcp-wrapper.d.ts +8 -0
- package/dist/mcp/mcp-wrapper.d.ts.map +1 -0
- package/dist/mcp/mcp-wrapper.js +77 -0
- package/dist/mcp/mcp-wrapper.js.map +1 -0
- package/dist/mcp/servicenow-automation-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-automation-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-automation-mcp.js +683 -0
- package/dist/mcp/servicenow-automation-mcp.js.map +1 -0
- package/dist/mcp/servicenow-deployment-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-deployment-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-deployment-mcp.js +972 -0
- package/dist/mcp/servicenow-deployment-mcp.js.map +1 -0
- package/dist/mcp/servicenow-flow-composer-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-flow-composer-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-flow-composer-mcp.js +1121 -0
- package/dist/mcp/servicenow-flow-composer-mcp.js.map +1 -0
- package/dist/mcp/servicenow-graph-memory-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-graph-memory-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-graph-memory-mcp.js +703 -0
- package/dist/mcp/servicenow-graph-memory-mcp.js.map +1 -0
- package/dist/mcp/servicenow-integration-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-integration-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-integration-mcp.js +689 -0
- package/dist/mcp/servicenow-integration-mcp.js.map +1 -0
- package/dist/mcp/servicenow-intelligent-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-intelligent-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-intelligent-mcp.js +1138 -0
- package/dist/mcp/servicenow-intelligent-mcp.js.map +1 -0
- package/dist/mcp/servicenow-mcp-server.d.ts +37 -0
- package/dist/mcp/servicenow-mcp-server.d.ts.map +1 -0
- package/dist/mcp/servicenow-mcp-server.js +648 -0
- package/dist/mcp/servicenow-mcp-server.js.map +1 -0
- package/dist/mcp/servicenow-operations-mcp.d.ts +15 -0
- package/dist/mcp/servicenow-operations-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-operations-mcp.js +1287 -0
- package/dist/mcp/servicenow-operations-mcp.js.map +1 -0
- package/dist/mcp/servicenow-platform-development-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-platform-development-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-platform-development-mcp.js +557 -0
- package/dist/mcp/servicenow-platform-development-mcp.js.map +1 -0
- package/dist/mcp/servicenow-progressive-indexer.d.ts +79 -0
- package/dist/mcp/servicenow-progressive-indexer.d.ts.map +1 -0
- package/dist/mcp/servicenow-progressive-indexer.js +320 -0
- package/dist/mcp/servicenow-progressive-indexer.js.map +1 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.js +888 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.js.map +1 -0
- package/dist/mcp/servicenow-security-compliance-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-security-compliance-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-security-compliance-mcp.js +812 -0
- package/dist/mcp/servicenow-security-compliance-mcp.js.map +1 -0
- package/dist/mcp/servicenow-update-set-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-update-set-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-update-set-mcp.js +599 -0
- package/dist/mcp/servicenow-update-set-mcp.js.map +1 -0
- package/dist/mcp/start-all-mcp-servers.d.ts +6 -0
- package/dist/mcp/start-all-mcp-servers.d.ts.map +1 -0
- package/dist/mcp/start-all-mcp-servers.js +65 -0
- package/dist/mcp/start-all-mcp-servers.js.map +1 -0
- package/dist/mcp/start-servicenow-mcp.d.ts +7 -0
- package/dist/mcp/start-servicenow-mcp.d.ts.map +1 -0
- package/dist/mcp/start-servicenow-mcp.js +64 -0
- package/dist/mcp/start-servicenow-mcp.js.map +1 -0
- package/dist/mcp/test-simple-mcp.d.ts +6 -0
- package/dist/mcp/test-simple-mcp.d.ts.map +1 -0
- package/dist/mcp/test-simple-mcp.js +64 -0
- package/dist/mcp/test-simple-mcp.js.map +1 -0
- package/dist/orchestrator/flow-composer.d.ts +269 -0
- package/dist/orchestrator/flow-composer.d.ts.map +1 -0
- package/dist/orchestrator/flow-composer.js +2221 -0
- package/dist/orchestrator/flow-composer.js.map +1 -0
- package/dist/orchestrator/flow-pattern-templates.d.ts +260 -0
- package/dist/orchestrator/flow-pattern-templates.d.ts.map +1 -0
- package/dist/orchestrator/flow-pattern-templates.js +906 -0
- package/dist/orchestrator/flow-pattern-templates.js.map +1 -0
- package/dist/orchestrator/flow-subflow-decision-engine.d.ts +202 -0
- package/dist/orchestrator/flow-subflow-decision-engine.d.ts.map +1 -0
- package/dist/orchestrator/flow-subflow-decision-engine.js +769 -0
- package/dist/orchestrator/flow-subflow-decision-engine.js.map +1 -0
- package/dist/orchestrator/flow-validation-engine.d.ts +145 -0
- package/dist/orchestrator/flow-validation-engine.d.ts.map +1 -0
- package/dist/orchestrator/flow-validation-engine.js +663 -0
- package/dist/orchestrator/flow-validation-engine.js.map +1 -0
- package/dist/orchestrator/snow-orchestrator.d.ts +49 -0
- package/dist/orchestrator/snow-orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/snow-orchestrator.js +235 -0
- package/dist/orchestrator/snow-orchestrator.js.map +1 -0
- package/dist/orchestrator/subflow-creation-handler.d.ts +230 -0
- package/dist/orchestrator/subflow-creation-handler.d.ts.map +1 -0
- package/dist/orchestrator/subflow-creation-handler.js +791 -0
- package/dist/orchestrator/subflow-creation-handler.js.map +1 -0
- package/dist/strategies/global-scope-strategy.d.ts +123 -0
- package/dist/strategies/global-scope-strategy.d.ts.map +1 -0
- package/dist/strategies/global-scope-strategy.js +585 -0
- package/dist/strategies/global-scope-strategy.js.map +1 -0
- package/dist/types/index.d.ts +138 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/servicenow.types.d.ts +260 -0
- package/dist/types/servicenow.types.d.ts.map +1 -0
- package/dist/types/servicenow.types.js +3 -0
- package/dist/types/servicenow.types.js.map +1 -0
- package/dist/types/snow-flow.types.d.ts +114 -0
- package/dist/types/snow-flow.types.d.ts.map +1 -0
- package/dist/types/snow-flow.types.js +3 -0
- package/dist/types/snow-flow.types.js.map +1 -0
- package/dist/utils/action-type-cache.d.ts +66 -0
- package/dist/utils/action-type-cache.d.ts.map +1 -0
- package/dist/utils/action-type-cache.js +237 -0
- package/dist/utils/action-type-cache.js.map +1 -0
- package/dist/utils/agent-detector.d.ts +35 -0
- package/dist/utils/agent-detector.d.ts.map +1 -0
- package/dist/utils/agent-detector.js +353 -0
- package/dist/utils/agent-detector.js.map +1 -0
- package/dist/utils/flow-api-discovery.d.ts +151 -0
- package/dist/utils/flow-api-discovery.d.ts.map +1 -0
- package/dist/utils/flow-api-discovery.js +440 -0
- package/dist/utils/flow-api-discovery.js.map +1 -0
- package/dist/utils/flow-xml-generator.d.ts +41 -0
- package/dist/utils/flow-xml-generator.d.ts.map +1 -0
- package/dist/utils/flow-xml-generator.js +258 -0
- package/dist/utils/flow-xml-generator.js.map +1 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +51 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mcp-auth-middleware.d.ts +58 -0
- package/dist/utils/mcp-auth-middleware.d.ts.map +1 -0
- package/dist/utils/mcp-auth-middleware.js +227 -0
- package/dist/utils/mcp-auth-middleware.js.map +1 -0
- package/dist/utils/mcp-config-manager.d.ts +126 -0
- package/dist/utils/mcp-config-manager.d.ts.map +1 -0
- package/dist/utils/mcp-config-manager.js +209 -0
- package/dist/utils/mcp-config-manager.js.map +1 -0
- package/dist/utils/mcp-server-manager.d.ts +91 -0
- package/dist/utils/mcp-server-manager.d.ts.map +1 -0
- package/dist/utils/mcp-server-manager.js +338 -0
- package/dist/utils/mcp-server-manager.js.map +1 -0
- package/dist/utils/scope-utils.d.ts +72 -0
- package/dist/utils/scope-utils.d.ts.map +1 -0
- package/dist/utils/scope-utils.js +386 -0
- package/dist/utils/scope-utils.js.map +1 -0
- package/dist/utils/servicenow-client.d.ts +233 -0
- package/dist/utils/servicenow-client.d.ts.map +1 -0
- package/dist/utils/servicenow-client.js +1465 -0
- package/dist/utils/servicenow-client.js.map +1 -0
- package/dist/utils/snow-oauth-old.d.ts +65 -0
- package/dist/utils/snow-oauth-old.d.ts.map +1 -0
- package/dist/utils/snow-oauth-old.js +345 -0
- package/dist/utils/snow-oauth-old.js.map +1 -0
- package/dist/utils/snow-oauth.d.ts +85 -0
- package/dist/utils/snow-oauth.d.ts.map +1 -0
- package/dist/utils/snow-oauth.js +512 -0
- package/dist/utils/snow-oauth.js.map +1 -0
- package/dist/utils/template-engine.d.ts +76 -0
- package/dist/utils/template-engine.d.ts.map +1 -0
- package/dist/utils/template-engine.js +391 -0
- package/dist/utils/template-engine.js.map +1 -0
- package/dist/version.d.ts +35 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +72 -0
- package/dist/version.js.map +1 -0
- package/mcp-wrapper.sh +12 -0
- package/package.json +77 -0
- package/reports/swarm-auto-centralized-1752649029776.json +13 -0
- package/scripts/postinstall.js +30 -0
- package/scripts/setup-mcp.js +89 -0
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* ServiceNow Automation MCP Server
|
|
5
|
+
* Handles scheduled tasks, events, and automated processes
|
|
6
|
+
* NO HARDCODED VALUES - All schedules and events discovered dynamically
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
10
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
11
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
12
|
+
const servicenow_client_js_1 = require("../utils/servicenow-client.js");
|
|
13
|
+
const mcp_auth_middleware_js_1 = require("../utils/mcp-auth-middleware.js");
|
|
14
|
+
const mcp_config_manager_js_1 = require("../utils/mcp-config-manager.js");
|
|
15
|
+
const logger_js_1 = require("../utils/logger.js");
|
|
16
|
+
class ServiceNowAutomationMCP {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.server = new index_js_1.Server({
|
|
19
|
+
name: 'servicenow-automation',
|
|
20
|
+
version: '1.0.0',
|
|
21
|
+
}, {
|
|
22
|
+
capabilities: {
|
|
23
|
+
tools: {},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
this.client = new servicenow_client_js_1.ServiceNowClient();
|
|
27
|
+
this.logger = new logger_js_1.Logger('ServiceNowAutomationMCP');
|
|
28
|
+
this.config = mcp_config_manager_js_1.mcpConfig.getConfig();
|
|
29
|
+
this.setupHandlers();
|
|
30
|
+
}
|
|
31
|
+
setupHandlers() {
|
|
32
|
+
this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
33
|
+
tools: [
|
|
34
|
+
{
|
|
35
|
+
name: 'snow_create_scheduled_job',
|
|
36
|
+
description: 'Create Scheduled Job with dynamic schedule discovery - NO hardcoded values',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
name: { type: 'string', description: 'Scheduled Job name' },
|
|
41
|
+
script: { type: 'string', description: 'JavaScript code to execute' },
|
|
42
|
+
description: { type: 'string', description: 'Job description' },
|
|
43
|
+
schedule: { type: 'string', description: 'Schedule pattern (daily, weekly, monthly, or cron)' },
|
|
44
|
+
active: { type: 'boolean', description: 'Job active status' },
|
|
45
|
+
runAsUser: { type: 'string', description: 'User to run job as' },
|
|
46
|
+
timeZone: { type: 'string', description: 'Time zone for execution' }
|
|
47
|
+
},
|
|
48
|
+
required: ['name', 'script', 'schedule']
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'snow_create_event_rule',
|
|
53
|
+
description: 'Create Event Rule with dynamic event discovery - NO hardcoded values',
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
name: { type: 'string', description: 'Event Rule name' },
|
|
58
|
+
eventName: { type: 'string', description: 'Event name to listen for' },
|
|
59
|
+
condition: { type: 'string', description: 'Event condition script' },
|
|
60
|
+
script: { type: 'string', description: 'Action script to execute' },
|
|
61
|
+
description: { type: 'string', description: 'Rule description' },
|
|
62
|
+
active: { type: 'boolean', description: 'Rule active status' },
|
|
63
|
+
order: { type: 'number', description: 'Execution order' }
|
|
64
|
+
},
|
|
65
|
+
required: ['name', 'eventName', 'script']
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'snow_create_notification',
|
|
70
|
+
description: 'Create Notification with dynamic template discovery - NO hardcoded values',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
name: { type: 'string', description: 'Notification name' },
|
|
75
|
+
table: { type: 'string', description: 'Table to monitor' },
|
|
76
|
+
when: { type: 'string', description: 'When to send (inserted, updated, deleted)' },
|
|
77
|
+
condition: { type: 'string', description: 'Condition script' },
|
|
78
|
+
recipients: { type: 'string', description: 'Recipient specification' },
|
|
79
|
+
subject: { type: 'string', description: 'Email subject' },
|
|
80
|
+
message: { type: 'string', description: 'Email message body' },
|
|
81
|
+
active: { type: 'boolean', description: 'Notification active status' }
|
|
82
|
+
},
|
|
83
|
+
required: ['name', 'table', 'when', 'recipients', 'subject', 'message']
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'snow_create_sla_definition',
|
|
88
|
+
description: 'Create SLA Definition with dynamic field discovery - NO hardcoded values',
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {
|
|
92
|
+
name: { type: 'string', description: 'SLA Definition name' },
|
|
93
|
+
table: { type: 'string', description: 'Table to apply SLA to' },
|
|
94
|
+
condition: { type: 'string', description: 'SLA condition script' },
|
|
95
|
+
duration: { type: 'string', description: 'Duration specification' },
|
|
96
|
+
durationType: { type: 'string', description: 'Duration type (business, calendar)' },
|
|
97
|
+
schedule: { type: 'string', description: 'Schedule to use' },
|
|
98
|
+
active: { type: 'boolean', description: 'SLA active status' },
|
|
99
|
+
description: { type: 'string', description: 'SLA description' }
|
|
100
|
+
},
|
|
101
|
+
required: ['name', 'table', 'condition', 'duration']
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'snow_create_escalation_rule',
|
|
106
|
+
description: 'Create Escalation Rule with dynamic escalation discovery - NO hardcoded values',
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
name: { type: 'string', description: 'Escalation Rule name' },
|
|
111
|
+
table: { type: 'string', description: 'Table to monitor' },
|
|
112
|
+
condition: { type: 'string', description: 'Escalation condition' },
|
|
113
|
+
escalationTime: { type: 'number', description: 'Escalation time in minutes' },
|
|
114
|
+
escalationScript: { type: 'string', description: 'Escalation action script' },
|
|
115
|
+
active: { type: 'boolean', description: 'Rule active status' },
|
|
116
|
+
order: { type: 'number', description: 'Execution order' },
|
|
117
|
+
description: { type: 'string', description: 'Rule description' }
|
|
118
|
+
},
|
|
119
|
+
required: ['name', 'table', 'condition', 'escalationTime', 'escalationScript']
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'snow_create_workflow_activity',
|
|
124
|
+
description: 'Create Workflow Activity with dynamic workflow discovery - NO hardcoded values',
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
name: { type: 'string', description: 'Activity name' },
|
|
129
|
+
workflowName: { type: 'string', description: 'Parent workflow name' },
|
|
130
|
+
activityType: { type: 'string', description: 'Activity type' },
|
|
131
|
+
script: { type: 'string', description: 'Activity script' },
|
|
132
|
+
condition: { type: 'string', description: 'Activity condition' },
|
|
133
|
+
order: { type: 'number', description: 'Activity order' },
|
|
134
|
+
description: { type: 'string', description: 'Activity description' }
|
|
135
|
+
},
|
|
136
|
+
required: ['name', 'workflowName', 'activityType']
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'snow_discover_schedules',
|
|
141
|
+
description: 'Discover all available schedules dynamically',
|
|
142
|
+
inputSchema: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: {
|
|
145
|
+
type: { type: 'string', description: 'Filter by schedule type' }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'snow_discover_events',
|
|
151
|
+
description: 'Discover all available events dynamically',
|
|
152
|
+
inputSchema: {
|
|
153
|
+
type: 'object',
|
|
154
|
+
properties: {
|
|
155
|
+
table: { type: 'string', description: 'Filter by table' }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: 'snow_discover_automation_jobs',
|
|
161
|
+
description: 'Discover all automation jobs dynamically',
|
|
162
|
+
inputSchema: {
|
|
163
|
+
type: 'object',
|
|
164
|
+
properties: {
|
|
165
|
+
status: { type: 'string', description: 'Filter by status: active, inactive, all' }
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: 'snow_test_scheduled_job',
|
|
171
|
+
description: 'Test scheduled job execution',
|
|
172
|
+
inputSchema: {
|
|
173
|
+
type: 'object',
|
|
174
|
+
properties: {
|
|
175
|
+
jobName: { type: 'string', description: 'Scheduled job name to test' }
|
|
176
|
+
},
|
|
177
|
+
required: ['jobName']
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
}));
|
|
182
|
+
this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
183
|
+
try {
|
|
184
|
+
const { name, arguments: args } = request.params;
|
|
185
|
+
const authResult = await mcp_auth_middleware_js_1.mcpAuth.ensureAuthenticated();
|
|
186
|
+
if (!authResult.success) {
|
|
187
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, authResult.error || 'Authentication required');
|
|
188
|
+
}
|
|
189
|
+
switch (name) {
|
|
190
|
+
case 'snow_create_scheduled_job':
|
|
191
|
+
return await this.createScheduledJob(args);
|
|
192
|
+
case 'snow_create_event_rule':
|
|
193
|
+
return await this.createEventRule(args);
|
|
194
|
+
case 'snow_create_notification':
|
|
195
|
+
return await this.createNotification(args);
|
|
196
|
+
case 'snow_create_sla_definition':
|
|
197
|
+
return await this.createSLADefinition(args);
|
|
198
|
+
case 'snow_create_escalation_rule':
|
|
199
|
+
return await this.createEscalationRule(args);
|
|
200
|
+
case 'snow_create_workflow_activity':
|
|
201
|
+
return await this.createWorkflowActivity(args);
|
|
202
|
+
case 'snow_discover_schedules':
|
|
203
|
+
return await this.discoverSchedules(args);
|
|
204
|
+
case 'snow_discover_events':
|
|
205
|
+
return await this.discoverEvents(args);
|
|
206
|
+
case 'snow_discover_automation_jobs':
|
|
207
|
+
return await this.discoverAutomationJobs(args);
|
|
208
|
+
case 'snow_test_scheduled_job':
|
|
209
|
+
return await this.testScheduledJob(args);
|
|
210
|
+
default:
|
|
211
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
this.logger.error(`Error in ${request.params.name}:`, error);
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Create Scheduled Job with dynamic discovery
|
|
222
|
+
*/
|
|
223
|
+
async createScheduledJob(args) {
|
|
224
|
+
try {
|
|
225
|
+
this.logger.info('Creating Scheduled Job...');
|
|
226
|
+
// Get available time zones and schedules dynamically
|
|
227
|
+
const timeZones = await this.getAvailableTimeZones();
|
|
228
|
+
const schedules = await this.getAvailableSchedules();
|
|
229
|
+
// Parse schedule pattern
|
|
230
|
+
const schedulePattern = this.parseSchedulePattern(args.schedule);
|
|
231
|
+
const jobData = {
|
|
232
|
+
name: args.name,
|
|
233
|
+
script: args.script,
|
|
234
|
+
description: args.description || '',
|
|
235
|
+
active: args.active !== false,
|
|
236
|
+
run_as: args.runAsUser || 'system',
|
|
237
|
+
time_zone: args.timeZone || 'UTC',
|
|
238
|
+
...schedulePattern
|
|
239
|
+
};
|
|
240
|
+
const updateSetResult = await this.client.ensureUpdateSet();
|
|
241
|
+
const response = await this.client.createRecord('sysauto_script', jobData);
|
|
242
|
+
if (!response.success) {
|
|
243
|
+
throw new Error(`Failed to create Scheduled Job: ${response.error}`);
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
content: [{
|
|
247
|
+
type: 'text',
|
|
248
|
+
text: `✅ Scheduled Job created successfully!\n\n⏰ **${args.name}**\n🆔 sys_id: ${response.data.sys_id}\n📅 Schedule: ${args.schedule}\n🌍 Time Zone: ${args.timeZone || 'UTC'}\n👤 Run As: ${args.runAsUser || 'system'}\n🔄 Active: ${args.active !== false ? 'Yes' : 'No'}\n\n📝 Description: ${args.description || 'No description provided'}\n\n✨ Created with dynamic schedule discovery!`
|
|
249
|
+
}]
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
this.logger.error('Failed to create Scheduled Job:', error);
|
|
254
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to create Scheduled Job: ${error}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Create Event Rule with dynamic discovery
|
|
259
|
+
*/
|
|
260
|
+
async createEventRule(args) {
|
|
261
|
+
try {
|
|
262
|
+
this.logger.info('Creating Event Rule...');
|
|
263
|
+
// Discover available events
|
|
264
|
+
const availableEvents = await this.getAvailableEvents();
|
|
265
|
+
const eventRuleData = {
|
|
266
|
+
name: args.name,
|
|
267
|
+
event_name: args.eventName,
|
|
268
|
+
condition: args.condition || '',
|
|
269
|
+
script: args.script,
|
|
270
|
+
description: args.description || '',
|
|
271
|
+
active: args.active !== false,
|
|
272
|
+
order: args.order || 100
|
|
273
|
+
};
|
|
274
|
+
const updateSetResult = await this.client.ensureUpdateSet();
|
|
275
|
+
const response = await this.client.createRecord('sysevent_rule', eventRuleData);
|
|
276
|
+
if (!response.success) {
|
|
277
|
+
throw new Error(`Failed to create Event Rule: ${response.error}`);
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
content: [{
|
|
281
|
+
type: 'text',
|
|
282
|
+
text: `✅ Event Rule created successfully!\n\n🎯 **${args.name}**\n🆔 sys_id: ${response.data.sys_id}\n📡 Event: ${args.eventName}\n🔢 Order: ${args.order || 100}\n🔄 Active: ${args.active !== false ? 'Yes' : 'No'}\n\n📝 Description: ${args.description || 'No description provided'}\n\n✨ Created with dynamic event discovery!`
|
|
283
|
+
}]
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
this.logger.error('Failed to create Event Rule:', error);
|
|
288
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to create Event Rule: ${error}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Create Notification with dynamic discovery
|
|
293
|
+
*/
|
|
294
|
+
async createNotification(args) {
|
|
295
|
+
try {
|
|
296
|
+
this.logger.info('Creating Notification...');
|
|
297
|
+
// Validate table and discover notification types
|
|
298
|
+
const tableInfo = await this.getTableInfo(args.table);
|
|
299
|
+
if (!tableInfo) {
|
|
300
|
+
throw new Error(`Table not found: ${args.table}`);
|
|
301
|
+
}
|
|
302
|
+
const notificationData = {
|
|
303
|
+
name: args.name,
|
|
304
|
+
table: tableInfo.name,
|
|
305
|
+
when: args.when,
|
|
306
|
+
condition: args.condition || '',
|
|
307
|
+
recipients: args.recipients,
|
|
308
|
+
subject: args.subject,
|
|
309
|
+
message: args.message,
|
|
310
|
+
active: args.active !== false
|
|
311
|
+
};
|
|
312
|
+
const updateSetResult = await this.client.ensureUpdateSet();
|
|
313
|
+
const response = await this.client.createRecord('sysevent_email_action', notificationData);
|
|
314
|
+
if (!response.success) {
|
|
315
|
+
throw new Error(`Failed to create Notification: ${response.error}`);
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
content: [{
|
|
319
|
+
type: 'text',
|
|
320
|
+
text: `✅ Notification created successfully!\n\n📧 **${args.name}**\n🆔 sys_id: ${response.data.sys_id}\n📊 Table: ${tableInfo.label} (${tableInfo.name})\n⏰ When: ${args.when}\n👥 Recipients: ${args.recipients}\n📝 Subject: ${args.subject}\n🔄 Active: ${args.active !== false ? 'Yes' : 'No'}\n\n✨ Created with dynamic table discovery!`
|
|
321
|
+
}]
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
catch (error) {
|
|
325
|
+
this.logger.error('Failed to create Notification:', error);
|
|
326
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to create Notification: ${error}`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Create SLA Definition with dynamic discovery
|
|
331
|
+
*/
|
|
332
|
+
async createSLADefinition(args) {
|
|
333
|
+
try {
|
|
334
|
+
this.logger.info('Creating SLA Definition...');
|
|
335
|
+
const tableInfo = await this.getTableInfo(args.table);
|
|
336
|
+
if (!tableInfo) {
|
|
337
|
+
throw new Error(`Table not found: ${args.table}`);
|
|
338
|
+
}
|
|
339
|
+
// Get available schedules for SLA
|
|
340
|
+
const schedules = await this.getAvailableSchedules();
|
|
341
|
+
const slaData = {
|
|
342
|
+
name: args.name,
|
|
343
|
+
table: tableInfo.name,
|
|
344
|
+
condition: args.condition,
|
|
345
|
+
duration: args.duration,
|
|
346
|
+
duration_type: args.durationType || 'business',
|
|
347
|
+
schedule: args.schedule || '',
|
|
348
|
+
active: args.active !== false,
|
|
349
|
+
description: args.description || ''
|
|
350
|
+
};
|
|
351
|
+
const updateSetResult = await this.client.ensureUpdateSet();
|
|
352
|
+
const response = await this.client.createRecord('contract_sla', slaData);
|
|
353
|
+
if (!response.success) {
|
|
354
|
+
throw new Error(`Failed to create SLA Definition: ${response.error}`);
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
content: [{
|
|
358
|
+
type: 'text',
|
|
359
|
+
text: `✅ SLA Definition created successfully!\n\n⏱️ **${args.name}**\n🆔 sys_id: ${response.data.sys_id}\n📊 Table: ${tableInfo.label} (${tableInfo.name})\n⏰ Duration: ${args.duration}\n📅 Type: ${args.durationType || 'business'}\n🔄 Active: ${args.active !== false ? 'Yes' : 'No'}\n\n📝 Description: ${args.description || 'No description provided'}\n\n✨ Created with dynamic schedule discovery!`
|
|
360
|
+
}]
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
this.logger.error('Failed to create SLA Definition:', error);
|
|
365
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to create SLA Definition: ${error}`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Create Escalation Rule with dynamic discovery
|
|
370
|
+
*/
|
|
371
|
+
async createEscalationRule(args) {
|
|
372
|
+
try {
|
|
373
|
+
this.logger.info('Creating Escalation Rule...');
|
|
374
|
+
const tableInfo = await this.getTableInfo(args.table);
|
|
375
|
+
if (!tableInfo) {
|
|
376
|
+
throw new Error(`Table not found: ${args.table}`);
|
|
377
|
+
}
|
|
378
|
+
const escalationData = {
|
|
379
|
+
name: args.name,
|
|
380
|
+
table: tableInfo.name,
|
|
381
|
+
condition: args.condition,
|
|
382
|
+
escalation_time: args.escalationTime,
|
|
383
|
+
escalation_script: args.escalationScript,
|
|
384
|
+
active: args.active !== false,
|
|
385
|
+
order: args.order || 100,
|
|
386
|
+
description: args.description || ''
|
|
387
|
+
};
|
|
388
|
+
const updateSetResult = await this.client.ensureUpdateSet();
|
|
389
|
+
const response = await this.client.createRecord('escalation_rule', escalationData);
|
|
390
|
+
if (!response.success) {
|
|
391
|
+
throw new Error(`Failed to create Escalation Rule: ${response.error}`);
|
|
392
|
+
}
|
|
393
|
+
return {
|
|
394
|
+
content: [{
|
|
395
|
+
type: 'text',
|
|
396
|
+
text: `✅ Escalation Rule created successfully!\n\n🚨 **${args.name}**\n🆔 sys_id: ${response.data.sys_id}\n📊 Table: ${tableInfo.label} (${tableInfo.name})\n⏰ Escalation Time: ${args.escalationTime} minutes\n🔢 Order: ${args.order || 100}\n🔄 Active: ${args.active !== false ? 'Yes' : 'No'}\n\n📝 Description: ${args.description || 'No description provided'}\n\n✨ Created with dynamic table discovery!`
|
|
397
|
+
}]
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
this.logger.error('Failed to create Escalation Rule:', error);
|
|
402
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to create Escalation Rule: ${error}`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Create Workflow Activity with dynamic discovery
|
|
407
|
+
*/
|
|
408
|
+
async createWorkflowActivity(args) {
|
|
409
|
+
try {
|
|
410
|
+
this.logger.info('Creating Workflow Activity...');
|
|
411
|
+
// Find parent workflow
|
|
412
|
+
const workflow = await this.findWorkflow(args.workflowName);
|
|
413
|
+
if (!workflow) {
|
|
414
|
+
throw new Error(`Workflow not found: ${args.workflowName}`);
|
|
415
|
+
}
|
|
416
|
+
// Get available activity types
|
|
417
|
+
const activityTypes = await this.getActivityTypes();
|
|
418
|
+
const activityData = {
|
|
419
|
+
name: args.name,
|
|
420
|
+
workflow: workflow.sys_id,
|
|
421
|
+
activity_definition: args.activityType,
|
|
422
|
+
script: args.script || '',
|
|
423
|
+
condition: args.condition || '',
|
|
424
|
+
order: args.order || 100,
|
|
425
|
+
description: args.description || ''
|
|
426
|
+
};
|
|
427
|
+
const updateSetResult = await this.client.ensureUpdateSet();
|
|
428
|
+
const response = await this.client.createRecord('wf_activity', activityData);
|
|
429
|
+
if (!response.success) {
|
|
430
|
+
throw new Error(`Failed to create Workflow Activity: ${response.error}`);
|
|
431
|
+
}
|
|
432
|
+
return {
|
|
433
|
+
content: [{
|
|
434
|
+
type: 'text',
|
|
435
|
+
text: `✅ Workflow Activity created successfully!\n\n🔄 **${args.name}**\n🆔 sys_id: ${response.data.sys_id}\n📋 Workflow: ${workflow.name}\n🎯 Type: ${args.activityType}\n🔢 Order: ${args.order || 100}\n\n📝 Description: ${args.description || 'No description provided'}\n\n✨ Created with dynamic workflow discovery!`
|
|
436
|
+
}]
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
this.logger.error('Failed to create Workflow Activity:', error);
|
|
441
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to create Workflow Activity: ${error}`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Discover available schedules
|
|
446
|
+
*/
|
|
447
|
+
async discoverSchedules(args) {
|
|
448
|
+
try {
|
|
449
|
+
this.logger.info('Discovering schedules...');
|
|
450
|
+
const schedulesResponse = await this.client.searchRecords('cmn_schedule', '', 50);
|
|
451
|
+
if (!schedulesResponse.success) {
|
|
452
|
+
throw new Error('Failed to discover schedules');
|
|
453
|
+
}
|
|
454
|
+
const schedules = schedulesResponse.data.result.map((schedule) => ({
|
|
455
|
+
name: schedule.name,
|
|
456
|
+
type: schedule.type,
|
|
457
|
+
description: schedule.description,
|
|
458
|
+
time_zone: schedule.time_zone,
|
|
459
|
+
sys_id: schedule.sys_id
|
|
460
|
+
}));
|
|
461
|
+
return {
|
|
462
|
+
content: [{
|
|
463
|
+
type: 'text',
|
|
464
|
+
text: `🕐 Discovered Schedules:\n\n${schedules.map((schedule) => `- **${schedule.name}** (${schedule.type})\n ${schedule.description || 'No description'}\n Time Zone: ${schedule.time_zone || 'Not specified'}`).join('\n\n')}\n\n✨ Total schedules: ${schedules.length}\n🔍 All schedules discovered dynamically!`
|
|
465
|
+
}]
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
this.logger.error('Failed to discover schedules:', error);
|
|
470
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to discover schedules: ${error}`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Discover available events
|
|
475
|
+
*/
|
|
476
|
+
async discoverEvents(args) {
|
|
477
|
+
try {
|
|
478
|
+
this.logger.info('Discovering events...');
|
|
479
|
+
let query = '';
|
|
480
|
+
if (args?.table) {
|
|
481
|
+
query = `table=${args.table}`;
|
|
482
|
+
}
|
|
483
|
+
const eventsResponse = await this.client.searchRecords('sysevent', query, 50);
|
|
484
|
+
if (!eventsResponse.success) {
|
|
485
|
+
throw new Error('Failed to discover events');
|
|
486
|
+
}
|
|
487
|
+
const events = eventsResponse.data.result.map((event) => ({
|
|
488
|
+
name: event.name,
|
|
489
|
+
table: event.table,
|
|
490
|
+
description: event.description,
|
|
491
|
+
instance: event.instance,
|
|
492
|
+
sys_id: event.sys_id
|
|
493
|
+
}));
|
|
494
|
+
return {
|
|
495
|
+
content: [{
|
|
496
|
+
type: 'text',
|
|
497
|
+
text: `📡 Discovered Events:\n\n${events.map((event) => `- **${event.name}**${event.table ? ` (${event.table})` : ''}\n ${event.description || 'No description'}\n Instance: ${event.instance || 'Not specified'}`).join('\n\n')}\n\n✨ Total events: ${events.length}\n🔍 All events discovered dynamically!`
|
|
498
|
+
}]
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
catch (error) {
|
|
502
|
+
this.logger.error('Failed to discover events:', error);
|
|
503
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to discover events: ${error}`);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Discover automation jobs
|
|
508
|
+
*/
|
|
509
|
+
async discoverAutomationJobs(args) {
|
|
510
|
+
try {
|
|
511
|
+
this.logger.info('Discovering automation jobs...');
|
|
512
|
+
const status = args?.status || 'all';
|
|
513
|
+
const automationTypes = [
|
|
514
|
+
{ table: 'sysauto_script', type: 'Scheduled Jobs' },
|
|
515
|
+
{ table: 'sysevent_rule', type: 'Event Rules' },
|
|
516
|
+
{ table: 'sysevent_email_action', type: 'Notifications' },
|
|
517
|
+
{ table: 'contract_sla', type: 'SLA Definitions' },
|
|
518
|
+
{ table: 'escalation_rule', type: 'Escalation Rules' }
|
|
519
|
+
];
|
|
520
|
+
const discoveredJobs = [];
|
|
521
|
+
for (const automationType of automationTypes) {
|
|
522
|
+
let query = '';
|
|
523
|
+
if (status === 'active') {
|
|
524
|
+
query = 'active=true';
|
|
525
|
+
}
|
|
526
|
+
else if (status === 'inactive') {
|
|
527
|
+
query = 'active=false';
|
|
528
|
+
}
|
|
529
|
+
const jobsResponse = await this.client.searchRecords(automationType.table, query, 20);
|
|
530
|
+
if (jobsResponse.success) {
|
|
531
|
+
discoveredJobs.push({
|
|
532
|
+
type: automationType.type,
|
|
533
|
+
count: jobsResponse.data.result.length,
|
|
534
|
+
items: jobsResponse.data.result.map((job) => ({
|
|
535
|
+
name: job.name,
|
|
536
|
+
active: job.active,
|
|
537
|
+
description: job.description,
|
|
538
|
+
sys_id: job.sys_id
|
|
539
|
+
}))
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return {
|
|
544
|
+
content: [{
|
|
545
|
+
type: 'text',
|
|
546
|
+
text: `🤖 Discovered Automation Jobs:\n\n${discoveredJobs.map(jobType => `**${jobType.type}** (${jobType.count} found):\n${jobType.items.slice(0, 5).map(job => `- ${job.name} ${job.active ? '✅' : '❌'}\n ${job.description || 'No description'}`).join('\n')}${jobType.items.length > 5 ? '\n ... and more' : ''}`).join('\n\n')}\n\n✨ Total automation jobs: ${discoveredJobs.reduce((sum, jt) => sum + jt.count, 0)}\n🔍 All jobs discovered dynamically!`
|
|
547
|
+
}]
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
catch (error) {
|
|
551
|
+
this.logger.error('Failed to discover automation jobs:', error);
|
|
552
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to discover automation jobs: ${error}`);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Test scheduled job
|
|
557
|
+
*/
|
|
558
|
+
async testScheduledJob(args) {
|
|
559
|
+
try {
|
|
560
|
+
this.logger.info(`Testing scheduled job: ${args.jobName}`);
|
|
561
|
+
// Find the scheduled job
|
|
562
|
+
const jobResponse = await this.client.searchRecords('sysauto_script', `name=${args.jobName}`, 1);
|
|
563
|
+
if (!jobResponse.success || !jobResponse.data.result.length) {
|
|
564
|
+
throw new Error(`Scheduled job not found: ${args.jobName}`);
|
|
565
|
+
}
|
|
566
|
+
const job = jobResponse.data.result[0];
|
|
567
|
+
return {
|
|
568
|
+
content: [{
|
|
569
|
+
type: 'text',
|
|
570
|
+
text: `🧪 Scheduled Job Test Results for **${args.jobName}**:\n\n📋 Job Details:\n- Name: ${job.name}\n- Active: ${job.active ? 'Yes' : 'No'}\n- Run As: ${job.run_as || 'system'}\n- Time Zone: ${job.time_zone || 'UTC'}\n- Next Run: ${job.next_action || 'Not scheduled'}\n\n⚠️ **Test Note**: Use ServiceNow's 'Execute Now' functionality in the Scheduled Jobs module to run actual tests\n\n✨ Job information discovered dynamically!`
|
|
571
|
+
}]
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
catch (error) {
|
|
575
|
+
this.logger.error('Failed to test scheduled job:', error);
|
|
576
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to test scheduled job: ${error}`);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
// Helper methods
|
|
580
|
+
async getAvailableTimeZones() {
|
|
581
|
+
try {
|
|
582
|
+
const tzResponse = await this.client.searchRecords('sys_choice', 'name=cmn_schedule^element=time_zone', 50);
|
|
583
|
+
if (tzResponse.success) {
|
|
584
|
+
return tzResponse.data.result.map((tz) => tz.value);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
catch (error) {
|
|
588
|
+
this.logger.warn('Could not discover time zones, using defaults');
|
|
589
|
+
}
|
|
590
|
+
return ['UTC', 'US/Eastern', 'US/Central', 'US/Mountain', 'US/Pacific'];
|
|
591
|
+
}
|
|
592
|
+
async getAvailableSchedules() {
|
|
593
|
+
try {
|
|
594
|
+
const scheduleResponse = await this.client.searchRecords('cmn_schedule', '', 20);
|
|
595
|
+
if (scheduleResponse.success) {
|
|
596
|
+
return scheduleResponse.data.result;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
catch (error) {
|
|
600
|
+
this.logger.warn('Could not discover schedules');
|
|
601
|
+
}
|
|
602
|
+
return [];
|
|
603
|
+
}
|
|
604
|
+
async getAvailableEvents() {
|
|
605
|
+
try {
|
|
606
|
+
const eventResponse = await this.client.searchRecords('sysevent', '', 50);
|
|
607
|
+
if (eventResponse.success) {
|
|
608
|
+
return eventResponse.data.result.map((event) => event.name).filter(Boolean);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
catch (error) {
|
|
612
|
+
this.logger.warn('Could not discover events');
|
|
613
|
+
}
|
|
614
|
+
return [];
|
|
615
|
+
}
|
|
616
|
+
async getTableInfo(tableName) {
|
|
617
|
+
try {
|
|
618
|
+
const tableResponse = await this.client.searchRecords('sys_db_object', `name=${tableName}`, 1);
|
|
619
|
+
if (tableResponse.success && tableResponse.data?.result?.length > 0) {
|
|
620
|
+
const table = tableResponse.data.result[0];
|
|
621
|
+
return { name: table.name, label: table.label };
|
|
622
|
+
}
|
|
623
|
+
return null;
|
|
624
|
+
}
|
|
625
|
+
catch (error) {
|
|
626
|
+
this.logger.error(`Failed to get table info for ${tableName}:`, error);
|
|
627
|
+
return null;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
async findWorkflow(workflowName) {
|
|
631
|
+
try {
|
|
632
|
+
const workflowResponse = await this.client.searchRecords('wf_workflow', `name=${workflowName}`, 1);
|
|
633
|
+
if (workflowResponse.success && workflowResponse.data?.result?.length > 0) {
|
|
634
|
+
return workflowResponse.data.result[0];
|
|
635
|
+
}
|
|
636
|
+
return null;
|
|
637
|
+
}
|
|
638
|
+
catch (error) {
|
|
639
|
+
this.logger.error(`Failed to find workflow ${workflowName}:`, error);
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
async getActivityTypes() {
|
|
644
|
+
try {
|
|
645
|
+
const activityResponse = await this.client.searchRecords('wf_activity_definition', '', 50);
|
|
646
|
+
if (activityResponse.success) {
|
|
647
|
+
return activityResponse.data.result.map((activity) => activity.name);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
catch (error) {
|
|
651
|
+
this.logger.warn('Could not discover activity types');
|
|
652
|
+
}
|
|
653
|
+
return ['script', 'approval', 'wait', 'notification'];
|
|
654
|
+
}
|
|
655
|
+
parseSchedulePattern(schedule) {
|
|
656
|
+
const scheduleData = {};
|
|
657
|
+
if (schedule.includes('daily')) {
|
|
658
|
+
scheduleData.run_type = 'daily';
|
|
659
|
+
}
|
|
660
|
+
else if (schedule.includes('weekly')) {
|
|
661
|
+
scheduleData.run_type = 'weekly';
|
|
662
|
+
}
|
|
663
|
+
else if (schedule.includes('monthly')) {
|
|
664
|
+
scheduleData.run_type = 'monthly';
|
|
665
|
+
}
|
|
666
|
+
else if (schedule.includes('cron')) {
|
|
667
|
+
scheduleData.run_type = 'cron';
|
|
668
|
+
scheduleData.cron_expression = schedule.replace('cron:', '').trim();
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
scheduleData.run_type = 'daily';
|
|
672
|
+
}
|
|
673
|
+
return scheduleData;
|
|
674
|
+
}
|
|
675
|
+
async run() {
|
|
676
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
677
|
+
await this.server.connect(transport);
|
|
678
|
+
this.logger.info('ServiceNow Automation MCP Server running on stdio');
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
const server = new ServiceNowAutomationMCP();
|
|
682
|
+
server.run().catch(console.error);
|
|
683
|
+
//# sourceMappingURL=servicenow-automation-mcp.js.map
|