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.
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 +48 -1
  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,611 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * servicenow-platform-development 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
- interface DynamicTableInfo {
11
- name: string;
12
- label: string;
13
- fields: Array<{
14
- name: string;
15
- type: string;
16
- label: string;
17
- mandatory: boolean;
18
- display: boolean;
19
- }>;
20
- }
21
-
22
- export class ServiceNowPlatformDevelopmentMCP extends BaseMCPServer {
23
- private tableCache: Map<string, DynamicTableInfo> = new Map();
24
-
25
- constructor() {
26
- super({
27
- name: 'servicenow-platform-development',
28
- version: '2.0.0',
29
- description: 'Handles core platform development artifacts with full dynamic discovery'
30
- });
31
- }
32
-
33
- protected setupTools(): void {
34
- // Tools are defined in getTools() method
35
- }
36
-
37
- protected getTools(): Tool[] {
38
- return [
39
- {
40
- name: 'snow_create_ui_page',
41
- description: 'Create UI Pages dynamically with full field discovery - NO hardcoded values',
42
- inputSchema: {
43
- type: 'object',
44
- properties: {
45
- name: { type: 'string', description: 'UI Page name' },
46
- title: { type: 'string', description: 'Page title' },
47
- html: { type: 'string', description: 'HTML content' },
48
- processingScript: { type: 'string', description: 'Server-side processing script' },
49
- clientScript: { type: 'string', description: 'Client-side script' },
50
- css: { type: 'string', description: 'CSS styles' },
51
- category: { type: 'string', description: 'Page category' }
52
- },
53
- required: ['name', 'title', 'html']
54
- }
55
- },
56
- {
57
- name: 'snow_create_script_include',
58
- description: 'Create Script Includes with dynamic table discovery - NO hardcoded values',
59
- inputSchema: {
60
- type: 'object',
61
- properties: {
62
- name: { type: 'string', description: 'Script Include name' },
63
- script: { type: 'string', description: 'JavaScript code' },
64
- description: { type: 'string', description: 'Description of functionality' },
65
- clientCallable: { type: 'boolean', description: 'Can be called from client' },
66
- apiName: { type: 'string', description: 'API name for external calls' }
67
- },
68
- required: ['name', 'script']
69
- }
70
- },
71
- {
72
- name: 'snow_create_business_rule',
73
- description: 'Create Business Rules with dynamic table and field discovery - NO hardcoded values',
74
- inputSchema: {
75
- type: 'object',
76
- properties: {
77
- name: { type: 'string', description: 'Business Rule name' },
78
- tableName: { type: 'string', description: 'Target table name or sys_id' },
79
- script: { type: 'string', description: 'JavaScript code' },
80
- when: { type: 'string', description: 'When to execute: before, after, async, display' },
81
- condition: { type: 'string', description: 'Condition script' },
82
- description: { type: 'string', description: 'Rule description' }
83
- },
84
- required: ['name', 'tableName', 'script', 'when']
85
- }
86
- },
87
- {
88
- name: 'snow_create_client_script',
89
- description: 'Create Client Scripts with dynamic form discovery - NO hardcoded values',
90
- inputSchema: {
91
- type: 'object',
92
- properties: {
93
- name: { type: 'string', description: 'Client Script name' },
94
- tableName: { type: 'string', description: 'Target table name or sys_id' },
95
- script: { type: 'string', description: 'JavaScript code' },
96
- type: { type: 'string', description: 'Script type: onLoad, onChange, onSubmit, onCellEdit' },
97
- fieldName: { type: 'string', description: 'Field name for onChange scripts' },
98
- condition: { type: 'string', description: 'Condition script' },
99
- description: { type: 'string', description: 'Script description' }
100
- },
101
- required: ['name', 'tableName', 'script', 'type']
102
- }
103
- },
104
- {
105
- name: 'snow_create_ui_policy',
106
- description: 'Create UI Policies with dynamic field discovery - NO hardcoded values',
107
- inputSchema: {
108
- type: 'object',
109
- properties: {
110
- name: { type: 'string', description: 'UI Policy name' },
111
- tableName: { type: 'string', description: 'Target table name or sys_id' },
112
- condition: { type: 'string', description: 'Condition script' },
113
- description: { type: 'string', description: 'Policy description' },
114
- runScripts: { type: 'boolean', description: 'Run scripts when policy applies' },
115
- reverseWhenFalse: { type: 'boolean', description: 'Reverse actions when condition is false' }
116
- },
117
- required: ['name', 'tableName', 'condition']
118
- }
119
- },
120
- {
121
- name: 'snow_create_ui_action',
122
- description: 'Create UI Actions with dynamic form discovery - NO hardcoded values',
123
- inputSchema: {
124
- type: 'object',
125
- properties: {
126
- name: { type: 'string', description: 'UI Action name' },
127
- tableName: { type: 'string', description: 'Target table name or sys_id' },
128
- script: { type: 'string', description: 'JavaScript code' },
129
- condition: { type: 'string', description: 'Condition script' },
130
- actionName: { type: 'string', description: 'Action name for forms' },
131
- formButton: { type: 'boolean', description: 'Show as form button' },
132
- listButton: { type: 'boolean', description: 'Show as list button' },
133
- description: { type: 'string', description: 'Action description' }
134
- },
135
- required: ['name', 'tableName', 'script']
136
- }
137
- },
138
- {
139
- name: 'snow_discover_platform_tables',
140
- description: 'Discover all available platform development tables dynamically',
141
- inputSchema: {
142
- type: 'object',
143
- properties: {
144
- category: { type: 'string', description: 'Filter by category: ui, script, policy, action, all' }
145
- }
146
- }
147
- },
148
- {
149
- name: 'snow_discover_table_fields',
150
- description: 'Discover all fields for a specific table dynamically',
151
- inputSchema: {
152
- type: 'object',
153
- properties: {
154
- tableName: { type: 'string', description: 'Table name to discover fields for' }
155
- },
156
- required: ['tableName']
157
- }
158
- },
159
- {
160
- name: 'snow_table_schema_discovery',
161
- description: 'Comprehensive table schema discovery - structure, relationships, indexes, constraints',
162
- inputSchema: {
163
- type: 'object',
164
- properties: {
165
- tableName: { type: 'string', description: 'Table name to analyze' },
166
- includeRelated: { type: 'boolean', description: 'Include related table information' },
167
- includeIndexes: { type: 'boolean', description: 'Include index information' },
168
- includeExtensions: { type: 'boolean', description: 'Include table extensions/hierarchy' },
169
- maxDepth: { type: 'number', description: 'Max depth for relationship discovery (default: 2)' }
170
- },
171
- required: ['tableName']
172
- }
173
- }
174
- ];
175
- }
176
-
177
- protected async executeTool(name: string, args: any): Promise<ToolResult> {
178
- const startTime = Date.now();
179
-
180
- switch (name) {
181
- case 'snow_create_ui_page':
182
- return await this.handleSnowCreateUiPage(args);
183
- case 'snow_create_script_include':
184
- return await this.handleSnowCreateScriptInclude(args);
185
- case 'snow_create_business_rule':
186
- return await this.handleSnowCreateBusinessRule(args);
187
- case 'snow_create_client_script':
188
- return await this.handleSnowCreateClientScript(args);
189
- case 'snow_create_ui_policy':
190
- return await this.handleSnowCreateUiPolicy(args);
191
- case 'snow_create_ui_action':
192
- return await this.handleSnowCreateUiAction(args);
193
- case 'snow_discover_platform_tables':
194
- return await this.handleSnowDiscoverPlatformTables(args);
195
- case 'snow_discover_table_fields':
196
- return await this.handleSnowDiscoverTableFields(args);
197
- case 'snow_table_schema_discovery':
198
- return await this.handleSnowTableSchemaDiscovery(args);
199
- default:
200
- return {
201
- success: false,
202
- error: `Unknown tool: ${name}`
203
- };
204
- }
205
- }
206
-
207
- // Tool handlers
208
- private async handleSnowCreateUiPage(args: any): Promise<ToolResult> {
209
- try {
210
- const pageData = {
211
- name: args.name,
212
- title: args.title,
213
- html: args.html,
214
- processing_script: args.processingScript,
215
- client_script: args.clientScript,
216
- css: args.css,
217
- category: args.category || 'general',
218
- active: true
219
- };
220
-
221
- const result = await this.client.createRecord('sys_ui_page', pageData);
222
-
223
- return {
224
- success: result.success,
225
- result: result.result,
226
- error: result.success ? undefined : 'Failed to create UI page',
227
- executionTime: Date.now() - Date.now()
228
- };
229
- } catch (error) {
230
- return {
231
- success: false,
232
- error: error instanceof Error ? error.message : 'Failed to create UI page',
233
- executionTime: Date.now() - Date.now()
234
- };
235
- }
236
- }
237
-
238
- private async handleSnowCreateScriptInclude(args: any): Promise<ToolResult> {
239
- try {
240
- const scriptData = {
241
- name: args.name,
242
- script: args.script,
243
- description: args.description,
244
- client_callable: args.clientCallable || false,
245
- api_name: args.apiName || args.name,
246
- active: true
247
- };
248
-
249
- const result = await this.client.createRecord('sys_script_include', scriptData);
250
-
251
- return {
252
- success: result.success,
253
- result: result.result,
254
- error: result.success ? undefined : 'Failed to create script include',
255
- executionTime: Date.now() - Date.now()
256
- };
257
- } catch (error) {
258
- return {
259
- success: false,
260
- error: error instanceof Error ? error.message : 'Failed to create script include',
261
- executionTime: Date.now() - Date.now()
262
- };
263
- }
264
- }
265
-
266
- private async handleSnowCreateBusinessRule(args: any): Promise<ToolResult> {
267
- try {
268
- // Resolve table name
269
- const tableInfo = await this.getTableInfo(args.tableName);
270
- if (!tableInfo) {
271
- throw new Error(`Table not found: ${args.tableName}`);
272
- }
273
-
274
- const ruleData = {
275
- name: args.name,
276
- collection: tableInfo.name,
277
- script: args.script,
278
- when: args.when,
279
- condition: args.condition || '',
280
- description: args.description || '',
281
- active: true,
282
- order: 100
283
- };
284
-
285
- const result = await this.client.createRecord('sys_script', ruleData);
286
-
287
- return {
288
- success: result.success,
289
- result: result.result,
290
- error: result.success ? undefined : 'Failed to create business rule',
291
- executionTime: Date.now() - Date.now()
292
- };
293
- } catch (error) {
294
- return {
295
- success: false,
296
- error: error instanceof Error ? error.message : 'Failed to create business rule',
297
- executionTime: Date.now() - Date.now()
298
- };
299
- }
300
- }
301
-
302
- private async handleSnowCreateClientScript(args: any): Promise<ToolResult> {
303
- try {
304
- // Resolve table name
305
- const tableInfo = await this.getTableInfo(args.tableName);
306
- if (!tableInfo) {
307
- throw new Error(`Table not found: ${args.tableName}`);
308
- }
309
-
310
- const scriptData = {
311
- name: args.name,
312
- table: tableInfo.name,
313
- script: args.script,
314
- type: args.type,
315
- field: args.fieldName || '',
316
- condition: args.condition || '',
317
- description: args.description || '',
318
- active: true
319
- };
320
-
321
- const result = await this.client.createRecord('sys_script_client', scriptData);
322
-
323
- return {
324
- success: result.success,
325
- result: result.result,
326
- error: result.success ? undefined : 'Failed to create client script',
327
- executionTime: Date.now() - Date.now()
328
- };
329
- } catch (error) {
330
- return {
331
- success: false,
332
- error: error instanceof Error ? error.message : 'Failed to create client script',
333
- executionTime: Date.now() - Date.now()
334
- };
335
- }
336
- }
337
-
338
- private async handleSnowCreateUiPolicy(args: any): Promise<ToolResult> {
339
- try {
340
- // Resolve table name
341
- const tableInfo = await this.getTableInfo(args.tableName);
342
- if (!tableInfo) {
343
- throw new Error(`Table not found: ${args.tableName}`);
344
- }
345
-
346
- const policyData = {
347
- name: args.name,
348
- table: tableInfo.name,
349
- conditions: args.condition,
350
- short_description: args.description || '',
351
- run_scripts: args.runScripts || false,
352
- reverse_if_false: args.reverseWhenFalse || false,
353
- active: true
354
- };
355
-
356
- const result = await this.client.createRecord('sys_ui_policy', policyData);
357
-
358
- return {
359
- success: result.success,
360
- result: result.result,
361
- error: result.success ? undefined : 'Failed to create UI policy',
362
- executionTime: Date.now() - Date.now()
363
- };
364
- } catch (error) {
365
- return {
366
- success: false,
367
- error: error instanceof Error ? error.message : 'Failed to create UI policy',
368
- executionTime: Date.now() - Date.now()
369
- };
370
- }
371
- }
372
-
373
- private async handleSnowCreateUiAction(args: any): Promise<ToolResult> {
374
- try {
375
- // Resolve table name
376
- const tableInfo = await this.getTableInfo(args.tableName);
377
- if (!tableInfo) {
378
- throw new Error(`Table not found: ${args.tableName}`);
379
- }
380
-
381
- const actionData = {
382
- name: args.name,
383
- table: tableInfo.name,
384
- script: args.script,
385
- condition: args.condition || '',
386
- action_name: args.actionName || args.name,
387
- form_button: args.formButton !== false,
388
- list_button: args.listButton || false,
389
- comments: args.description || '',
390
- active: true
391
- };
392
-
393
- const result = await this.client.createRecord('sys_ui_action', actionData);
394
-
395
- return {
396
- success: result.success,
397
- result: result.result,
398
- error: result.success ? undefined : 'Failed to create UI action',
399
- executionTime: Date.now() - Date.now()
400
- };
401
- } catch (error) {
402
- return {
403
- success: false,
404
- error: error instanceof Error ? error.message : 'Failed to create UI action',
405
- executionTime: Date.now() - Date.now()
406
- };
407
- }
408
- }
409
-
410
- private async handleSnowDiscoverPlatformTables(args: any): Promise<ToolResult> {
411
- try {
412
- this.logger.info('Discovering platform development tables...');
413
-
414
- // Define table categories
415
- const tableQueries = [
416
- { category: 'ui', query: 'nameSTARTSWITHsys_ui^ORnameSTARTSWITHsp_' },
417
- { category: 'script', query: 'nameSTARTSWITHsys_script^ORnameSTARTSWITHsys_processor' },
418
- { category: 'policy', query: 'nameSTARTSWITHsys_ui_policy^ORnameSTARTSWITHsys_ui_action' },
419
- { category: 'security', query: 'nameSTARTSWITHsys_security^ORnameSTARTSWITHsys_user' },
420
- { category: 'system', query: 'nameSTARTSWITHsys_dictionary^ORnameSTARTSWITHsys_choice' }
421
- ];
422
-
423
- const category = args?.category || 'all';
424
- const discoveredTables: Array<{category: string, tables: any[]}> = [];
425
-
426
- for (const tableQuery of tableQueries) {
427
- if (category === 'all' || category === tableQuery.category) {
428
- const tablesResponse = await this.client.searchRecords(
429
- 'sys_db_object',
430
- tableQuery.query,
431
- 50
432
- );
433
-
434
- if (tablesResponse.success && tablesResponse.data) {
435
- discoveredTables.push({
436
- category: tableQuery.category,
437
- tables: tablesResponse.data.result.map((table: any) => ({
438
- name: table.name,
439
- label: table.label,
440
- super_class: table.super_class,
441
- is_extendable: table.is_extendable,
442
- sys_id: table.sys_id
443
- }))
444
- });
445
- }
446
- }
447
- }
448
-
449
- return {
450
- success: true,
451
- result: { discoveredTables },
452
- executionTime: Date.now() - Date.now()
453
- };
454
- } catch (error) {
455
- return {
456
- success: false,
457
- error: error instanceof Error ? error.message : 'Failed to discover platform tables',
458
- executionTime: Date.now() - Date.now()
459
- };
460
- }
461
- }
462
-
463
- private async handleSnowDiscoverTableFields(args: any): Promise<ToolResult> {
464
- try {
465
- const tableName = args.tableName;
466
- this.logger.info(`Discovering fields for table: ${tableName}`);
467
-
468
- // Resolve table name
469
- const tableInfo = await this.getTableInfo(tableName);
470
- if (!tableInfo) {
471
- throw new Error(`Table not found: ${tableName}`);
472
- }
473
-
474
- // Get all fields for this table
475
- const fieldsResponse = await this.client.searchRecords(
476
- 'sys_dictionary',
477
- `nameSTARTSWITH${tableInfo.name}^element!=NULL`,
478
- 100
479
- );
480
-
481
- if (!fieldsResponse.success || !fieldsResponse.data) {
482
- throw new Error(`Failed to get fields for table: ${tableName}`);
483
- }
484
-
485
- const fields = fieldsResponse.data.result.map((field: any) => ({
486
- name: field.element,
487
- type: field.internal_type,
488
- label: field.column_label,
489
- mandatory: field.mandatory === 'true',
490
- display: field.display === 'true',
491
- max_length: field.max_length,
492
- reference: field.reference,
493
- choice: field.choice
494
- }));
495
-
496
- // Cache the table info
497
- this.tableCache.set(tableName, {
498
- name: tableInfo.name,
499
- label: tableInfo.label,
500
- fields: fields
501
- });
502
-
503
- return {
504
- success: true,
505
- result: { table: tableInfo, fields },
506
- executionTime: Date.now() - Date.now()
507
- };
508
- } catch (error) {
509
- return {
510
- success: false,
511
- error: error instanceof Error ? error.message : 'Failed to discover table fields',
512
- executionTime: Date.now() - Date.now()
513
- };
514
- }
515
- }
516
-
517
- private async handleSnowTableSchemaDiscovery(args: any): Promise<ToolResult> {
518
- try {
519
- this.logger.info(`Discovering schema for table: ${args.tableName}`);
520
-
521
- // Get basic table info and fields
522
- const fieldsResult = await this.handleSnowDiscoverTableFields({ tableName: args.tableName });
523
- if (!fieldsResult.success) {
524
- return fieldsResult;
525
- }
526
-
527
- const schema: any = {
528
- table: fieldsResult.result?.table,
529
- fields: fieldsResult.result?.fields
530
- };
531
-
532
- // Add relationships if requested
533
- if (args.includeRelated) {
534
- // This would involve querying reference fields and foreign keys
535
- schema.relationships = [];
536
- }
537
-
538
- // Add indexes if requested
539
- if (args.includeIndexes) {
540
- // This would involve querying sys_db_index
541
- schema.indexes = [];
542
- }
543
-
544
- // Add extensions if requested
545
- if (args.includeExtensions) {
546
- // This would involve querying parent/child tables
547
- schema.extensions = [];
548
- }
549
-
550
- return {
551
- success: true,
552
- result: schema,
553
- executionTime: Date.now() - Date.now()
554
- };
555
- } catch (error) {
556
- return {
557
- success: false,
558
- error: error instanceof Error ? error.message : 'Failed to discover table schema',
559
- executionTime: Date.now() - Date.now()
560
- };
561
- }
562
- }
563
-
564
- // Helper methods
565
- private async getTableInfo(tableName: string): Promise<{name: string, label: string, sys_id: string} | null> {
566
- try {
567
- // Try direct lookup first
568
- const tableResponse = await this.client.searchRecords(
569
- 'sys_db_object',
570
- `name=${tableName}`,
571
- 1
572
- );
573
-
574
- if (tableResponse.success && tableResponse.data?.result?.length > 0) {
575
- const table = tableResponse.data.result[0];
576
- return {
577
- name: table.name,
578
- label: table.label,
579
- sys_id: table.sys_id
580
- };
581
- }
582
-
583
- // Try by sys_id
584
- const tableByIdResponse = await this.client.searchRecords(
585
- 'sys_db_object',
586
- `sys_id=${tableName}`,
587
- 1
588
- );
589
-
590
- if (tableByIdResponse.success && tableByIdResponse.data?.result?.length > 0) {
591
- const table = tableByIdResponse.data.result[0];
592
- return {
593
- name: table.name,
594
- label: table.label,
595
- sys_id: table.sys_id
596
- };
597
- }
598
-
599
- return null;
600
- } catch (error) {
601
- this.logger.error('Failed to get table info:', error);
602
- return null;
603
- }
604
- }
605
- }
606
-
607
- // Create and run the server
608
- if (require.main === module) {
609
- const server = new ServiceNowPlatformDevelopmentMCP();
610
- server.start().catch(console.error);
611
- }