snow-flow 8.39.1 → 8.39.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.
Files changed (115) hide show
  1. package/dist/mcp/base-mcp-server.d.ts +3 -0
  2. package/dist/mcp/base-mcp-server.d.ts.map +1 -1
  3. package/dist/mcp/base-mcp-server.js +48 -21
  4. package/dist/mcp/base-mcp-server.js.map +1 -1
  5. package/dist/mcp/servicenow-mcp-unified/tools/automation/index.d.ts +6 -0
  6. package/dist/mcp/servicenow-mcp-unified/tools/automation/index.d.ts.map +1 -1
  7. package/dist/mcp/servicenow-mcp-unified/tools/automation/index.js +19 -1
  8. package/dist/mcp/servicenow-mcp-unified/tools/automation/index.js.map +1 -1
  9. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_email_logs.d.ts +12 -0
  10. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_email_logs.d.ts.map +1 -0
  11. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_email_logs.js +185 -0
  12. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_email_logs.js.map +1 -0
  13. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_flow_execution_logs.d.ts +12 -0
  14. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_flow_execution_logs.d.ts.map +1 -0
  15. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_flow_execution_logs.js +280 -0
  16. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_flow_execution_logs.js.map +1 -0
  17. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_inbound_http_logs.d.ts +12 -0
  18. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_inbound_http_logs.d.ts.map +1 -0
  19. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_inbound_http_logs.js +233 -0
  20. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_inbound_http_logs.js.map +1 -0
  21. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_outbound_http_logs.d.ts +12 -0
  22. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_outbound_http_logs.d.ts.map +1 -0
  23. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_outbound_http_logs.js +218 -0
  24. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_outbound_http_logs.js.map +1 -0
  25. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_scheduled_job_logs.d.ts +12 -0
  26. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_scheduled_job_logs.d.ts.map +1 -0
  27. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_scheduled_job_logs.js +276 -0
  28. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_scheduled_job_logs.js.map +1 -0
  29. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_slow_queries.d.ts +12 -0
  30. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_slow_queries.d.ts.map +1 -0
  31. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_slow_queries.js +340 -0
  32. package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_get_slow_queries.js.map +1 -0
  33. package/dist/mcp/servicenow-mcp-unified/tools/integration/index.d.ts +10 -0
  34. package/dist/mcp/servicenow-mcp-unified/tools/integration/index.d.ts.map +1 -1
  35. package/dist/mcp/servicenow-mcp-unified/tools/integration/index.js +34 -1
  36. package/dist/mcp/servicenow-mcp-unified/tools/integration/index.js.map +1 -1
  37. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_configure_mid_server.d.ts +12 -0
  38. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_configure_mid_server.d.ts.map +1 -0
  39. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_configure_mid_server.js +397 -0
  40. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_configure_mid_server.js.map +1 -0
  41. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_connection_alias.d.ts +12 -0
  42. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_connection_alias.d.ts.map +1 -0
  43. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_connection_alias.js +234 -0
  44. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_connection_alias.js.map +1 -0
  45. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_credential_alias.d.ts +12 -0
  46. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_credential_alias.d.ts.map +1 -0
  47. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_credential_alias.js +280 -0
  48. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_credential_alias.js.map +1 -0
  49. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_flow_action.d.ts +12 -0
  50. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_flow_action.d.ts.map +1 -0
  51. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_flow_action.js +358 -0
  52. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_flow_action.js.map +1 -0
  53. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_oauth_profile.d.ts +12 -0
  54. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_oauth_profile.d.ts.map +1 -0
  55. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_oauth_profile.js +237 -0
  56. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_create_oauth_profile.js.map +1 -0
  57. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_install_spoke.d.ts +12 -0
  58. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_install_spoke.d.ts.map +1 -0
  59. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_install_spoke.js +326 -0
  60. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_install_spoke.js.map +1 -0
  61. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_mid_capabilities.d.ts +12 -0
  62. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_mid_capabilities.d.ts.map +1 -0
  63. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_mid_capabilities.js +442 -0
  64. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_mid_capabilities.js.map +1 -0
  65. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_oauth_tokens.d.ts +12 -0
  66. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_oauth_tokens.d.ts.map +1 -0
  67. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_oauth_tokens.js +348 -0
  68. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_oauth_tokens.js.map +1 -0
  69. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_spoke_connection.d.ts +12 -0
  70. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_spoke_connection.d.ts.map +1 -0
  71. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_spoke_connection.js +427 -0
  72. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_manage_spoke_connection.js.map +1 -0
  73. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_test_mid_connectivity.d.ts +12 -0
  74. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_test_mid_connectivity.d.ts.map +1 -0
  75. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_test_mid_connectivity.js +432 -0
  76. package/dist/mcp/servicenow-mcp-unified/tools/integration/snow_test_mid_connectivity.js.map +1 -0
  77. package/dist/monitoring/performance-tracker.d.ts +1 -1
  78. package/dist/monitoring/performance-tracker.d.ts.map +1 -1
  79. package/dist/monitoring/performance-tracker.js +44 -9
  80. package/dist/monitoring/performance-tracker.js.map +1 -1
  81. package/dist/snow-flow-system.d.ts +12 -2
  82. package/dist/snow-flow-system.d.ts.map +1 -1
  83. package/dist/snow-flow-system.js +55 -12
  84. package/dist/snow-flow-system.js.map +1 -1
  85. package/dist/templates/agents-md-template.d.ts +2 -2
  86. package/dist/templates/agents-md-template.d.ts.map +1 -1
  87. package/dist/templates/agents-md-template.js +57 -2
  88. package/dist/templates/agents-md-template.js.map +1 -1
  89. package/dist/templates/claude-md-template.d.ts +2 -2
  90. package/dist/templates/claude-md-template.d.ts.map +1 -1
  91. package/dist/templates/claude-md-template.js +17 -1
  92. package/dist/templates/claude-md-template.js.map +1 -1
  93. package/dist/utils/mcp-on-demand-manager.d.ts.map +1 -1
  94. package/dist/utils/mcp-on-demand-manager.js +18 -5
  95. package/dist/utils/mcp-on-demand-manager.js.map +1 -1
  96. package/dist/utils/mcp-persistent-guard.d.ts +4 -0
  97. package/dist/utils/mcp-persistent-guard.d.ts.map +1 -1
  98. package/dist/utils/mcp-persistent-guard.js +26 -2
  99. package/dist/utils/mcp-persistent-guard.js.map +1 -1
  100. package/dist/utils/mcp-process-manager.d.ts.map +1 -1
  101. package/dist/utils/mcp-process-manager.js +5 -0
  102. package/dist/utils/mcp-process-manager.js.map +1 -1
  103. package/dist/utils/memory-safe-collections.d.ts +119 -0
  104. package/dist/utils/memory-safe-collections.d.ts.map +1 -0
  105. package/dist/utils/memory-safe-collections.js +212 -0
  106. package/dist/utils/memory-safe-collections.js.map +1 -0
  107. package/dist/utils/timer-registry.d.ts +138 -0
  108. package/dist/utils/timer-registry.d.ts.map +1 -0
  109. package/dist/utils/timer-registry.js +289 -0
  110. package/dist/utils/timer-registry.js.map +1 -0
  111. package/dist/version.d.ts +1 -1
  112. package/dist/version.d.ts.map +1 -1
  113. package/dist/version.js +1 -1
  114. package/dist/version.js.map +1 -1
  115. package/package.json +2 -2
