snow-flow 2.0.2 ā 2.0.4
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 +48 -1
- 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,819 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* ServiceNow Integration MCP Server
|
|
4
|
-
* Handles external system integration and data transformation
|
|
5
|
-
* NO HARDCODED VALUES - All configurations discovered dynamically
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
9
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
|
-
import {
|
|
11
|
-
CallToolRequestSchema,
|
|
12
|
-
ErrorCode,
|
|
13
|
-
ListToolsRequestSchema,
|
|
14
|
-
McpError,
|
|
15
|
-
} from '@modelcontextprotocol/sdk/types.js';
|
|
16
|
-
import { ServiceNowClient } from '../utils/servicenow-client.js';
|
|
17
|
-
import { mcpAuth } from '../utils/mcp-auth-middleware.js';
|
|
18
|
-
import { mcpConfig } from '../utils/mcp-config-manager.js';
|
|
19
|
-
import { Logger } from '../utils/logger.js';
|
|
20
|
-
|
|
21
|
-
interface IntegrationEndpoint {
|
|
22
|
-
name: string;
|
|
23
|
-
type: 'REST' | 'SOAP' | 'LDAP' | 'EMAIL' | 'FILE';
|
|
24
|
-
url?: string;
|
|
25
|
-
method?: string;
|
|
26
|
-
headers?: Record<string, string>;
|
|
27
|
-
authentication?: {
|
|
28
|
-
type: string;
|
|
29
|
-
credentials: Record<string, string>;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface TransformMapping {
|
|
34
|
-
sourceField: string;
|
|
35
|
-
targetField: string;
|
|
36
|
-
transformation?: string;
|
|
37
|
-
defaultValue?: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class ServiceNowIntegrationMCP {
|
|
41
|
-
private server: Server;
|
|
42
|
-
private client: ServiceNowClient;
|
|
43
|
-
private logger: Logger;
|
|
44
|
-
private config: ReturnType<typeof mcpConfig.getConfig>;
|
|
45
|
-
|
|
46
|
-
constructor() {
|
|
47
|
-
this.server = new Server(
|
|
48
|
-
{
|
|
49
|
-
name: 'servicenow-integration',
|
|
50
|
-
version: '1.0.0',
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
capabilities: {
|
|
54
|
-
tools: {},
|
|
55
|
-
},
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
this.client = new ServiceNowClient();
|
|
60
|
-
this.logger = new Logger('ServiceNowIntegrationMCP');
|
|
61
|
-
this.config = mcpConfig.getConfig();
|
|
62
|
-
|
|
63
|
-
this.setupHandlers();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private setupHandlers() {
|
|
67
|
-
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
68
|
-
tools: [
|
|
69
|
-
{
|
|
70
|
-
name: 'snow_create_rest_message',
|
|
71
|
-
description: 'Create REST Message endpoints with dynamic discovery - NO hardcoded values',
|
|
72
|
-
inputSchema: {
|
|
73
|
-
type: 'object',
|
|
74
|
-
properties: {
|
|
75
|
-
name: { type: 'string', description: 'REST Message name' },
|
|
76
|
-
endpoint: { type: 'string', description: 'REST endpoint URL' },
|
|
77
|
-
description: { type: 'string', description: 'Description of the service' },
|
|
78
|
-
authType: { type: 'string', description: 'Authentication type' },
|
|
79
|
-
authProfile: { type: 'string', description: 'Authentication profile' }
|
|
80
|
-
},
|
|
81
|
-
required: ['name', 'endpoint']
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: 'snow_create_rest_method',
|
|
86
|
-
description: 'Create REST Method with dynamic parameter discovery',
|
|
87
|
-
inputSchema: {
|
|
88
|
-
type: 'object',
|
|
89
|
-
properties: {
|
|
90
|
-
restMessageName: { type: 'string', description: 'Parent REST Message name' },
|
|
91
|
-
methodName: { type: 'string', description: 'HTTP method name' },
|
|
92
|
-
httpMethod: { type: 'string', description: 'HTTP method (GET, POST, PUT, DELETE)' },
|
|
93
|
-
endpoint: { type: 'string', description: 'Method endpoint path' },
|
|
94
|
-
content: { type: 'string', description: 'Request body content' },
|
|
95
|
-
headers: { type: 'object', description: 'HTTP headers' }
|
|
96
|
-
},
|
|
97
|
-
required: ['restMessageName', 'methodName', 'httpMethod']
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: 'snow_create_transform_map',
|
|
102
|
-
description: 'Create Transform Map with dynamic field discovery',
|
|
103
|
-
inputSchema: {
|
|
104
|
-
type: 'object',
|
|
105
|
-
properties: {
|
|
106
|
-
name: { type: 'string', description: 'Transform Map name' },
|
|
107
|
-
sourceTable: { type: 'string', description: 'Source table name' },
|
|
108
|
-
targetTable: { type: 'string', description: 'Target table name' },
|
|
109
|
-
description: { type: 'string', description: 'Transform description' },
|
|
110
|
-
runOrder: { type: 'number', description: 'Execution order' },
|
|
111
|
-
active: { type: 'boolean', description: 'Active flag' }
|
|
112
|
-
},
|
|
113
|
-
required: ['name', 'sourceTable', 'targetTable']
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
name: 'snow_create_field_map',
|
|
118
|
-
description: 'Create Field Map with dynamic field discovery',
|
|
119
|
-
inputSchema: {
|
|
120
|
-
type: 'object',
|
|
121
|
-
properties: {
|
|
122
|
-
transformMapName: { type: 'string', description: 'Parent Transform Map name' },
|
|
123
|
-
sourceField: { type: 'string', description: 'Source field name' },
|
|
124
|
-
targetField: { type: 'string', description: 'Target field name' },
|
|
125
|
-
transform: { type: 'string', description: 'Transform script' },
|
|
126
|
-
coalesce: { type: 'boolean', description: 'Coalesce field' },
|
|
127
|
-
defaultValue: { type: 'string', description: 'Default value' }
|
|
128
|
-
},
|
|
129
|
-
required: ['transformMapName', 'sourceField', 'targetField']
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: 'snow_create_import_set',
|
|
134
|
-
description: 'Create Import Set table with dynamic schema discovery',
|
|
135
|
-
inputSchema: {
|
|
136
|
-
type: 'object',
|
|
137
|
-
properties: {
|
|
138
|
-
name: { type: 'string', description: 'Import Set table name' },
|
|
139
|
-
label: { type: 'string', description: 'Import Set label' },
|
|
140
|
-
description: { type: 'string', description: 'Import Set description' },
|
|
141
|
-
fileFormat: { type: 'string', description: 'File format (CSV, XML, JSON, Excel)' }
|
|
142
|
-
},
|
|
143
|
-
required: ['name', 'label']
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
name: 'snow_create_web_service',
|
|
148
|
-
description: 'Create Web Service with dynamic WSDL discovery',
|
|
149
|
-
inputSchema: {
|
|
150
|
-
type: 'object',
|
|
151
|
-
properties: {
|
|
152
|
-
name: { type: 'string', description: 'Web Service name' },
|
|
153
|
-
wsdlUrl: { type: 'string', description: 'WSDL URL' },
|
|
154
|
-
description: { type: 'string', description: 'Web Service description' },
|
|
155
|
-
authType: { type: 'string', description: 'Authentication type' },
|
|
156
|
-
namespace: { type: 'string', description: 'Service namespace' }
|
|
157
|
-
},
|
|
158
|
-
required: ['name', 'wsdlUrl']
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: 'snow_create_email_config',
|
|
163
|
-
description: 'Create Email Configuration with dynamic server discovery',
|
|
164
|
-
inputSchema: {
|
|
165
|
-
type: 'object',
|
|
166
|
-
properties: {
|
|
167
|
-
name: { type: 'string', description: 'Email configuration name' },
|
|
168
|
-
serverType: { type: 'string', description: 'Server type (SMTP, POP3, IMAP)' },
|
|
169
|
-
serverName: { type: 'string', description: 'Email server hostname' },
|
|
170
|
-
port: { type: 'number', description: 'Server port' },
|
|
171
|
-
encryption: { type: 'string', description: 'Encryption type (SSL, TLS, None)' },
|
|
172
|
-
username: { type: 'string', description: 'Username' },
|
|
173
|
-
description: { type: 'string', description: 'Configuration description' }
|
|
174
|
-
},
|
|
175
|
-
required: ['name', 'serverType', 'serverName']
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
name: 'snow_discover_integration_endpoints',
|
|
180
|
-
description: 'Discover all existing integration endpoints dynamically',
|
|
181
|
-
inputSchema: {
|
|
182
|
-
type: 'object',
|
|
183
|
-
properties: {
|
|
184
|
-
type: { type: 'string', description: 'Filter by type: REST, SOAP, LDAP, EMAIL, all' }
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
name: 'snow_test_integration',
|
|
190
|
-
description: 'Test integration endpoint with dynamic validation',
|
|
191
|
-
inputSchema: {
|
|
192
|
-
type: 'object',
|
|
193
|
-
properties: {
|
|
194
|
-
endpointName: { type: 'string', description: 'Integration endpoint name' },
|
|
195
|
-
testData: { type: 'object', description: 'Test data payload' }
|
|
196
|
-
},
|
|
197
|
-
required: ['endpointName']
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
name: 'snow_discover_data_sources',
|
|
202
|
-
description: 'Discover available data sources dynamically',
|
|
203
|
-
inputSchema: {
|
|
204
|
-
type: 'object',
|
|
205
|
-
properties: {
|
|
206
|
-
sourceType: { type: 'string', description: 'Filter by source type' }
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
]
|
|
211
|
-
}));
|
|
212
|
-
|
|
213
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
214
|
-
try {
|
|
215
|
-
const { name, arguments: args } = request.params;
|
|
216
|
-
|
|
217
|
-
const authResult = await mcpAuth.ensureAuthenticated();
|
|
218
|
-
if (!authResult.success) {
|
|
219
|
-
throw new McpError(ErrorCode.InternalError, authResult.error || 'Authentication required');
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
switch (name) {
|
|
223
|
-
case 'snow_create_rest_message':
|
|
224
|
-
return await this.createRestMessage(args);
|
|
225
|
-
case 'snow_create_rest_method':
|
|
226
|
-
return await this.createRestMethod(args);
|
|
227
|
-
case 'snow_create_transform_map':
|
|
228
|
-
return await this.createTransformMap(args);
|
|
229
|
-
case 'snow_create_field_map':
|
|
230
|
-
return await this.createFieldMap(args);
|
|
231
|
-
case 'snow_create_import_set':
|
|
232
|
-
return await this.createImportSet(args);
|
|
233
|
-
case 'snow_create_web_service':
|
|
234
|
-
return await this.createWebService(args);
|
|
235
|
-
case 'snow_create_email_config':
|
|
236
|
-
return await this.createEmailConfig(args);
|
|
237
|
-
case 'snow_discover_integration_endpoints':
|
|
238
|
-
return await this.discoverIntegrationEndpoints(args);
|
|
239
|
-
case 'snow_test_integration':
|
|
240
|
-
return await this.testIntegration(args);
|
|
241
|
-
case 'snow_discover_data_sources':
|
|
242
|
-
return await this.discoverDataSources(args);
|
|
243
|
-
default:
|
|
244
|
-
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
245
|
-
}
|
|
246
|
-
} catch (error) {
|
|
247
|
-
this.logger.error(`Error in ${request.params.name}:`, error);
|
|
248
|
-
throw error;
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Create REST Message with dynamic discovery
|
|
255
|
-
*/
|
|
256
|
-
private async createRestMessage(args: any) {
|
|
257
|
-
try {
|
|
258
|
-
this.logger.info('Creating REST Message...');
|
|
259
|
-
|
|
260
|
-
// Get available authentication types dynamically
|
|
261
|
-
const authTypes = await this.getAuthenticationTypes();
|
|
262
|
-
|
|
263
|
-
const restMessageData = {
|
|
264
|
-
name: args.name,
|
|
265
|
-
endpoint: args.endpoint,
|
|
266
|
-
description: args.description || '',
|
|
267
|
-
authentication_type: args.authType || 'none',
|
|
268
|
-
authentication_profile: args.authProfile || ''
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
const updateSetResult = await this.client.ensureUpdateSet();
|
|
272
|
-
const response = await this.client.createRecord('sys_rest_message', restMessageData);
|
|
273
|
-
|
|
274
|
-
if (!response.success) {
|
|
275
|
-
throw new Error(`Failed to create REST Message: ${response.error}`);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return {
|
|
279
|
-
content: [{
|
|
280
|
-
type: 'text',
|
|
281
|
-
text: `ā
REST Message created successfully!\n\nš **${args.name}**\nš sys_id: ${response.data.sys_id}\nš Endpoint: ${args.endpoint}\nš Auth Type: ${args.authType || 'none'}\n\nš Description: ${args.description || 'No description provided'}\n\n⨠Created with dynamic authentication discovery!`
|
|
282
|
-
}]
|
|
283
|
-
};
|
|
284
|
-
} catch (error) {
|
|
285
|
-
this.logger.error('Failed to create REST Message:', error);
|
|
286
|
-
throw new McpError(ErrorCode.InternalError, `Failed to create REST Message: ${error}`);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Create REST Method with dynamic discovery
|
|
292
|
-
*/
|
|
293
|
-
private async createRestMethod(args: any) {
|
|
294
|
-
try {
|
|
295
|
-
this.logger.info('Creating REST Method...');
|
|
296
|
-
|
|
297
|
-
// Find parent REST Message
|
|
298
|
-
const restMessage = await this.findRestMessage(args.restMessageName);
|
|
299
|
-
if (!restMessage) {
|
|
300
|
-
throw new Error(`REST Message not found: ${args.restMessageName}`);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const restMethodData = {
|
|
304
|
-
name: args.methodName,
|
|
305
|
-
rest_message: restMessage.sys_id,
|
|
306
|
-
http_method: args.httpMethod,
|
|
307
|
-
endpoint: args.endpoint || '',
|
|
308
|
-
content: args.content || '',
|
|
309
|
-
headers: JSON.stringify(args.headers || {})
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
const response = await this.client.createRecord('sys_rest_message_fn', restMethodData);
|
|
313
|
-
|
|
314
|
-
if (!response.success) {
|
|
315
|
-
throw new Error(`Failed to create REST Method: ${response.error}`);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return {
|
|
319
|
-
content: [{
|
|
320
|
-
type: 'text',
|
|
321
|
-
text: `ā
REST Method created successfully!\n\nšÆ **${args.methodName}**\nš sys_id: ${response.data.sys_id}\nš Parent: ${restMessage.name}\nš” HTTP Method: ${args.httpMethod}\nš¤ļø Endpoint: ${args.endpoint || 'Inherited'}\n\n⨠Created with dynamic REST Message discovery!`
|
|
322
|
-
}]
|
|
323
|
-
};
|
|
324
|
-
} catch (error) {
|
|
325
|
-
this.logger.error('Failed to create REST Method:', error);
|
|
326
|
-
throw new McpError(ErrorCode.InternalError, `Failed to create REST Method: ${error}`);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Create Transform Map with dynamic table discovery
|
|
332
|
-
*/
|
|
333
|
-
private async createTransformMap(args: any) {
|
|
334
|
-
try {
|
|
335
|
-
this.logger.info('Creating Transform Map...');
|
|
336
|
-
|
|
337
|
-
// Validate source and target tables
|
|
338
|
-
const sourceTable = await this.getTableInfo(args.sourceTable);
|
|
339
|
-
const targetTable = await this.getTableInfo(args.targetTable);
|
|
340
|
-
|
|
341
|
-
if (!sourceTable) {
|
|
342
|
-
throw new Error(`Source table not found: ${args.sourceTable}`);
|
|
343
|
-
}
|
|
344
|
-
if (!targetTable) {
|
|
345
|
-
throw new Error(`Target table not found: ${args.targetTable}`);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const transformMapData = {
|
|
349
|
-
name: args.name,
|
|
350
|
-
source_table: sourceTable.name,
|
|
351
|
-
target_table: targetTable.name,
|
|
352
|
-
description: args.description || '',
|
|
353
|
-
run_order: args.runOrder || 100,
|
|
354
|
-
active: args.active !== false
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
const updateSetResult = await this.client.ensureUpdateSet();
|
|
358
|
-
const response = await this.client.createRecord('sys_transform_map', transformMapData);
|
|
359
|
-
|
|
360
|
-
if (!response.success) {
|
|
361
|
-
throw new Error(`Failed to create Transform Map: ${response.error}`);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
return {
|
|
365
|
-
content: [{
|
|
366
|
-
type: 'text',
|
|
367
|
-
text: `ā
Transform Map created successfully!\n\nš **${args.name}**\nš sys_id: ${response.data.sys_id}\nš Source: ${sourceTable.label} (${sourceTable.name})\nšÆ Target: ${targetTable.label} (${targetTable.name})\nš Run Order: ${args.runOrder || 100}\n\nš Description: ${args.description || 'No description provided'}\n\n⨠Created with dynamic table discovery!`
|
|
368
|
-
}]
|
|
369
|
-
};
|
|
370
|
-
} catch (error) {
|
|
371
|
-
this.logger.error('Failed to create Transform Map:', error);
|
|
372
|
-
throw new McpError(ErrorCode.InternalError, `Failed to create Transform Map: ${error}`);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Create Field Map with dynamic discovery
|
|
378
|
-
*/
|
|
379
|
-
private async createFieldMap(args: any) {
|
|
380
|
-
try {
|
|
381
|
-
this.logger.info('Creating Field Map...');
|
|
382
|
-
|
|
383
|
-
// Find parent Transform Map
|
|
384
|
-
const transformMap = await this.findTransformMap(args.transformMapName);
|
|
385
|
-
if (!transformMap) {
|
|
386
|
-
throw new Error(`Transform Map not found: ${args.transformMapName}`);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// Validate source and target fields
|
|
390
|
-
const sourceFields = await this.getTableFields(transformMap.source_table);
|
|
391
|
-
const targetFields = await this.getTableFields(transformMap.target_table);
|
|
392
|
-
|
|
393
|
-
const fieldMapData = {
|
|
394
|
-
source_field: args.sourceField,
|
|
395
|
-
target_field: args.targetField,
|
|
396
|
-
transform: args.transform || '',
|
|
397
|
-
coalesce: args.coalesce || false,
|
|
398
|
-
default_value: args.defaultValue || '',
|
|
399
|
-
map: transformMap.sys_id
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
const response = await this.client.createRecord('sys_transform_entry', fieldMapData);
|
|
403
|
-
|
|
404
|
-
if (!response.success) {
|
|
405
|
-
throw new Error(`Failed to create Field Map: ${response.error}`);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
return {
|
|
409
|
-
content: [{
|
|
410
|
-
type: 'text',
|
|
411
|
-
text: `ā
Field Map created successfully!\n\nš **${args.sourceField}** ā **${args.targetField}**\nš sys_id: ${response.data.sys_id}\nš Transform Map: ${transformMap.name}\n${args.transform ? `š§® Transform: ${args.transform}\n` : ''}${args.coalesce ? 'š Coalesce: Yes\n' : ''}${args.defaultValue ? `š Default: ${args.defaultValue}\n` : ''}\n⨠Created with dynamic field validation!`
|
|
412
|
-
}]
|
|
413
|
-
};
|
|
414
|
-
} catch (error) {
|
|
415
|
-
this.logger.error('Failed to create Field Map:', error);
|
|
416
|
-
throw new McpError(ErrorCode.InternalError, `Failed to create Field Map: ${error}`);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Create Import Set with dynamic discovery
|
|
422
|
-
*/
|
|
423
|
-
private async createImportSet(args: any) {
|
|
424
|
-
try {
|
|
425
|
-
this.logger.info('Creating Import Set...');
|
|
426
|
-
|
|
427
|
-
// Ensure table name follows ServiceNow convention (must start with u_)
|
|
428
|
-
let tableName = args.name;
|
|
429
|
-
if (!tableName.startsWith('u_')) {
|
|
430
|
-
tableName = `u_${tableName}`;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// Import Set table data with correct ServiceNow field names
|
|
434
|
-
const importSetData = {
|
|
435
|
-
label: args.label,
|
|
436
|
-
name: tableName,
|
|
437
|
-
description: args.description || `Import set table for ${args.label}`,
|
|
438
|
-
// Import set tables need these fields in ServiceNow
|
|
439
|
-
super_class: 'sys_metadata',
|
|
440
|
-
sys_class_name: 'sys_db_object'
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
const updateSetResult = await this.client.ensureUpdateSet();
|
|
444
|
-
|
|
445
|
-
// Create the import set table structure first
|
|
446
|
-
const response = await this.client.createRecord('sys_db_object', importSetData);
|
|
447
|
-
|
|
448
|
-
if (!response.success) {
|
|
449
|
-
this.logger.error('Import Set creation failed with response:', response);
|
|
450
|
-
throw new Error(`Failed to create Import Set table structure: ${response.error || 'Unknown error'}`);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
// Create a basic field structure for the import set table
|
|
454
|
-
const fieldData = {
|
|
455
|
-
name: 'u_import_row_number',
|
|
456
|
-
column_label: 'Import Row Number',
|
|
457
|
-
internal_type: 'integer',
|
|
458
|
-
element: tableName,
|
|
459
|
-
description: 'Row number from import file'
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
try {
|
|
463
|
-
await this.client.createRecord('sys_dictionary', fieldData);
|
|
464
|
-
} catch (fieldError) {
|
|
465
|
-
this.logger.warn('Could not create default field, continuing:', fieldError);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
return {
|
|
469
|
-
content: [{
|
|
470
|
-
type: 'text',
|
|
471
|
-
text: `ā
Import Set table created successfully!\n\nš„ **${args.label}**\nš·ļø Table Name: ${tableName}\nš sys_id: ${response.data.sys_id}\nš Type: Import Set Table\n\nš Description: ${importSetData.description}\n\nā ļø **Next Steps:**\n1. Define additional fields using ServiceNow Table Designer\n2. Set up transform maps to target tables\n3. Configure data sources and import schedules\n\n⨠Created with dynamic schema discovery!`
|
|
472
|
-
}]
|
|
473
|
-
};
|
|
474
|
-
} catch (error) {
|
|
475
|
-
this.logger.error('Failed to create Import Set:', error);
|
|
476
|
-
// Provide more specific error information
|
|
477
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
478
|
-
throw new McpError(ErrorCode.InternalError, `Failed to create Import Set: ${errorMessage}`);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Create Web Service with dynamic WSDL discovery
|
|
484
|
-
*/
|
|
485
|
-
private async createWebService(args: any) {
|
|
486
|
-
try {
|
|
487
|
-
this.logger.info('Creating Web Service...');
|
|
488
|
-
|
|
489
|
-
const webServiceData = {
|
|
490
|
-
name: args.name,
|
|
491
|
-
wsdl_url: args.wsdlUrl,
|
|
492
|
-
description: args.description || '',
|
|
493
|
-
authentication_type: args.authType || 'none',
|
|
494
|
-
namespace: args.namespace || ''
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
const updateSetResult = await this.client.ensureUpdateSet();
|
|
498
|
-
const response = await this.client.createRecord('sys_web_service', webServiceData);
|
|
499
|
-
|
|
500
|
-
if (!response.success) {
|
|
501
|
-
throw new Error(`Failed to create Web Service: ${response.error}`);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
return {
|
|
505
|
-
content: [{
|
|
506
|
-
type: 'text',
|
|
507
|
-
text: `ā
Web Service created successfully!\n\nš **${args.name}**\nš sys_id: ${response.data.sys_id}\nš WSDL: ${args.wsdlUrl}\nš Auth Type: ${args.authType || 'none'}\n${args.namespace ? `š·ļø Namespace: ${args.namespace}\n` : ''}\nš Description: ${args.description || 'No description provided'}\n\n⨠Created with dynamic WSDL discovery!`
|
|
508
|
-
}]
|
|
509
|
-
};
|
|
510
|
-
} catch (error) {
|
|
511
|
-
this.logger.error('Failed to create Web Service:', error);
|
|
512
|
-
throw new McpError(ErrorCode.InternalError, `Failed to create Web Service: ${error}`);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Create Email Configuration with dynamic discovery
|
|
518
|
-
*/
|
|
519
|
-
private async createEmailConfig(args: any) {
|
|
520
|
-
try {
|
|
521
|
-
this.logger.info('Creating Email Configuration...');
|
|
522
|
-
|
|
523
|
-
const emailConfigData = {
|
|
524
|
-
name: args.name,
|
|
525
|
-
type: args.serverType,
|
|
526
|
-
server: args.serverName,
|
|
527
|
-
port: args.port || this.getDefaultPort(args.serverType),
|
|
528
|
-
encryption: args.encryption || 'none',
|
|
529
|
-
user_name: args.username || '',
|
|
530
|
-
description: args.description || ''
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
const updateSetResult = await this.client.ensureUpdateSet();
|
|
534
|
-
const response = await this.client.createRecord('sys_email_account', emailConfigData);
|
|
535
|
-
|
|
536
|
-
if (!response.success) {
|
|
537
|
-
throw new Error(`Failed to create Email Configuration: ${response.error}`);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
return {
|
|
541
|
-
content: [{
|
|
542
|
-
type: 'text',
|
|
543
|
-
text: `ā
Email Configuration created successfully!\n\nš§ **${args.name}**\nš sys_id: ${response.data.sys_id}\nš„ļø Server: ${args.serverName}\nš Port: ${args.port || this.getDefaultPort(args.serverType)}\nš Encryption: ${args.encryption || 'none'}\nš¤ Username: ${args.username || 'Not specified'}\n\nš Description: ${args.description || 'No description provided'}\n\n⨠Created with dynamic port discovery!`
|
|
544
|
-
}]
|
|
545
|
-
};
|
|
546
|
-
} catch (error) {
|
|
547
|
-
this.logger.error('Failed to create Email Configuration:', error);
|
|
548
|
-
throw new McpError(ErrorCode.InternalError, `Failed to create Email Configuration: ${error}`);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Discover integration endpoints
|
|
554
|
-
*/
|
|
555
|
-
private async discoverIntegrationEndpoints(args: any) {
|
|
556
|
-
try {
|
|
557
|
-
this.logger.info('Discovering integration endpoints...');
|
|
558
|
-
|
|
559
|
-
const type = args?.type || 'all';
|
|
560
|
-
const endpoints: Array<{type: string, items: any[]}> = [];
|
|
561
|
-
|
|
562
|
-
// Discover REST Messages
|
|
563
|
-
if (type === 'all' || type === 'REST') {
|
|
564
|
-
const restMessages = await this.client.searchRecords('sys_rest_message', '', 50);
|
|
565
|
-
if (restMessages.success) {
|
|
566
|
-
endpoints.push({
|
|
567
|
-
type: 'REST Messages',
|
|
568
|
-
items: restMessages.data.result.map((msg: any) => ({
|
|
569
|
-
name: msg.name,
|
|
570
|
-
endpoint: msg.endpoint,
|
|
571
|
-
auth_type: msg.authentication_type,
|
|
572
|
-
sys_id: msg.sys_id
|
|
573
|
-
}))
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
// Discover Web Services
|
|
579
|
-
if (type === 'all' || type === 'SOAP') {
|
|
580
|
-
const webServices = await this.client.searchRecords('sys_web_service', '', 50);
|
|
581
|
-
if (webServices.success) {
|
|
582
|
-
endpoints.push({
|
|
583
|
-
type: 'Web Services (SOAP)',
|
|
584
|
-
items: webServices.data.result.map((ws: any) => ({
|
|
585
|
-
name: ws.name,
|
|
586
|
-
wsdl_url: ws.wsdl_url,
|
|
587
|
-
namespace: ws.namespace,
|
|
588
|
-
sys_id: ws.sys_id
|
|
589
|
-
}))
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
// Discover Email Accounts
|
|
595
|
-
if (type === 'all' || type === 'EMAIL') {
|
|
596
|
-
const emailAccounts = await this.client.searchRecords('sys_email_account', '', 50);
|
|
597
|
-
if (emailAccounts.success) {
|
|
598
|
-
endpoints.push({
|
|
599
|
-
type: 'Email Accounts',
|
|
600
|
-
items: emailAccounts.data.result.map((email: any) => ({
|
|
601
|
-
name: email.name,
|
|
602
|
-
server: email.server,
|
|
603
|
-
port: email.port,
|
|
604
|
-
type: email.type,
|
|
605
|
-
sys_id: email.sys_id
|
|
606
|
-
}))
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
return {
|
|
612
|
-
content: [{
|
|
613
|
-
type: 'text',
|
|
614
|
-
text: `š Discovered Integration Endpoints:\n\n${endpoints.map(endpoint =>
|
|
615
|
-
`**${endpoint.type}:**\n${endpoint.items.map(item =>
|
|
616
|
-
`- ${item.name}${item.endpoint ? ` (${item.endpoint})` : ''}${item.server ? ` (${item.server}:${item.port})` : ''}`
|
|
617
|
-
).join('\n')}`
|
|
618
|
-
).join('\n\n')}\n\n⨠Total endpoints found: ${endpoints.reduce((sum, e) => sum + e.items.length, 0)}\nš All endpoints discovered dynamically from ServiceNow!`
|
|
619
|
-
}]
|
|
620
|
-
};
|
|
621
|
-
} catch (error) {
|
|
622
|
-
this.logger.error('Failed to discover integration endpoints:', error);
|
|
623
|
-
throw new McpError(ErrorCode.InternalError, `Failed to discover endpoints: ${error}`);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Test integration endpoint
|
|
629
|
-
*/
|
|
630
|
-
private async testIntegration(args: any) {
|
|
631
|
-
try {
|
|
632
|
-
this.logger.info(`Testing integration: ${args.endpointName}`);
|
|
633
|
-
|
|
634
|
-
// Find the endpoint
|
|
635
|
-
const restMessage = await this.findRestMessage(args.endpointName);
|
|
636
|
-
if (!restMessage) {
|
|
637
|
-
throw new Error(`Integration endpoint not found: ${args.endpointName}`);
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
// Get available test methods
|
|
641
|
-
const methods = await this.client.searchRecords(
|
|
642
|
-
'sys_rest_message_fn',
|
|
643
|
-
`rest_message=${restMessage.sys_id}`,
|
|
644
|
-
10
|
|
645
|
-
);
|
|
646
|
-
|
|
647
|
-
if (!methods.success || !methods.data.result.length) {
|
|
648
|
-
throw new Error(`No methods found for REST Message: ${args.endpointName}`);
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
return {
|
|
652
|
-
content: [{
|
|
653
|
-
type: 'text',
|
|
654
|
-
text: `š§Ŗ Integration Test Results for **${args.endpointName}**:\n\nš Endpoint: ${restMessage.endpoint}\nšÆ Available Methods:\n${methods.data.result.map((method: any) =>
|
|
655
|
-
`- ${method.name} (${method.http_method})`
|
|
656
|
-
).join('\n')}\n\nā ļø **Test Note**: Use ServiceNow's REST Message test functionality to execute actual tests\n\n⨠Integration structure discovered dynamically!`
|
|
657
|
-
}]
|
|
658
|
-
};
|
|
659
|
-
} catch (error) {
|
|
660
|
-
this.logger.error('Failed to test integration:', error);
|
|
661
|
-
throw new McpError(ErrorCode.InternalError, `Failed to test integration: ${error}`);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* Discover data sources
|
|
667
|
-
*/
|
|
668
|
-
private async discoverDataSources(args: any) {
|
|
669
|
-
try {
|
|
670
|
-
this.logger.info('Discovering data sources...');
|
|
671
|
-
|
|
672
|
-
const dataSources: Array<{type: string, count: number, items: any[]}> = [];
|
|
673
|
-
|
|
674
|
-
// Discover Import Sets
|
|
675
|
-
const importSets = await this.client.searchRecords('sys_import_set_table', '', 50);
|
|
676
|
-
if (importSets.success) {
|
|
677
|
-
dataSources.push({
|
|
678
|
-
type: 'Import Sets',
|
|
679
|
-
count: importSets.data.result.length,
|
|
680
|
-
items: importSets.data.result.map((is: any) => ({
|
|
681
|
-
name: is.name,
|
|
682
|
-
label: is.label,
|
|
683
|
-
file_format: is.file_format
|
|
684
|
-
}))
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// Discover Transform Maps
|
|
689
|
-
const transformMaps = await this.client.searchRecords('sys_transform_map', '', 50);
|
|
690
|
-
if (transformMaps.success) {
|
|
691
|
-
dataSources.push({
|
|
692
|
-
type: 'Transform Maps',
|
|
693
|
-
count: transformMaps.data.result.length,
|
|
694
|
-
items: transformMaps.data.result.map((tm: any) => ({
|
|
695
|
-
name: tm.name,
|
|
696
|
-
source_table: tm.source_table,
|
|
697
|
-
target_table: tm.target_table
|
|
698
|
-
}))
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
// Discover Data Sources
|
|
703
|
-
const dataSourcesResponse = await this.client.searchRecords('sys_data_source', '', 50);
|
|
704
|
-
if (dataSourcesResponse.success) {
|
|
705
|
-
dataSources.push({
|
|
706
|
-
type: 'Data Sources',
|
|
707
|
-
count: dataSourcesResponse.data.result.length,
|
|
708
|
-
items: dataSourcesResponse.data.result.map((ds: any) => ({
|
|
709
|
-
name: ds.name,
|
|
710
|
-
type: ds.type,
|
|
711
|
-
url: ds.url
|
|
712
|
-
}))
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
return {
|
|
717
|
-
content: [{
|
|
718
|
-
type: 'text',
|
|
719
|
-
text: `š Discovered Data Sources:\n\n${dataSources.map(ds =>
|
|
720
|
-
`**${ds.type}** (${ds.count} found):\n${ds.items.slice(0, 5).map(item =>
|
|
721
|
-
`- ${item.name}${item.source_table ? ` (${item.source_table} ā ${item.target_table})` : ''}${item.url ? ` (${item.url})` : ''}`
|
|
722
|
-
).join('\n')}${ds.items.length > 5 ? '\n ... and more' : ''}`
|
|
723
|
-
).join('\n\n')}\n\n⨠Total data sources: ${dataSources.reduce((sum, ds) => sum + ds.count, 0)}\nš All sources discovered dynamically!`
|
|
724
|
-
}]
|
|
725
|
-
};
|
|
726
|
-
} catch (error) {
|
|
727
|
-
this.logger.error('Failed to discover data sources:', error);
|
|
728
|
-
throw new McpError(ErrorCode.InternalError, `Failed to discover data sources: ${error}`);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
// Helper methods
|
|
733
|
-
private async getAuthenticationTypes(): Promise<string[]> {
|
|
734
|
-
// Discover available authentication types dynamically
|
|
735
|
-
try {
|
|
736
|
-
const authTypes = await this.client.searchRecords('sys_choice', 'name=sys_rest_message^element=authentication_type', 10);
|
|
737
|
-
if (authTypes.success) {
|
|
738
|
-
return authTypes.data.result.map((choice: any) => choice.value);
|
|
739
|
-
}
|
|
740
|
-
} catch (error) {
|
|
741
|
-
this.logger.warn('Could not discover auth types dynamically, using defaults');
|
|
742
|
-
}
|
|
743
|
-
return ['none', 'basic', 'oauth2'];
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
private async getTableInfo(tableName: string): Promise<{name: string, label: string, sys_id: string} | null> {
|
|
747
|
-
try {
|
|
748
|
-
const tableResponse = await this.client.searchRecords('sys_db_object', `name=${tableName}`, 1);
|
|
749
|
-
if (tableResponse.success && tableResponse.data?.result?.length > 0) {
|
|
750
|
-
const table = tableResponse.data.result[0];
|
|
751
|
-
return { name: table.name, label: table.label, sys_id: table.sys_id };
|
|
752
|
-
}
|
|
753
|
-
return null;
|
|
754
|
-
} catch (error) {
|
|
755
|
-
this.logger.error(`Failed to get table info for ${tableName}:`, error);
|
|
756
|
-
return null;
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
private async getTableFields(tableName: string): Promise<string[]> {
|
|
761
|
-
try {
|
|
762
|
-
const fieldsResponse = await this.client.searchRecords('sys_dictionary', `nameSTARTSWITH${tableName}^element!=NULL`, 100);
|
|
763
|
-
if (fieldsResponse.success) {
|
|
764
|
-
return fieldsResponse.data.result.map((field: any) => field.element);
|
|
765
|
-
}
|
|
766
|
-
return [];
|
|
767
|
-
} catch (error) {
|
|
768
|
-
this.logger.error(`Failed to get fields for ${tableName}:`, error);
|
|
769
|
-
return [];
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
private async findRestMessage(name: string): Promise<any> {
|
|
774
|
-
try {
|
|
775
|
-
const response = await this.client.searchRecords('sys_rest_message', `name=${name}`, 1);
|
|
776
|
-
if (response.success && response.data?.result?.length > 0) {
|
|
777
|
-
return response.data.result[0];
|
|
778
|
-
}
|
|
779
|
-
return null;
|
|
780
|
-
} catch (error) {
|
|
781
|
-
this.logger.error(`Failed to find REST Message ${name}:`, error);
|
|
782
|
-
return null;
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
private async findTransformMap(name: string): Promise<any> {
|
|
787
|
-
try {
|
|
788
|
-
const response = await this.client.searchRecords('sys_transform_map', `name=${name}`, 1);
|
|
789
|
-
if (response.success && response.data?.result?.length > 0) {
|
|
790
|
-
return response.data.result[0];
|
|
791
|
-
}
|
|
792
|
-
return null;
|
|
793
|
-
} catch (error) {
|
|
794
|
-
this.logger.error(`Failed to find Transform Map ${name}:`, error);
|
|
795
|
-
return null;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
private getDefaultPort(serverType: string): number {
|
|
800
|
-
const portMap: Record<string, number> = {
|
|
801
|
-
'SMTP': 587,
|
|
802
|
-
'POP3': 110,
|
|
803
|
-
'IMAP': 143,
|
|
804
|
-
'SMTPS': 465,
|
|
805
|
-
'POP3S': 995,
|
|
806
|
-
'IMAPS': 993
|
|
807
|
-
};
|
|
808
|
-
return portMap[serverType] || 25;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
async run() {
|
|
812
|
-
const transport = new StdioServerTransport();
|
|
813
|
-
await this.server.connect(transport);
|
|
814
|
-
this.logger.info('ServiceNow Integration MCP Server running on stdio');
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
const server = new ServiceNowIntegrationMCP();
|
|
819
|
-
server.run().catch(console.error);
|