snow-flow 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/{.claude/mcp-config.json → .mcp.json} +13 -12
  2. package/.releaserc.json +47 -0
  3. package/README.md +6 -0
  4. package/package.json +1 -1
  5. package/.claude/claude-settings.json +0 -15
  6. package/.claude/commands/analysis/README.md +0 -9
  7. package/.claude/commands/automation/README.md +0 -9
  8. package/.claude/commands/github/README.md +0 -11
  9. package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
  10. package/.claude/commands/hooks/README.md +0 -11
  11. package/.claude/commands/monitoring/README.md +0 -9
  12. package/.claude/commands/optimization/README.md +0 -9
  13. package/.claude/commands/training/README.md +0 -9
  14. package/.claude/commands/workflows/README.md +0 -9
  15. package/.claude/config.json +0 -36
  16. package/.claude/helpers/github-setup.sh +0 -28
  17. package/.claude/helpers/quick-start.sh +0 -19
  18. package/.claude/helpers/setup-mcp.sh +0 -18
  19. package/.claude/settings.json +0 -114
  20. package/.claude/settings.local.json +0 -33
  21. package/.claude-flow/metrics/agent-metrics.json +0 -1
  22. package/.claude-flow/metrics/performance.json +0 -9
  23. package/.claude-flow/metrics/system-metrics.json +0 -15986
  24. package/.claude-flow/metrics/task-metrics.json +0 -10
  25. package/.roo/README.md +0 -402
  26. package/.roo/mcp-list.txt +0 -257
  27. package/.roo/mcp.json +0 -32
  28. package/.roo/workflows/basic-tdd.json +0 -32
  29. package/.roomodes +0 -201
  30. package/CLAUDE.md +0 -393
  31. package/bin/snow-flow.js +0 -3
  32. package/dist/cli.js.bak +0 -2052
  33. package/dist/config/snow-flow-config.d.ts +0 -1492
  34. package/dist/config/snow-flow-config.js +0 -938
  35. package/scripts/create-env.js +0 -91
  36. package/scripts/postinstall.js +0 -30
  37. package/scripts/register-mcp-servers.js +0 -210
  38. package/scripts/reset-mcp-servers.js +0 -246
  39. package/scripts/setup-mcp.js +0 -106
  40. package/scripts/update-version.js +0 -31
  41. package/src/agents/README.md +0 -192
  42. package/src/agents/base-agent.ts +0 -251
  43. package/src/agents/coordinator.ts +0 -971
  44. package/src/agents/index.ts +0 -18
  45. package/src/agents/queen-403-handler.ts +0 -230
  46. package/src/agents/queen-agent.ts +0 -1399
  47. package/src/agents/script-writer-agent.ts +0 -769
  48. package/src/agents/security-agent.ts +0 -726
  49. package/src/agents/widget-creator-agent.ts +0 -568
  50. package/src/api/error-handling.ts +0 -1758
  51. package/src/api/natural-language-mapper.ts +0 -630
  52. package/src/api/performance-optimizer.ts +0 -891
  53. package/src/api/transaction-manager.ts +0 -754
  54. package/src/cli/deploy-artifact.ts +0 -304
  55. package/src/cli/snow-flow-cli-integration.ts +0 -434
  56. package/src/cli.ts +0 -4455
  57. package/src/cli.ts.bak +0 -5616
  58. package/src/compliance/advanced-compliance-system.ts +0 -1268
  59. package/src/compliance/index.ts +0 -19
  60. package/src/config/snow-flow-config.ts +0 -1019
  61. package/src/documentation/index.ts +0 -16
  62. package/src/documentation/self-documenting-system.ts +0 -1421
  63. package/src/dynamic-version.ts +0 -44
  64. package/src/healing/index.ts +0 -20
  65. package/src/healing/self-healing-system.ts +0 -1435
  66. package/src/health/README.md +0 -161
  67. package/src/health/system-health.ts +0 -995
  68. package/src/index.ts +0 -60
  69. package/src/intelligence/acl-analyzer.ts +0 -377
  70. package/src/intelligence/auto-resolution-engine.ts +0 -643
  71. package/src/intelligence/gap-analysis-engine.ts +0 -488
  72. package/src/intelligence/manual-instructions-generator.ts +0 -744
  73. package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
  74. package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
  75. package/src/intelligence/performance-recommendations-engine.ts +0 -1223
  76. package/src/intelligence/requirements-analyzer.ts +0 -1148
  77. package/src/intelligence/task-analyzer.ts +0 -628
  78. package/src/managers/scope-manager.ts +0 -555
  79. package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
  80. package/src/mcp/base-mcp-server.ts +0 -660
  81. package/src/mcp/http-transport-wrapper.ts +0 -426
  82. package/src/mcp/service-discovery-client.ts +0 -312
  83. package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
  84. package/src/mcp/servicenow-automation-mcp.ts +0 -838
  85. package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
  86. package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
  87. package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
  88. package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
  89. package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
  90. package/src/mcp/servicenow-integration-mcp.ts +0 -819
  91. package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
  92. package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
  93. package/src/mcp/servicenow-mcp-server.ts +0 -728
  94. package/src/mcp/servicenow-memory-mcp.ts +0 -474
  95. package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
  96. package/src/mcp/servicenow-operations-mcp.ts +0 -3384
  97. package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
  98. package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
  99. package/src/mcp/servicenow-progressive-indexer.ts +0 -370
  100. package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
  101. package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
  102. package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
  103. package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
  104. package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
  105. package/src/mcp/servicenow-update-set-mcp.ts +0 -811
  106. package/src/mcp/shared/agent-context-provider.ts +0 -365
  107. package/src/mcp/shared/base-mcp-server.ts +0 -2463
  108. package/src/mcp/shared/mcp-memory-manager.ts +0 -540
  109. package/src/mcp/shared/mcp-resource-manager.ts +0 -367
  110. package/src/mcp/snow-flow-mcp.ts +0 -911
  111. package/src/mcp/start-all-mcp-servers.ts +0 -102
  112. package/src/mcp/start-servicenow-mcp.ts +0 -67
  113. package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
  114. package/src/monitoring/performance-tracker.ts +0 -777
  115. package/src/optimization/cost-optimization-engine.ts +0 -1125
  116. package/src/optimization/index.ts +0 -10
  117. package/src/queen/README.md +0 -403
  118. package/src/queen/agent-factory.ts +0 -574
  119. package/src/queen/index.ts +0 -94
  120. package/src/queen/mcp-execution-bridge.ts +0 -681
  121. package/src/queen/neural-learning.ts +0 -319
  122. package/src/queen/parallel-agent-engine.ts +0 -848
  123. package/src/queen/queen-memory-system.ts +0 -490
  124. package/src/queen/queen-memory.ts +0 -456
  125. package/src/queen/servicenow-queen.ts +0 -1029
  126. package/src/queen/types.ts +0 -87
  127. package/src/rollback/smart-rollback-system.ts +0 -866
  128. package/src/schemas/deployment.schema.json +0 -58
  129. package/src/schemas/flow.schema.json +0 -79
  130. package/src/schemas/widget.schema.json +0 -72
  131. package/src/snow-flow-system.ts +0 -541
  132. package/src/sparc/sparc-help.ts +0 -49
  133. package/src/sparc/team-sparc.ts +0 -88
  134. package/src/strategies/global-scope-strategy.ts +0 -736
  135. package/src/templates/base/application.template.json +0 -45
  136. package/src/templates/base/business_rule.template.json +0 -33
  137. package/src/templates/base/script_include.template.json +0 -18
  138. package/src/templates/base/table.template.json +0 -64
  139. package/src/templates/base/widget.template.json +0 -25
  140. package/src/templates/patterns/composite.incident-management.template.json +0 -140
  141. package/src/templates/patterns/widget.dashboard.template.json +0 -238
  142. package/src/templates/patterns/widget.datatable.template.json +0 -292
  143. package/src/testing/integration-test-suite.ts +0 -1276
  144. package/src/types/index.ts +0 -183
  145. package/src/types/neo4j-driver.d.ts +0 -23
  146. package/src/types/servicenow.types.ts +0 -307
  147. package/src/types/snow-flow.types.ts +0 -186
  148. package/src/types/todo.types.ts +0 -70
  149. package/src/utils/action-type-cache.ts +0 -286
  150. package/src/utils/agent-detector.ts +0 -573
  151. package/src/utils/artifact-tracker.ts +0 -379
  152. package/src/utils/dependency-detector.ts +0 -233
  153. package/src/utils/deployment-metadata-handler.ts +0 -518
  154. package/src/utils/error-recovery.ts +0 -680
  155. package/src/utils/logger.ts +0 -60
  156. package/src/utils/mcp-auth-middleware.ts +0 -262
  157. package/src/utils/mcp-config-manager.ts +0 -270
  158. package/src/utils/mcp-server-manager.ts +0 -446
  159. package/src/utils/mcp-tool-registry.ts +0 -298
  160. package/src/utils/migrate-snow-flow.ts +0 -98
  161. package/src/utils/oauth-html-templates.ts +0 -188
  162. package/src/utils/scope-utils.ts +0 -443
  163. package/src/utils/servicenow-client.ts +0 -3321
  164. package/src/utils/servicenow-id-generator.ts +0 -181
  165. package/src/utils/snow-memory-manager.ts +0 -605
  166. package/src/utils/snow-oauth.ts +0 -797
  167. package/src/utils/template-engine.ts +0 -463
  168. package/src/utils/theme-manager.ts +0 -295
  169. package/src/utils/unified-auth-store.ts +0 -222
  170. package/src/utils/update-set-importer.ts +0 -422
  171. package/src/utils/update-set-xml-packager.ts +0 -371
  172. package/src/utils/widget-template-generator.ts +0 -1744
  173. package/src/version.ts +0 -1950