@@ -0,0 +1,397 @@
1
+ "use strict";
2
+ /**
3
+ * snow_configure_mid_server - Configure MID Server settings
4
+ *
5
+ * View, configure, and manage MID Server instances for secure
6
+ * on-premise integrations and Discovery operations.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.author = exports.version = exports.toolDefinition = void 0;
10
+ exports.execute = execute;
11
+ const auth_js_1 = require("../../shared/auth.js");
12
+ const error_handler_js_1 = require("../../shared/error-handler.js");
13
+ exports.toolDefinition = {
14
+ name: 'snow_configure_mid_server',
15
+ description: 'Configure MID Server settings for on-premise integrations and Discovery',
16
+ category: 'integration',
17
+ subcategory: 'mid-server',
18
+ use_cases: ['mid-server', 'on-premise', 'discovery', 'integration'],
19
+ complexity: 'advanced',
20
+ frequency: 'low',
21
+ permission: 'admin',
22
+ allowedRoles: ['admin'],
23
+ inputSchema: {
24
+ type: 'object',
25
+ properties: {
26
+ action: {
27
+ type: 'string',
28
+ enum: ['list', 'status', 'configure', 'validate', 'restart', 'assign_application'],
29
+ description: 'Action to perform',
30
+ default: 'list'
31
+ },
32
+ mid_server_name: {
33
+ type: 'string',
34
+ description: 'Name of the MID Server'
35
+ },
36
+ mid_server_id: {
37
+ type: 'string',
38
+ description: 'sys_id of the MID Server'
39
+ },
40
+ configuration: {
41
+ type: 'object',
42
+ description: 'Configuration settings to apply',
43
+ properties: {
44
+ ip_address: { type: 'string', description: 'IP address restriction' },
45
+ max_threads: { type: 'number', description: 'Maximum concurrent threads' },
46
+ max_memory: { type: 'string', description: 'Maximum memory allocation (e.g., "2048m")' },
47
+ network_range: { type: 'string', description: 'Network range for Discovery' },
48
+ validated: { type: 'boolean', description: 'Validation status' }
49
+ }
50
+ },
51
+ application_id: {
52
+ type: 'string',
53
+ description: 'Application sys_id for assign_application action'
54
+ },
55
+ include_inactive: {
56
+ type: 'boolean',
57
+ description: 'Include inactive MID Servers',
58
+ default: false
59
+ }
60
+ },
61
+ required: ['action']
62
+ }
63
+ };
64
+ async function execute(args, context) {
65
+ var action = args.action || 'list';
66
+ var mid_server_name = args.mid_server_name || '';
67
+ var mid_server_id = args.mid_server_id || '';
68
+ var configuration = args.configuration || {};
69
+ var application_id = args.application_id || '';
70
+ var include_inactive = args.include_inactive || false;
71
+ try {
72
+ var client = await (0, auth_js_1.getAuthenticatedClient)(context);
73
+ if (action === 'list') {
74
+ // List all MID Servers
75
+ var queryParts = [];
76
+ if (!include_inactive) {
77
+ queryParts.push('status=Up');
78
+ }
79
+ if (mid_server_name) {
80
+ queryParts.push('nameLIKE' + mid_server_name);
81
+ }
82
+ var midServersResponse = await client.get('/api/now/table/ecc_agent', {
83
+ params: {
84
+ sysparm_query: queryParts.join('^') + '^ORDERBYname',
85
+ sysparm_limit: 100,
86
+ sysparm_fields: 'sys_id,name,status,ip_address,host_name,version,validated,last_refreshed,router,sys_created_on',
87
+ sysparm_display_value: 'all'
88
+ }
89
+ });
90
+ var midServers = midServersResponse.data.result || [];
91
+ // Get additional stats for each MID Server
92
+ var enrichedServers = [];
93
+ for (var i = 0; i < midServers.length; i++) {
94
+ var mid = midServers[i];
95
+ // Get capability count
96
+ var capsResponse = await client.get('/api/now/table/ecc_agent_capability_m2m', {
97
+ params: {
98
+ sysparm_query: 'agent=' + mid.sys_id,
99
+ sysparm_fields: 'sys_id',
100
+ sysparm_limit: 100
101
+ }
102
+ });
103
+ // Get application count
104
+ var appsResponse = await client.get('/api/now/table/ecc_agent_application_m2m', {
105
+ params: {
106
+ sysparm_query: 'agent=' + mid.sys_id,
107
+ sysparm_fields: 'sys_id',
108
+ sysparm_limit: 100
109
+ }
110
+ });
111
+ enrichedServers.push({
112
+ sys_id: mid.sys_id,
113
+ name: mid.name,
114
+ status: mid.status && mid.status.display_value ? mid.status.display_value : mid.status,
115
+ ip_address: mid.ip_address,
116
+ host_name: mid.host_name,
117
+ version: mid.version,
118
+ validated: mid.validated === 'true' || mid.validated === true,
119
+ last_refreshed: mid.last_refreshed,
120
+ router: mid.router && mid.router.display_value ? mid.router.display_value : mid.router,
121
+ capability_count: capsResponse.data.result?.length || 0,
122
+ application_count: appsResponse.data.result?.length || 0,
123
+ created_on: mid.sys_created_on
124
+ });
125
+ }
126
+ // Calculate summary
127
+ var summary = {
128
+ total: enrichedServers.length,
129
+ up: enrichedServers.filter(function (m) { return m.status === 'Up'; }).length,
130
+ down: enrichedServers.filter(function (m) { return m.status === 'Down'; }).length,
131
+ validated: enrichedServers.filter(function (m) { return m.validated; }).length,
132
+ not_validated: enrichedServers.filter(function (m) { return !m.validated; }).length
133
+ };
134
+ return (0, error_handler_js_1.createSuccessResult)({
135
+ action: 'list',
136
+ mid_servers: enrichedServers,
137
+ summary: summary
138
+ });
139
+ }
140
+ else if (action === 'status') {
141
+ // Get detailed status of a specific MID Server
142
+ var midId = mid_server_id;
143
+ if (!midId && mid_server_name) {
144
+ var lookupResponse = await client.get('/api/now/table/ecc_agent', {
145
+ params: {
146
+ sysparm_query: 'name=' + mid_server_name,
147
+ sysparm_limit: 1,
148
+ sysparm_fields: 'sys_id'
149
+ }
150
+ });
151
+ if (lookupResponse.data.result && lookupResponse.data.result.length > 0) {
152
+ midId = lookupResponse.data.result[0].sys_id;
153
+ }
154
+ }
155
+ if (!midId) {
156
+ return (0, error_handler_js_1.createErrorResult)('MID Server not found. Provide mid_server_id or mid_server_name.');
157
+ }
158
+ // Get MID Server details
159
+ var midResponse = await client.get('/api/now/table/ecc_agent/' + midId, {
160
+ params: {
161
+ sysparm_display_value: 'all'
162
+ }
163
+ });
164
+ if (!midResponse.data.result) {
165
+ return (0, error_handler_js_1.createErrorResult)('MID Server not found');
166
+ }
167
+ var midServer = midResponse.data.result;
168
+ // Get capabilities
169
+ var capabilitiesResponse = await client.get('/api/now/table/ecc_agent_capability_m2m', {
170
+ params: {
171
+ sysparm_query: 'agent=' + midId,
172
+ sysparm_fields: 'capability',
173
+ sysparm_display_value: 'all',
174
+ sysparm_limit: 100
175
+ }
176
+ });
177
+ var capabilities = (capabilitiesResponse.data.result || []).map(function (c) {
178
+ return c.capability && c.capability.display_value ? c.capability.display_value : c.capability;
179
+ });
180
+ // Get assigned applications
181
+ var applicationsResponse = await client.get('/api/now/table/ecc_agent_application_m2m', {
182
+ params: {
183
+ sysparm_query: 'agent=' + midId,
184
+ sysparm_fields: 'application',
185
+ sysparm_display_value: 'all',
186
+ sysparm_limit: 100
187
+ }
188
+ });
189
+ var applications = (applicationsResponse.data.result || []).map(function (a) {
190
+ return a.application && a.application.display_value ? a.application.display_value : a.application;
191
+ });
192
+ // Get recent issues from ECC queue
193
+ var eccIssuesResponse = await client.get('/api/now/table/ecc_queue', {
194
+ params: {
195
+ sysparm_query: 'agent=' + midId + '^state=error^ORDERBYDESCsys_created_on',
196
+ sysparm_limit: 10,
197
+ sysparm_fields: 'sys_created_on,topic,name,error_string'
198
+ }
199
+ });
200
+ var recentIssues = eccIssuesResponse.data.result || [];
201
+ // Calculate health score
202
+ var healthScore = 100;
203
+ if (midServer.status !== 'Up' && midServer.status?.display_value !== 'Up')
204
+ healthScore -= 50;
205
+ if (!midServer.validated && midServer.validated !== 'true')
206
+ healthScore -= 20;
207
+ if (recentIssues.length > 0)
208
+ healthScore -= Math.min(30, recentIssues.length * 5);
209
+ return (0, error_handler_js_1.createSuccessResult)({
210
+ action: 'status',
211
+ mid_server: {
212
+ sys_id: midServer.sys_id,
213
+ name: midServer.name,
214
+ status: midServer.status && midServer.status.display_value ? midServer.status.display_value : midServer.status,
215
+ ip_address: midServer.ip_address,
216
+ host_name: midServer.host_name,
217
+ version: midServer.version,
218
+ validated: midServer.validated === 'true' || midServer.validated === true,
219
+ last_refreshed: midServer.last_refreshed,
220
+ router: midServer.router && midServer.router.display_value ? midServer.router.display_value : midServer.router,
221
+ network: midServer.network,
222
+ home_dir: midServer.home_dir
223
+ },
224
+ capabilities: capabilities,
225
+ capability_count: capabilities.length,
226
+ applications: applications,
227
+ application_count: applications.length,
228
+ recent_issues: recentIssues.map(function (issue) {
229
+ return {
230
+ timestamp: issue.sys_created_on,
231
+ topic: issue.topic,
232
+ name: issue.name,
233
+ error: issue.error_string
234
+ };
235
+ }),
236
+ health: {
237
+ score: healthScore,
238
+ status: healthScore >= 80 ? 'healthy' : (healthScore >= 50 ? 'degraded' : 'unhealthy')
239
+ }
240
+ });
241
+ }
242
+ else if (action === 'configure') {
243
+ var configMidId = mid_server_id;
244
+ if (!configMidId && mid_server_name) {
245
+ var configLookup = await client.get('/api/now/table/ecc_agent', {
246
+ params: {
247
+ sysparm_query: 'name=' + mid_server_name,
248
+ sysparm_limit: 1,
249
+ sysparm_fields: 'sys_id'
250
+ }
251
+ });
252
+ if (configLookup.data.result && configLookup.data.result.length > 0) {
253
+ configMidId = configLookup.data.result[0].sys_id;
254
+ }
255
+ }
256
+ if (!configMidId) {
257
+ return (0, error_handler_js_1.createErrorResult)('MID Server not found');
258
+ }
259
+ // Build update object
260
+ var updates = {};
261
+ if (configuration.ip_address !== undefined)
262
+ updates.ip_address = configuration.ip_address;
263
+ if (configuration.validated !== undefined)
264
+ updates.validated = configuration.validated;
265
+ if (configuration.network_range !== undefined)
266
+ updates.network = configuration.network_range;
267
+ if (Object.keys(updates).length > 0) {
268
+ await client.patch('/api/now/table/ecc_agent/' + configMidId, updates);
269
+ }
270
+ return (0, error_handler_js_1.createSuccessResult)({
271
+ action: 'configure',
272
+ mid_server_id: configMidId,
273
+ updates_applied: updates,
274
+ message: 'MID Server configuration updated',
275
+ note: 'Some settings require MID Server restart to take effect'
276
+ });
277
+ }
278
+ else if (action === 'validate') {
279
+ var validateMidId = mid_server_id;
280
+ if (!validateMidId && mid_server_name) {
281
+ var validateLookup = await client.get('/api/now/table/ecc_agent', {
282
+ params: {
283
+ sysparm_query: 'name=' + mid_server_name,
284
+ sysparm_limit: 1,
285
+ sysparm_fields: 'sys_id,name,validated'
286
+ }
287
+ });
288
+ if (validateLookup.data.result && validateLookup.data.result.length > 0) {
289
+ validateMidId = validateLookup.data.result[0].sys_id;
290
+ }
291
+ }
292
+ if (!validateMidId) {
293
+ return (0, error_handler_js_1.createErrorResult)('MID Server not found');
294
+ }
295
+ // Set validated to true
296
+ await client.patch('/api/now/table/ecc_agent/' + validateMidId, {
297
+ validated: true
298
+ });
299
+ return (0, error_handler_js_1.createSuccessResult)({
300
+ action: 'validate',
301
+ mid_server_id: validateMidId,
302
+ validated: true,
303
+ message: 'MID Server has been validated and is ready for use'
304
+ });
305
+ }
306
+ else if (action === 'restart') {
307
+ var restartMidId = mid_server_id;
308
+ if (!restartMidId && mid_server_name) {
309
+ var restartLookup = await client.get('/api/now/table/ecc_agent', {
310
+ params: {
311
+ sysparm_query: 'name=' + mid_server_name,
312
+ sysparm_limit: 1,
313
+ sysparm_fields: 'sys_id,name'
314
+ }
315
+ });
316
+ if (restartLookup.data.result && restartLookup.data.result.length > 0) {
317
+ restartMidId = restartLookup.data.result[0].sys_id;
318
+ }
319
+ }
320
+ if (!restartMidId) {
321
+ return (0, error_handler_js_1.createErrorResult)('MID Server not found');
322
+ }
323
+ // Queue a restart command via ECC queue
324
+ var restartScript = `
325
+ var ecc = new GlideRecord('ecc_queue');
326
+ ecc.initialize();
327
+ ecc.agent = ${JSON.stringify(restartMidId)};
328
+ ecc.topic = 'Command';
329
+ ecc.name = 'restartMid';
330
+ ecc.source = 'snow-flow';
331
+ ecc.queue = 'output';
332
+ var sysId = ecc.insert();
333
+ gs.print(JSON.stringify({
334
+ success: sysId ? true : false,
335
+ ecc_queue_id: sysId,
336
+ message: sysId ? 'Restart command queued' : 'Failed to queue restart'
337
+ }));
338
+ `;
339
+ var restartResponse = await client.post('/api/now/table/sys_script_execution', {
340
+ script: restartScript,
341
+ description: 'Restart MID Server: ' + restartMidId
342
+ });
343
+ var restartOutput = restartResponse.data.result?.output || '';
344
+ var restartMatch = restartOutput.match(/\{[^}]+\}/);
345
+ var restartResult = restartMatch ? JSON.parse(restartMatch[0]) : { success: false, message: 'Unknown error' };
346
+ return (0, error_handler_js_1.createSuccessResult)({
347
+ action: 'restart',
348
+ mid_server_id: restartMidId,
349
+ result: restartResult
350
+ });
351
+ }
352
+ else if (action === 'assign_application') {
353
+ if (!application_id) {
354
+ return (0, error_handler_js_1.createErrorResult)('application_id is required for assign_application action');
355
+ }
356
+ var assignMidId = mid_server_id;
357
+ if (!assignMidId && mid_server_name) {
358
+ var assignLookup = await client.get('/api/now/table/ecc_agent', {
359
+ params: {
360
+ sysparm_query: 'name=' + mid_server_name,
361
+ sysparm_limit: 1,
362
+ sysparm_fields: 'sys_id'
363
+ }
364
+ });
365
+ if (assignLookup.data.result && assignLookup.data.result.length > 0) {
366
+ assignMidId = assignLookup.data.result[0].sys_id;
367
+ }
368
+ }
369
+ if (!assignMidId) {
370
+ return (0, error_handler_js_1.createErrorResult)('MID Server not found');
371
+ }
372
+ // Create application assignment
373
+ var assignResponse = await client.post('/api/now/table/ecc_agent_application_m2m', {
374
+ agent: assignMidId,
375
+ application: application_id
376
+ });
377
+ return (0, error_handler_js_1.createSuccessResult)({
378
+ action: 'assign_application',
379
+ mid_server_id: assignMidId,
380
+ application_id: application_id,
381
+ assignment_id: assignResponse.data.result?.sys_id,
382
+ message: 'Application assigned to MID Server successfully'
383
+ });
384
+ }
385
+ return (0, error_handler_js_1.createErrorResult)('Unknown action: ' + action);
386
+ }
387
+ catch (error) {
388
+ if (error.response?.status === 403) {
389
+ return (0, error_handler_js_1.createErrorResult)('Permission denied (403): Your ServiceNow user lacks permissions to manage MID Servers. ' +
390
+ 'Required roles: "mid_server" or "admin". Please contact your ServiceNow administrator.');
391
+ }
392
+ return (0, error_handler_js_1.createErrorResult)(error.message);
393
+ }
394
+ }
395
+ exports.version = '1.0.0';
396
+ exports.author = 'Snow-Flow Team';
397
+ //# sourceMappingURL=snow_configure_mid_server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snow_configure_mid_server.js","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/integration/snow_configure_mid_server.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA2DH,0BA+WC;AAvaD,kDAA8D;AAC9D,oEAAuF;AAE1E,QAAA,cAAc,GAAsB;IAC/C,IAAI,EAAE,2BAA2B;IACjC,WAAW,EAAE,yEAAyE;IACtF,QAAQ,EAAE,aAAa;IACvB,WAAW,EAAE,YAAY;IACzB,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,CAAC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,IAAA,sCAAmB,EAAC;gBACzB,MAAM,EAAE,oBAAoB;gBAC5B,aAAa,EAAE,WAAW;gBAC1B,cAAc,EAAE,cAAc;gBAC9B,aAAa,EAAE,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM;gBACjD,OAAO,EAAE,iDAAiD;aAC3D,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAA,oCAAiB,EAAC,kBAAkB,GAAG,MAAM,CAAC,CAAC;IAExD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,KAAK,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE,CAAC;YACnC,OAAO,IAAA,oCAAiB,EACtB,yFAAyF;gBACzF,wFAAwF,CACzF,CAAC;QACJ,CAAC;QACD,OAAO,IAAA,oCAAiB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAEY,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,MAAM,GAAG,gBAAgB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * snow_create_connection_alias - Create Connection & Credential Aliases
3
+ *
4
+ * Create connection aliases for IntegrationHub and Flow Designer
5
+ * to securely reference external system credentials.
6
+ */
7
+ import { MCPToolDefinition, ServiceNowContext, ToolResult } from '../../shared/types.js';
8
+ export declare const toolDefinition: MCPToolDefinition;
9
+ export declare function execute(args: any, context: ServiceNowContext): Promise<ToolResult>;
10
+ export declare const version = "1.0.0";
11
+ export declare const author = "Snow-Flow Team";
12
+ //# sourceMappingURL=snow_create_connection_alias.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snow_create_connection_alias.d.ts","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/integration/snow_create_connection_alias.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIzF,eAAO,MAAM,cAAc,EAAE,iBA8E5B,CAAC;AAEF,wBAAsB,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAwJxF;AAED,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ /**
3
+ * snow_create_connection_alias - Create Connection & Credential Aliases
4
+ *
5
+ * Create connection aliases for IntegrationHub and Flow Designer
6
+ * to securely reference external system credentials.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.author = exports.version = exports.toolDefinition = void 0;
10
+ exports.execute = execute;
11
+ const auth_js_1 = require("../../shared/auth.js");
12
+ const error_handler_js_1 = require("../../shared/error-handler.js");
13
+ exports.toolDefinition = {
14
+ name: 'snow_create_connection_alias',
15
+ description: 'Create connection alias for IntegrationHub/Flow Designer to reference external credentials',
16
+ category: 'integration',
17
+ subcategory: 'credentials',
18
+ use_cases: ['integration-hub', 'flow-designer', 'credentials', 'connections'],
19
+ complexity: 'intermediate',
20
+ frequency: 'medium',
21
+ permission: 'write',
22
+ allowedRoles: ['developer', 'admin'],
23
+ inputSchema: {
24
+ type: 'object',
25
+ properties: {
26
+ name: {
27
+ type: 'string',
28
+ description: 'Connection alias name (e.g., "Jira Production", "Azure DevOps")'
29
+ },
30
+ connection_type: {
31
+ type: 'string',
32
+ enum: ['http', 'jdbc', 'ldap', 'ssh', 'custom'],
33
+ description: 'Type of connection',
34
+ default: 'http'
35
+ },
36
+ configuration_template: {
37
+ type: 'string',
38
+ description: 'sys_id of the connection configuration template (e.g., for specific Spoke)'
39
+ },
40
+ credential_alias: {
41
+ type: 'string',
42
+ description: 'sys_id of credential alias to use (if already exists)'
43
+ },
44
+ active: {
45
+ type: 'boolean',
46
+ description: 'Whether the alias is active',
47
+ default: true
48
+ },
49
+ http_connection: {
50
+ type: 'object',
51
+ description: 'HTTP connection details (for http type)',
52
+ properties: {
53
+ base_url: {
54
+ type: 'string',
55
+ description: 'Base URL of the external system'
56
+ },
57
+ default_headers: {
58
+ type: 'object',
59
+ description: 'Default headers to send'
60
+ },
61
+ use_mutual_auth: {
62
+ type: 'boolean',
63
+ description: 'Enable mutual TLS authentication'
64
+ },
65
+ mid_server: {
66
+ type: 'string',
67
+ description: 'MID Server to use for connection'
68
+ }
69
+ }
70
+ },
71
+ retry_policy: {
72
+ type: 'object',
73
+ description: 'Retry policy for failed connections',
74
+ properties: {
75
+ max_retries: {
76
+ type: 'number',
77
+ description: 'Maximum number of retries',
78
+ default: 3
79
+ },
80
+ retry_interval_seconds: {
81
+ type: 'number',
82
+ description: 'Seconds between retries',
83
+ default: 5
84
+ }
85
+ }
86
+ }
87
+ },
88
+ required: ['name']
89
+ }
90
+ };
91
+ async function execute(args, context) {
92
+ var name = args.name;
93
+ var connection_type = args.connection_type || 'http';
94
+ var configuration_template = args.configuration_template || '';
95
+ var credential_alias = args.credential_alias || '';
96
+ var active = args.active !== false;
97
+ var http_connection = args.http_connection || {};
98
+ var retry_policy = args.retry_policy || {};
99
+ try {
100
+ var client = await (0, auth_js_1.getAuthenticatedClient)(context);
101
+ var usedBackgroundScript = false;
102
+ // Create the connection alias record
103
+ var aliasData = {
104
+ name: name,
105
+ type: connection_type,
106
+ active: active
107
+ };
108
+ if (configuration_template) {
109
+ aliasData.configuration_template = configuration_template;
110
+ }
111
+ if (credential_alias) {
112
+ aliasData.credential = credential_alias;
113
+ }
114
+ var aliasResponse;
115
+ try {
116
+ aliasResponse = await client.post('/api/now/table/sys_alias', aliasData);
117
+ }
118
+ catch (tableError) {
119
+ if (tableError.response?.status === 403) {
120
+ usedBackgroundScript = true;
121
+ var script = `
122
+ var gr = new GlideRecord('sys_alias');
123
+ gr.initialize();
124
+ gr.name = ${JSON.stringify(name)};
125
+ gr.type = ${JSON.stringify(connection_type)};
126
+ gr.active = ${active};
127
+ ${configuration_template ? `gr.configuration_template = ${JSON.stringify(configuration_template)};` : ''}
128
+ ${credential_alias ? `gr.credential = ${JSON.stringify(credential_alias)};` : ''}
129
+ var sysId = gr.insert();
130
+
131
+ if (sysId) {
132
+ gs.print(JSON.stringify({
133
+ sys_id: sysId,
134
+ name: gr.name.toString(),
135
+ type: gr.type.toString()
136
+ }));
137
+ } else {
138
+ gs.error('Failed to create connection alias');
139
+ }
140
+ `;
141
+ var scriptResponse = await client.post('/api/now/table/sys_script_execution', {
142
+ script: script,
143
+ description: 'Create connection alias: ' + name
144
+ });
145
+ var output = scriptResponse.data.result?.output || '';
146
+ var match = output.match(/\{[^}]+\}/);
147
+ if (match) {
148
+ aliasResponse = { data: { result: JSON.parse(match[0]) } };
149
+ }
150
+ else {
151
+ throw new Error('Failed to create connection alias via background script');
152
+ }
153
+ }
154
+ else {
155
+ throw tableError;
156
+ }
157
+ }
158
+ var alias = aliasResponse.data.result;
159
+ // If HTTP connection details provided, create HTTP connection record
160
+ var httpConnectionRecord = null;
161
+ if (connection_type === 'http' && http_connection.base_url) {
162
+ var httpData = {
163
+ connection_alias: alias.sys_id,
164
+ connection_url: http_connection.base_url,
165
+ use_mutual_auth: http_connection.use_mutual_auth || false
166
+ };
167
+ if (http_connection.mid_server) {
168
+ httpData.mid_server = http_connection.mid_server;
169
+ }
170
+ try {
171
+ var httpResponse = await client.post('/api/now/table/sys_connection', httpData);
172
+ httpConnectionRecord = httpResponse.data.result;
173
+ }
174
+ catch (httpError) {
175
+ if (httpError.response?.status === 403) {
176
+ var httpScript = `
177
+ var gr = new GlideRecord('sys_connection');
178
+ gr.initialize();
179
+ gr.connection_alias = ${JSON.stringify(alias.sys_id)};
180
+ gr.connection_url = ${JSON.stringify(http_connection.base_url)};
181
+ gr.use_mutual_auth = ${http_connection.use_mutual_auth || false};
182
+ ${http_connection.mid_server ? `gr.mid_server = ${JSON.stringify(http_connection.mid_server)};` : ''}
183
+ var sysId = gr.insert();
184
+
185
+ if (sysId) {
186
+ gs.print(JSON.stringify({
187
+ sys_id: sysId,
188
+ connection_url: gr.connection_url.toString()
189
+ }));
190
+ }
191
+ `;
192
+ var httpScriptResponse = await client.post('/api/now/table/sys_script_execution', {
193
+ script: httpScript,
194
+ description: 'Create HTTP connection for alias: ' + name
195
+ });
196
+ var httpOutput = httpScriptResponse.data.result?.output || '';
197
+ var httpMatch = httpOutput.match(/\{[^}]+\}/);
198
+ if (httpMatch) {
199
+ httpConnectionRecord = JSON.parse(httpMatch[0]);
200
+ }
201
+ }
202
+ }
203
+ }
204
+ return (0, error_handler_js_1.createSuccessResult)({
205
+ created: true,
206
+ method: usedBackgroundScript ? 'background_script' : 'table_api',
207
+ connection_alias: {
208
+ sys_id: alias.sys_id,
209
+ name: alias.name || name,
210
+ type: connection_type,
211
+ active: active
212
+ },
213
+ http_connection: httpConnectionRecord ? {
214
+ sys_id: httpConnectionRecord.sys_id,
215
+ base_url: http_connection.base_url
216
+ } : null,
217
+ usage_instructions: [
218
+ 'Use this alias in Flow Designer actions',
219
+ 'Reference in REST steps: alias=' + name,
220
+ 'Configure credentials via snow_create_credential_alias if needed'
221
+ ]
222
+ });
223
+ }
224
+ catch (error) {
225
+ if (error.response?.status === 403) {
226
+ return (0, error_handler_js_1.createErrorResult)('Permission denied (403): Your ServiceNow user lacks permissions to create connection aliases. ' +
227
+ 'Required roles: "connection_admin" or "admin". Please contact your ServiceNow administrator.');
228
+ }
229
+ return (0, error_handler_js_1.createErrorResult)(error.message);
230
+ }
231
+ }
232
+ exports.version = '1.0.0';
233
+ exports.author = 'Snow-Flow Team';
234
+ //# sourceMappingURL=snow_create_connection_alias.js.map