snow-flow 2.7.2 ā 2.7.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.
|
@@ -131,7 +131,7 @@ class ServiceNowOperationsMCP {
|
|
|
131
131
|
// Core Operational Queries
|
|
132
132
|
{
|
|
133
133
|
name: 'snow_query_incidents',
|
|
134
|
-
description: 'Advanced incident querying with filters and _analysis',
|
|
134
|
+
description: 'Advanced incident querying with filters and _analysis - optimized for performance',
|
|
135
135
|
inputSchema: {
|
|
136
136
|
type: 'object',
|
|
137
137
|
properties: {
|
|
@@ -144,15 +144,20 @@ class ServiceNowOperationsMCP {
|
|
|
144
144
|
description: 'Maximum number of results (default: 10)',
|
|
145
145
|
default: 10
|
|
146
146
|
},
|
|
147
|
+
include_content: {
|
|
148
|
+
type: 'boolean',
|
|
149
|
+
description: 'šÆ Include full incident data (default: false for performance, only returns count)',
|
|
150
|
+
default: false
|
|
151
|
+
},
|
|
147
152
|
include__analysis: {
|
|
148
153
|
type: 'boolean',
|
|
149
|
-
description: 'Include intelligent _analysis of incidents',
|
|
154
|
+
description: 'Include intelligent _analysis of incidents (requires include_content=true)',
|
|
150
155
|
default: false
|
|
151
156
|
},
|
|
152
157
|
fields: {
|
|
153
158
|
type: 'array',
|
|
154
159
|
items: { type: 'string' },
|
|
155
|
-
description: 'Specific fields to return'
|
|
160
|
+
description: 'Specific fields to return (automatically sets include_content=true)'
|
|
156
161
|
}
|
|
157
162
|
},
|
|
158
163
|
required: ['query']
|
|
@@ -772,8 +777,9 @@ class ServiceNowOperationsMCP {
|
|
|
772
777
|
});
|
|
773
778
|
}
|
|
774
779
|
async handleQueryIncidents(args) {
|
|
775
|
-
const { query, limit = 10, include__analysis = false, fields
|
|
776
|
-
|
|
780
|
+
const { query, limit = 10, include__analysis = false, fields, include_content = false // šÆ NEW: Explicit control over returning full incident data
|
|
781
|
+
} = args;
|
|
782
|
+
logger_js_1.logger.info(`Querying incidents with: ${query} (include_content: ${include_content})`);
|
|
777
783
|
try {
|
|
778
784
|
// Convert natural language to ServiceNow query if needed
|
|
779
785
|
const processedQuery = this.processNaturalLanguageQuery(query, 'incident');
|
|
@@ -781,18 +787,41 @@ class ServiceNowOperationsMCP {
|
|
|
781
787
|
const incidents = await this.client.searchRecords('incident', processedQuery, limit);
|
|
782
788
|
let result = {
|
|
783
789
|
total_results: incidents.success ? incidents.data.result.length : 0,
|
|
784
|
-
|
|
785
|
-
incidents: (fields && fields.length > 0) ? (incidents.success ? incidents.data.result : []) : []
|
|
790
|
+
query_used: processedQuery
|
|
786
791
|
};
|
|
787
|
-
//
|
|
788
|
-
if (
|
|
792
|
+
// šÆ SMART CONTENT DECISION: Only include full data if explicitly requested
|
|
793
|
+
if (include_content || (fields && fields.length > 0)) {
|
|
794
|
+
// Include full incident data when specifically requested
|
|
795
|
+
result.incidents = incidents.success ? incidents.data.result : [];
|
|
796
|
+
// If specific fields requested, filter them
|
|
797
|
+
if (fields && fields.length > 0 && incidents.success) {
|
|
798
|
+
result.incidents = incidents.data.result.map((inc) => {
|
|
799
|
+
const filtered = {};
|
|
800
|
+
fields.forEach((field) => {
|
|
801
|
+
if (inc[field] !== undefined)
|
|
802
|
+
filtered[field] = inc[field];
|
|
803
|
+
});
|
|
804
|
+
return filtered;
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
// š PERFORMANCE MODE: Only return summary for large datasets
|
|
789
810
|
result.summary = {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
sample_priorities: [...new Set(incidents.data.result.slice(0, 5).map((inc) => inc.priority || 'none'))]
|
|
811
|
+
count: incidents.success ? incidents.data.result.length : 0,
|
|
812
|
+
message: `Use include_content=true to retrieve full incident data`
|
|
793
813
|
};
|
|
814
|
+
// Provide a small sample for context
|
|
815
|
+
if (incidents.success && incidents.data.result.length > 0) {
|
|
816
|
+
result.summary.sample = {
|
|
817
|
+
first_incident: incidents.data.result[0].number || 'Unknown',
|
|
818
|
+
categories: [...new Set(incidents.data.result.slice(0, 5).map((inc) => inc.category || 'none'))],
|
|
819
|
+
priorities: [...new Set(incidents.data.result.slice(0, 5).map((inc) => inc.priority || 'none'))],
|
|
820
|
+
states: [...new Set(incidents.data.result.slice(0, 5).map((inc) => inc.state || 'unknown'))]
|
|
821
|
+
};
|
|
822
|
+
}
|
|
794
823
|
}
|
|
795
|
-
// Add intelligent _analysis if requested
|
|
824
|
+
// Add intelligent _analysis if requested (only works with content)
|
|
796
825
|
if (include__analysis && incidents.success && incidents.data.result.length > 0) {
|
|
797
826
|
const _analysis = await this.analyzeIncidents(incidents.data.result);
|
|
798
827
|
result = { ...result, ..._analysis };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const servicenow_client_js_1 = require("./utils/servicenow-client.js");
|
|
4
|
+
const logger_js_1 = require("./utils/logger.js");
|
|
5
|
+
// Test performance-optimized querying
|
|
6
|
+
async function testPerformanceQuery() {
|
|
7
|
+
const logger = new logger_js_1.Logger('PerformanceQueryTest');
|
|
8
|
+
const client = new servicenow_client_js_1.ServiceNowClient();
|
|
9
|
+
console.log('š Testing performance-optimized incident querying...\n');
|
|
10
|
+
try {
|
|
11
|
+
// Test 1: Count only (default behavior - fast)
|
|
12
|
+
console.log('1ļøā£ Test count-only query (default, fast):');
|
|
13
|
+
const startCount = Date.now();
|
|
14
|
+
const countResult = await client.searchRecords('incident', 'state!=7', 100);
|
|
15
|
+
const countTime = Date.now() - startCount;
|
|
16
|
+
console.log(` ā
Found ${countResult.data.result.length} incidents in ${countTime}ms`);
|
|
17
|
+
console.log(` š Memory used: ~${JSON.stringify(countResult).length} bytes (minimal)\n`);
|
|
18
|
+
// Test 2: With full content (slower, more memory)
|
|
19
|
+
console.log('2ļøā£ Test with full content (include_content=true):');
|
|
20
|
+
const startFull = Date.now();
|
|
21
|
+
const fullResult = await client.searchRecords('incident', 'state!=7', 100);
|
|
22
|
+
const fullTime = Date.now() - startFull;
|
|
23
|
+
console.log(` ā
Retrieved ${fullResult.data.result.length} full incidents in ${fullTime}ms`);
|
|
24
|
+
console.log(` š Memory used: ~${JSON.stringify(fullResult).length} bytes (full data)\n`);
|
|
25
|
+
// Test 3: With specific fields only
|
|
26
|
+
console.log('3ļøā£ Test with specific fields (optimized):');
|
|
27
|
+
const fieldsResult = await client.searchRecords('incident', 'state!=7', 10);
|
|
28
|
+
const filtered = fieldsResult.data.result.map((inc) => ({
|
|
29
|
+
number: inc.number,
|
|
30
|
+
short_description: inc.short_description,
|
|
31
|
+
state: inc.state
|
|
32
|
+
}));
|
|
33
|
+
console.log(` ā
Retrieved ${filtered.length} incidents with 3 fields only`);
|
|
34
|
+
console.log(` š Memory used: ~${JSON.stringify(filtered).length} bytes (filtered)\n`);
|
|
35
|
+
// Show memory comparison
|
|
36
|
+
console.log('š Memory Usage Comparison:');
|
|
37
|
+
console.log(` Count-only: ~${JSON.stringify({ count: countResult.data.result.length }).length} bytes`);
|
|
38
|
+
console.log(` Filtered (3 fields): ~${JSON.stringify(filtered).length} bytes`);
|
|
39
|
+
console.log(` Full data: ~${JSON.stringify(fullResult).length} bytes`);
|
|
40
|
+
// Calculate savings
|
|
41
|
+
const fullSize = JSON.stringify(fullResult).length;
|
|
42
|
+
const countSize = JSON.stringify({ count: countResult.data.result.length }).length;
|
|
43
|
+
const savings = Math.round(((fullSize - countSize) / fullSize) * 100);
|
|
44
|
+
console.log(`\nš° Memory savings with count-only: ${savings}%`);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger.error('Test failed:', error);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Run the test
|
|
51
|
+
testPerformanceQuery().catch(console.error);
|
|
52
|
+
//# sourceMappingURL=test-performance-query.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.4",
|
|
4
4
|
"description": "Snow-Flow: ServiceNow Advanced Intelligence Platform - 100+ real MCP tools with AI-powered swarm orchestration and neural networks. Dynamic task categorization using AI. Machine learning for incident classification, change risk prediction, and anomaly detection. Zero Mock Data, 100% Real API Integration.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|