@@ -1,695 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * servicenow-reporting-analytics MCP Server - REFACTORED
4
- * Uses BaseMCPServer to eliminate code duplication
5
- */
6
-
7
- import { BaseMCPServer, ToolResult } from './base-mcp-server.js';
8
- import { Tool } from '@modelcontextprotocol/sdk/types.js';
9
-
10
- export class ServiceNowReportingAnalyticsMCP extends BaseMCPServer {
11
- constructor() {
12
- super({
13
- name: 'servicenow-reporting-analytics',
14
- version: '2.0.0',
15
- description: 'Handles reports, dashboards, and analytics operations'
16
- });
17
- }
18
-
19
- protected setupTools(): void {
20
- // Tools are defined in getTools() method
21
- }
22
-
23
- protected getTools(): Tool[] {
24
- return [
25
- {
26
- name: 'snow_create_report',
27
- description: 'Create Report with dynamic table and field discovery - NO hardcoded values',
28
- inputSchema: {
29
- type: 'object',
30
- properties: {
31
- name: { type: 'string', description: 'Report name' },
32
- table: { type: 'string', description: 'Source table' },
33
- description: { type: 'string', description: 'Report description' },
34
- conditions: { type: 'string', description: 'Report conditions/filters' },
35
- fields: { type: 'array', description: 'Fields to include in report' },
36
- groupBy: { type: 'array', description: 'Group by fields' },
37
- aggregations: { type: 'array', description: 'Aggregation functions' },
38
- sortBy: { type: 'string', description: 'Sort field' },
39
- sortOrder: { type: 'string', description: 'Sort order (asc/desc)' },
40
- schedule: { type: 'string', description: 'Report schedule' },
41
- format: { type: 'string', description: 'Output format (PDF, Excel, CSV)' }
42
- },
43
- required: ['name', 'table', 'fields']
44
- }
45
- },
46
- {
47
- name: 'snow_create_dashboard',
48
- description: 'Create Dashboard with dynamic widget discovery',
49
- inputSchema: {
50
- type: 'object',
51
- properties: {
52
- name: { type: 'string', description: 'Dashboard name' },
53
- description: { type: 'string', description: 'Dashboard description' },
54
- layout: { type: 'string', description: 'Dashboard layout (grid, tabs, accordion)' },
55
- widgets: { type: 'array', description: 'Dashboard widgets configuration' },
56
- permissions: { type: 'array', description: 'User/role permissions' },
57
- refreshInterval: { type: 'number', description: 'Auto-refresh interval in minutes' },
58
- public: { type: 'boolean', description: 'Public dashboard' }
59
- },
60
- required: ['name', 'widgets']
61
- }
62
- },
63
- {
64
- name: 'snow_create_kpi',
65
- description: 'Create KPI with dynamic metric discovery',
66
- inputSchema: {
67
- type: 'object',
68
- properties: {
69
- name: { type: 'string', description: 'KPI name' },
70
- description: { type: 'string', description: 'KPI description' },
71
- table: { type: 'string', description: 'Source table' },
72
- metric: { type: 'string', description: 'Metric to measure' },
73
- aggregation: { type: 'string', description: 'Aggregation function (count, sum, avg, max, min)' },
74
- conditions: { type: 'string', description: 'KPI conditions/filters' },
75
- target: { type: 'number', description: 'Target value' },
76
- threshold: { type: 'object', description: 'Threshold configuration' },
77
- unit: { type: 'string', description: 'Unit of measurement' },
78
- frequency: { type: 'string', description: 'Update frequency' }
79
- },
80
- required: ['name', 'table', 'metric', 'aggregation']
81
- }
82
- },
83
- {
84
- name: 'snow_create_data_visualization',
85
- description: 'Create Data Visualization with dynamic chart discovery',
86
- inputSchema: {
87
- type: 'object',
88
- properties: {
89
- name: { type: 'string', description: 'Visualization name' },
90
- type: { type: 'string', description: 'Chart type (bar, line, pie, scatter, etc.)' },
91
- dataSource: { type: 'string', description: 'Data source (table or report)' },
92
- xAxis: { type: 'string', description: 'X-axis field' },
93
- yAxis: { type: 'string', description: 'Y-axis field' },
94
- series: { type: 'array', description: 'Data series configuration' },
95
- filters: { type: 'array', description: 'Chart filters' },
96
- colors: { type: 'array', description: 'Color palette' },
97
- interactive: { type: 'boolean', description: 'Interactive chart' }
98
- },
99
- required: ['name', 'type', 'dataSource']
100
- }
101
- },
102
- {
103
- name: 'snow_create_performance_analytics',
104
- description: 'Create Performance Analytics with dynamic metric discovery',
105
- inputSchema: {
106
- type: 'object',
107
- properties: {
108
- name: { type: 'string', description: 'Analytics name' },
109
- category: { type: 'string', description: 'Analytics category' },
110
- dataSource: { type: 'string', description: 'Data source table' },
111
- metrics: { type: 'array', description: 'Performance metrics to track' },
112
- dimensions: { type: 'array', description: 'Analysis dimensions' },
113
- timeframe: { type: 'string', description: 'Time period for _analysis' },
114
- benchmarks: { type: 'array', description: 'Performance benchmarks' },
115
- alerts: { type: 'array', description: 'Alert configurations' }
116
- },
117
- required: ['name', 'dataSource', 'metrics']
118
- }
119
- },
120
- {
121
- name: 'snow_create_scheduled_report',
122
- description: 'Create Scheduled Report with dynamic delivery discovery',
123
- inputSchema: {
124
- type: 'object',
125
- properties: {
126
- reportName: { type: 'string', description: 'Source report name' },
127
- schedule: { type: 'string', description: 'Schedule frequency' },
128
- recipients: { type: 'array', description: 'Email recipients' },
129
- format: { type: 'string', description: 'Report format (PDF, Excel, CSV)' },
130
- conditions: { type: 'string', description: 'Additional conditions' },
131
- subject: { type: 'string', description: 'Email subject' },
132
- message: { type: 'string', description: 'Email message' }
133
- },
134
- required: ['reportName', 'schedule', 'recipients']
135
- }
136
- },
137
- {
138
- name: 'snow_discover_reporting_tables',
139
- description: 'Discover all tables available for reporting',
140
- inputSchema: {
141
- type: 'object',
142
- properties: {
143
- category: { type: 'string', description: 'Table category filter' },
144
- hasData: { type: 'boolean', description: 'Only tables with data' }
145
- }
146
- }
147
- },
148
- {
149
- name: 'snow_discover_report_fields',
150
- description: 'Discover available fields for reporting on a table',
151
- inputSchema: {
152
- type: 'object',
153
- properties: {
154
- table: { type: 'string', description: 'Table name to analyze' },
155
- fieldType: { type: 'string', description: 'Filter by field type' }
156
- },
157
- required: ['table']
158
- }
159
- },
160
- {
161
- name: 'snow_analyze_data_quality',
162
- description: 'Analyze data quality for reporting',
163
- inputSchema: {
164
- type: 'object',
165
- properties: {
166
- table: { type: 'string', description: 'Table to analyze' },
167
- fields: { type: 'array', description: 'Specific fields to analyze' },
168
- checkCompleteness: { type: 'boolean', description: 'Check data completeness' },
169
- checkConsistency: { type: 'boolean', description: 'Check data consistency' },
170
- checkAccuracy: { type: 'boolean', description: 'Check data accuracy' }
171
- },
172
- required: ['table']
173
- }
174
- },
175
- {
176
- name: 'snow_generate_insights',
177
- description: 'Generate data insights and recommendations',
178
- inputSchema: {
179
- type: 'object',
180
- properties: {
181
- table: { type: 'string', description: 'Table to analyze' },
182
- analysisType: { type: 'string', description: 'Analysis type (trends, patterns, anomalies)' },
183
- timeframe: { type: 'string', description: 'Time period for _analysis' },
184
- generateRecommendations: { type: 'boolean', description: 'Generate recommendations' }
185
- },
186
- required: ['table']
187
- }
188
- },
189
- {
190
- name: 'snow_export_report_data',
191
- description: 'Export report data in various formats',
192
- inputSchema: {
193
- type: 'object',
194
- properties: {
195
- reportName: { type: 'string', description: 'Report name to export' },
196
- format: { type: 'string', description: 'Export format (CSV, Excel, JSON, XML)' },
197
- includeHeaders: { type: 'boolean', description: 'Include column headers' },
198
- maxRows: { type: 'number', description: 'Maximum rows to export' }
199
- },
200
- required: ['reportName', 'format']
201
- }
202
- }
203
- ];
204
- }
205
-
206
- protected async executeTool(name: string, args: any): Promise<ToolResult> {
207
- const startTime = Date.now();
208
-
209
- switch (name) {
210
- case 'snow_create_report':
211
- return await this.handleSnowCreateReport(args);
212
- case 'snow_create_dashboard':
213
- return await this.handleSnowCreateDashboard(args);
214
- case 'snow_create_kpi':
215
- return await this.handleSnowCreateKpi(args);
216
- case 'snow_create_data_visualization':
217
- return await this.handleSnowCreateDataVisualization(args);
218
- case 'snow_create_performance_analytics':
219
- return await this.handleSnowCreatePerformanceAnalytics(args);
220
- case 'snow_create_scheduled_report':
221
- return await this.handleSnowCreateScheduledReport(args);
222
- case 'snow_discover_reporting_tables':
223
- return await this.handleSnowDiscoverReportingTables(args);
224
- case 'snow_discover_report_fields':
225
- return await this.handleSnowDiscoverReportFields(args);
226
- case 'snow_analyze_data_quality':
227
- return await this.handleSnowAnalyzeDataQuality(args);
228
- case 'snow_generate_insights':
229
- return await this.handleSnowGenerateInsights(args);
230
- case 'snow_export_report_data':
231
- return await this.handleSnowExportReportData(args);
232
- default:
233
- return {
234
- success: false,
235
- error: `Unknown tool: ${name}`
236
- };
237
- }
238
- }
239
-
240
- // Tool handlers
241
- private async handleSnowCreateReport(args: any): Promise<ToolResult> {
242
- const startTime = Date.now();
243
- try {
244
- const reportData = {
245
- name: args.name,
246
- table: args.table,
247
- description: args.description || '',
248
- filter: args.conditions || '',
249
- fields: args.fields.join(','),
250
- group_by: args.groupBy ? args.groupBy.join(',') : '',
251
- aggregation: args.aggregations ? args.aggregations.join(',') : '',
252
- sort_by: args.sortBy || '',
253
- sort_order: args.sortOrder || 'asc',
254
- schedule: args.schedule || '',
255
- format: args.format || 'PDF',
256
- active: true
257
- };
258
-
259
- const result = await this.client.createRecord('sys_report', reportData);
260
-
261
- return {
262
- success: result.success,
263
- result: result.result,
264
- error: result.success ? undefined : 'Failed to create report',
265
- executionTime: Date.now() - startTime
266
- };
267
- } catch (error) {
268
- return {
269
- success: false,
270
- error: error instanceof Error ? error.message : 'Failed to create report',
271
- executionTime: Date.now() - startTime
272
- };
273
- }
274
- }
275
-
276
- private async handleSnowCreateDashboard(args: any): Promise<ToolResult> {
277
- const startTime = Date.now();
278
- try {
279
- const dashboardData = {
280
- name: args.name,
281
- description: args.description || '',
282
- layout: args.layout || 'grid',
283
- refresh_interval: args.refreshInterval || 0,
284
- is_public: args.public || false,
285
- active: true
286
- };
287
-
288
- // Create dashboard
289
- const dashboardResult = await this.client.createRecord('sys_dashboard', dashboardData);
290
-
291
- if (dashboardResult.success && args.widgets) {
292
- // Create widgets for the dashboard
293
- const dashboardId = Array.isArray(dashboardResult.result)
294
- ? dashboardResult.result[0]?.sys_id
295
- : (dashboardResult.result as any)?.sys_id || 'unknown';
296
- for (const widget of args.widgets) {
297
- await this.createDashboardWidget(dashboardId, widget);
298
- }
299
- }
300
-
301
- return {
302
- success: dashboardResult.success,
303
- result: dashboardResult.result,
304
- error: dashboardResult.success ? undefined : 'Failed to create dashboard',
305
- executionTime: Date.now() - startTime
306
- };
307
- } catch (error) {
308
- return {
309
- success: false,
310
- error: error instanceof Error ? error.message : 'Failed to create dashboard',
311
- executionTime: Date.now() - startTime
312
- };
313
- }
314
- }
315
-
316
- private async handleSnowCreateKpi(args: any): Promise<ToolResult> {
317
- const startTime = Date.now();
318
- try {
319
- const kpiData = {
320
- name: args.name,
321
- description: args.description || '',
322
- table: args.table,
323
- field: args.metric,
324
- aggregate: args.aggregation,
325
- conditions: args.conditions || '',
326
- target_value: args.target || 0,
327
- unit: args.unit || '',
328
- frequency: args.frequency || 'daily',
329
- active: true
330
- };
331
-
332
- const result = await this.client.createRecord('sysauto_indicator', kpiData);
333
-
334
- return {
335
- success: result.success,
336
- result: result.result,
337
- error: result.success ? undefined : 'Failed to create KPI',
338
- executionTime: Date.now() - startTime
339
- };
340
- } catch (error) {
341
- return {
342
- success: false,
343
- error: error instanceof Error ? error.message : 'Failed to create KPI',
344
- executionTime: Date.now() - startTime
345
- };
346
- }
347
- }
348
-
349
- private async handleSnowCreateDataVisualization(args: any): Promise<ToolResult> {
350
- const startTime = Date.now();
351
- try {
352
- const vizData = {
353
- name: args.name,
354
- type: args.type,
355
- data_source: args.dataSource,
356
- x_axis: args.xAxis || '',
357
- y_axis: args.yAxis || '',
358
- series: args.series ? JSON.stringify(args.series) : '',
359
- filters: args.filters ? JSON.stringify(args.filters) : '',
360
- colors: args.colors ? args.colors.join(',') : '',
361
- interactive: args.interactive !== false,
362
- active: true
363
- };
364
-
365
- const result = await this.client.createRecord('sys_visualization', vizData);
366
-
367
- return {
368
- success: result.success,
369
- result: result.result,
370
- error: result.success ? undefined : 'Failed to create data visualization',
371
- executionTime: Date.now() - startTime
372
- };
373
- } catch (error) {
374
- return {
375
- success: false,
376
- error: error instanceof Error ? error.message : 'Failed to create data visualization',
377
- executionTime: Date.now() - startTime
378
- };
379
- }
380
- }
381
-
382
- private async handleSnowCreatePerformanceAnalytics(args: any): Promise<ToolResult> {
383
- const startTime = Date.now();
384
- try {
385
- const analyticsData = {
386
- name: args.name,
387
- category: args.category || 'general',
388
- table: args.dataSource,
389
- metrics: args.metrics.join(','),
390
- dimensions: args.dimensions ? args.dimensions.join(',') : '',
391
- timeframe: args.timeframe || 'monthly',
392
- benchmarks: args.benchmarks ? JSON.stringify(args.benchmarks) : '',
393
- alerts: args.alerts ? JSON.stringify(args.alerts) : '',
394
- active: true
395
- };
396
-
397
- const result = await this.client.createRecord('pa_cubes', analyticsData);
398
-
399
- return {
400
- success: result.success,
401
- result: result.result,
402
- error: result.success ? undefined : 'Failed to create performance analytics',
403
- executionTime: Date.now() - startTime
404
- };
405
- } catch (error) {
406
- return {
407
- success: false,
408
- error: error instanceof Error ? error.message : 'Failed to create performance analytics',
409
- executionTime: Date.now() - startTime
410
- };
411
- }
412
- }
413
-
414
- private async handleSnowCreateScheduledReport(args: any): Promise<ToolResult> {
415
- const startTime = Date.now();
416
- try {
417
- // Find the source report
418
- const reportResponse = await this.client.searchRecords(
419
- 'sys_report',
420
- `name=${args.reportName}`,
421
- 1
422
- );
423
-
424
- if (!reportResponse.success || !reportResponse.data?.result?.length) {
425
- throw new Error(`Report not found: ${args.reportName}`);
426
- }
427
-
428
- const reportId = reportResponse.data.result[0].sys_id;
429
-
430
- const scheduleData = {
431
- report: reportId,
432
- schedule_type: args.schedule,
433
- recipients: args.recipients.join(','),
434
- format: args.format || 'PDF',
435
- conditions: args.conditions || '',
436
- subject: args.subject || `Scheduled Report: ${args.reportName}`,
437
- message: args.message || 'Please find the attached report.',
438
- active: true
439
- };
440
-
441
- const result = await this.client.createRecord('sys_report_schedule', scheduleData);
442
-
443
- return {
444
- success: result.success,
445
- result: result.result,
446
- error: result.success ? undefined : 'Failed to create scheduled report',
447
- executionTime: Date.now() - startTime
448
- };
449
- } catch (error) {
450
- return {
451
- success: false,
452
- error: error instanceof Error ? error.message : 'Failed to create scheduled report',
453
- executionTime: Date.now() - startTime
454
- };
455
- }
456
- }
457
-
458
- private async handleSnowDiscoverReportingTables(args: any): Promise<ToolResult> {
459
- const startTime = Date.now();
460
- try {
461
- const tables: any[] = [];
462
-
463
- // Build query
464
- let query = '';
465
- if (args.hasData) {
466
- query = 'row_count>0';
467
- }
468
-
469
- // Discover tables
470
- const tableResponse = await this.client.searchRecords('sys_db_object', query, 100);
471
- if (tableResponse.success && tableResponse.data) {
472
- tables.push(...tableResponse.data.result.map((table: any) => ({
473
- name: table.name,
474
- label: table.label,
475
- row_count: table.row_count,
476
- category: table.super_class ? 'extended' : 'base',
477
- accessible: table.accessible
478
- })));
479
- }
480
-
481
- // Filter by category if specified
482
- const filteredTables = args.category
483
- ? tables.filter(t => t.category === args.category)
484
- : tables;
485
-
486
- return {
487
- success: true,
488
- result: { tables: filteredTables },
489
- executionTime: Date.now() - startTime
490
- };
491
- } catch (error) {
492
- return {
493
- success: false,
494
- error: error instanceof Error ? error.message : 'Failed to discover reporting tables',
495
- executionTime: Date.now() - startTime
496
- };
497
- }
498
- }
499
-
500
- private async handleSnowDiscoverReportFields(args: any): Promise<ToolResult> {
501
- const startTime = Date.now();
502
- try {
503
- const fields: any[] = [];
504
-
505
- // Get fields for the table
506
- const fieldResponse = await this.client.searchRecords(
507
- 'sys_dictionary',
508
- `name=${args.table}^element!=NULL`,
509
- 100
510
- );
511
-
512
- if (fieldResponse.success && fieldResponse.data) {
513
- fields.push(...fieldResponse.data.result.map((field: any) => ({
514
- name: field.element,
515
- label: field.column_label,
516
- type: field.internal_type,
517
- reference: field.reference,
518
- choice: field.choice,
519
- max_length: field.max_length,
520
- mandatory: field.mandatory === 'true',
521
- calculated: field.virtual === 'true',
522
- reportable: field.attributes?.includes('report') !== false
523
- })));
524
- }
525
-
526
- // Filter by field type if specified
527
- const filteredFields = args.fieldType
528
- ? fields.filter(f => f.type === args.fieldType)
529
- : fields;
530
-
531
- return {
532
- success: true,
533
- result: { fields: filteredFields },
534
- executionTime: Date.now() - startTime
535
- };
536
- } catch (error) {
537
- return {
538
- success: false,
539
- error: error instanceof Error ? error.message : 'Failed to discover report fields',
540
- executionTime: Date.now() - startTime
541
- };
542
- }
543
- }
544
-
545
- private async handleSnowAnalyzeDataQuality(args: any): Promise<ToolResult> {
546
- const startTime = Date.now();
547
- try {
548
- // This would be a complex _analysis in reality
549
- // For now, simulate data quality analysis
550
- const _analysis = {
551
- table: args.table,
552
- total_records: Math.floor(Math.random() * 10000) + 1000,
553
- fields_analyzed: args.fields?.length || 'all',
554
- completeness: args.checkCompleteness ? {
555
- score: 94.5,
556
- missing_values: 234,
557
- null_fields: ['description', 'notes']
558
- } : null,
559
- consistency: args.checkConsistency ? {
560
- score: 87.3,
561
- inconsistent_formats: 45,
562
- duplicate_records: 12
563
- } : null,
564
- accuracy: args.checkAccuracy ? {
565
- score: 91.2,
566
- validation_errors: 78,
567
- outliers: 23
568
- } : null,
569
- overall_quality_score: 91.0,
570
- recommendations: [
571
- 'Standardize date formats across all fields',
572
- 'Implement validation rules for email fields',
573
- 'Remove duplicate entries in customer table'
574
- ]
575
- };
576
-
577
- return {
578
- success: true,
579
- result: _analysis,
580
- executionTime: Date.now() - startTime
581
- };
582
- } catch (error) {
583
- return {
584
- success: false,
585
- error: error instanceof Error ? error.message : 'Failed to analyze data quality',
586
- executionTime: Date.now() - startTime
587
- };
588
- }
589
- }
590
-
591
- private async handleSnowGenerateInsights(args: any): Promise<ToolResult> {
592
- const startTime = Date.now();
593
- try {
594
- // Simulate insight generation
595
- const insights = {
596
- table: args.table,
597
- analysis_type: args.analysisType || 'trends',
598
- timeframe: args.timeframe || 'last_30_days',
599
- key_findings: [
600
- 'Incident volume increased by 23% in the last week',
601
- 'Average resolution time improved by 15%',
602
- 'Peak incident hours are between 9 AM and 11 AM'
603
- ],
604
- patterns: [
605
- { type: 'seasonal', description: 'Higher volume on Mondays' },
606
- { type: 'correlation', description: 'Priority 1 incidents correlate with system outages' }
607
- ],
608
- anomalies: [
609
- { date: '2024-01-15', description: 'Unusual spike in network incidents' }
610
- ],
611
- recommendations: args.generateRecommendations ? [
612
- 'Increase staffing during peak hours',
613
- 'Implement proactive monitoring for high-risk systems',
614
- 'Create automation for common incident types'
615
- ] : []
616
- };
617
-
618
- return {
619
- success: true,
620
- result: insights,
621
- executionTime: Date.now() - startTime
622
- };
623
- } catch (error) {
624
- return {
625
- success: false,
626
- error: error instanceof Error ? error.message : 'Failed to generate insights',
627
- executionTime: Date.now() - startTime
628
- };
629
- }
630
- }
631
-
632
- private async handleSnowExportReportData(args: any): Promise<ToolResult> {
633
- const startTime = Date.now();
634
- try {
635
- // Find the report
636
- const reportResponse = await this.client.searchRecords(
637
- 'sys_report',
638
- `name=${args.reportName}`,
639
- 1
640
- );
641
-
642
- if (!reportResponse.success || !reportResponse.data?.result?.length) {
643
- throw new Error(`Report not found: ${args.reportName}`);
644
- }
645
-
646
- const report = reportResponse.data.result[0];
647
-
648
- // Simulate export
649
- const exportResult = {
650
- report_name: report.name,
651
- export_format: args.format,
652
- include_headers: args.includeHeaders !== false,
653
- max_rows: args.maxRows || 10000,
654
- export_date: new Date().toISOString(),
655
- file_size: Math.floor(Math.random() * 5000) + 1000,
656
- download_url: `/api/now/export/report/${report.sys_id}/${args.format.toLowerCase()}`,
657
- expires_in: '24 hours'
658
- };
659
-
660
- return {
661
- success: true,
662
- result: exportResult,
663
- executionTime: Date.now() - startTime
664
- };
665
- } catch (error) {
666
- return {
667
- success: false,
668
- error: error instanceof Error ? error.message : 'Failed to export report data',
669
- executionTime: Date.now() - startTime
670
- };
671
- }
672
- }
673
-
674
- // Helper methods
675
- private async createDashboardWidget(dashboardId: string, widget: any): Promise<void> {
676
- const widgetData = {
677
- dashboard: dashboardId,
678
- name: widget.name,
679
- type: widget.type || 'report',
680
- data_source: widget.dataSource,
681
- configuration: JSON.stringify(widget.configuration || {}),
682
- position: widget.position || 0,
683
- size_x: widget.width || 4,
684
- size_y: widget.height || 3
685
- };
686
-
687
- await this.client.createRecord('sys_dashboard_widget', widgetData);
688
- }
689
- }
690
-
691
- // Create and run the server
692
- if (require.main === module) {
693
- const server = new ServiceNowReportingAnalyticsMCP();
694
- server.start().catch(console.error);
695
- }