snow-flow 3.4.28 → 3.4.29

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.
@@ -89,7 +89,7 @@ class ServiceNowDevelopmentAssistantMCP {
89
89
  },
90
90
  {
91
91
  name: 'snow_get_by_sysid',
92
- description: 'Retrieves artifacts by sys_id for precise, fast lookups. More reliable than text-based searches when sys_id is known.',
92
+ description: 'Retrieves artifacts by sys_id for precise, fast lookups. Auto-detects large responses and suggests efficient field-specific queries using snow_query_table when needed. More reliable than text-based searches when sys_id is known.',
93
93
  inputSchema: {
94
94
  type: 'object',
95
95
  properties: {
@@ -2128,6 +2128,50 @@ class ServiceNowDevelopmentAssistantMCP {
2128
2128
  table: args.table,
2129
2129
  ...artifact
2130
2130
  };
2131
+ // Estimate token count (rough estimate: 1 token ≈ 4 characters)
2132
+ const jsonString = JSON.stringify(formattedArtifact, null, 2);
2133
+ const estimatedTokens = Math.ceil(jsonString.length / 4);
2134
+ const maxTokens = 25000; // MCP response limit
2135
+ let responseText;
2136
+ if (estimatedTokens > maxTokens) {
2137
+ // Response too large - return essential fields only and suggest specific field access
2138
+ const essentialFields = {
2139
+ sys_id: artifact.sys_id,
2140
+ name: artifact.name || artifact.title || 'Unknown',
2141
+ table: args.table,
2142
+ sys_updated_on: artifact.sys_updated_on,
2143
+ sys_created_on: artifact.sys_created_on,
2144
+ sys_updated_by: artifact.sys_updated_by,
2145
+ active: artifact.active,
2146
+ // Table-specific key fields
2147
+ ...(args.table === 'sp_widget' && {
2148
+ id: artifact.id,
2149
+ title: artifact.title,
2150
+ template: artifact.template ? `${artifact.template.substring(0, 200)}...` : null,
2151
+ script: artifact.script ? `${artifact.script.substring(0, 200)}...` : null,
2152
+ client_script: artifact.client_script ? `${artifact.client_script.substring(0, 200)}...` : null,
2153
+ css: artifact.css ? `${artifact.css.substring(0, 200)}...` : null
2154
+ }),
2155
+ ...(args.table === 'wf_workflow' && {
2156
+ title: artifact.title,
2157
+ workflow_version: artifact.workflow_version,
2158
+ stage: artifact.stage
2159
+ }),
2160
+ ...(args.table === 'sys_script_include' && {
2161
+ api_name: artifact.api_name,
2162
+ client_callable: artifact.client_callable,
2163
+ script: artifact.script ? `${artifact.script.substring(0, 200)}...` : null
2164
+ })
2165
+ };
2166
+ const availableFields = Object.keys(artifact).filter(key => !essentialFields.hasOwnProperty(key));
2167
+ responseText = `✅ Found artifact by sys_id!\n\n🎯 **${formattedArtifact.name}**\n🆔 sys_id: ${args.sys_id}\n📊 Table: ${args.table}\n\n⚠️ **Response size limited (${estimatedTokens} tokens > ${maxTokens} limit)**\n\n**Essential Fields:**\n${JSON.stringify(essentialFields, null, 2)}\n\n🎯 **RECOMMENDATION: Get specific fields instead**\n\nUse snow_query_table with specific fields for better performance:\n\`\`\`\nsnow_query_table({\n table: "${args.table}",\n query: "sys_id=${args.sys_id}",\n fields: ["field1", "field2", "field3"], // Only fields you need\n limit: 1\n})\n\`\`\`\n\n**Available fields to choose from:**\n${availableFields.slice(0, 20).join(', ')}${availableFields.length > 20 ? `, and ${availableFields.length - 20} more...` : ''}\n\n💡 **Example for ${args.table}:**\n${args.table === 'sp_widget' ? `snow_query_table({ table: "sp_widget", query: "sys_id=${args.sys_id}", fields: ["name", "title", "template", "client_script", "script"], limit: 1 })` :
2168
+ args.table === 'wf_workflow' ? `snow_query_table({ table: "wf_workflow", query: "sys_id=${args.sys_id}", fields: ["name", "title", "workflow_version", "stage"], limit: 1 })` :
2169
+ `snow_query_table({ table: "${args.table}", query: "sys_id=${args.sys_id}", fields: ["name", "sys_updated_on"], limit: 1 })`}`;
2170
+ }
2171
+ else {
2172
+ // Response size is acceptable
2173
+ responseText = `✅ Found artifact by sys_id!\n\n🎯 **${formattedArtifact.name}**\n🆔 sys_id: ${args.sys_id}\n📊 Table: ${args.table}\n\n**All Fields:**\n${jsonString}`;
2174
+ }
2131
2175
  // Skip memory indexing for now - it might be causing timeouts
2132
2176
  // TODO: Investigate why memory indexing causes timeouts
2133
2177
  /*
@@ -2143,7 +2187,7 @@ class ServiceNowDevelopmentAssistantMCP {
2143
2187
  content: [
2144
2188
  {
2145
2189
  type: 'text',
2146
- text: `✅ Found artifact by sys_id!\n\n🎯 **${formattedArtifact.name}**\n🆔 sys_id: ${args.sys_id}\n📊 Table: ${args.table}\n\n**All Fields:**\n${JSON.stringify(formattedArtifact, null, 2)}`,
2190
+ text: responseText,
2147
2191
  },
2148
2192
  ],
2149
2193
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.4.28",
3
+ "version": "3.4.29",
4
4
  "description": "ServiceNow development framework with MCP server integration. Executes background scripts using ES5 JavaScript only (ServiceNow Rhino engine requirement). Provides 17 MCP servers for complete ServiceNow operations including widget deployment with coherence validation, table operations, script execution, machine learning, advanced features, and comprehensive platform management.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",