snow-flow 3.4.20 → 3.4.21

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.
@@ -516,6 +516,8 @@ class ServiceNowAutomationMCP {
516
516
  }
517
517
  // Complete operation with token tracking
518
518
  this.logger.operationComplete(name, result);
519
+ // Add token usage to response
520
+ result = this.logger.addTokenUsageToResponse(result);
519
521
  return result;
520
522
  }
521
523
  catch (error) {
@@ -847,6 +847,8 @@ class ServiceNowOperationsMCP {
847
847
  }
848
848
  // Complete operation with token tracking
849
849
  this.logger.operationComplete(name, result);
850
+ // Add token usage to response
851
+ result = this.logger.addTokenUsageToResponse(result);
850
852
  return result;
851
853
  }
852
854
  catch (error) {
@@ -369,6 +369,8 @@ class ServiceNowSystemPropertiesMCP {
369
369
  }
370
370
  // Complete operation with token tracking
371
371
  this.logger.operationComplete(name, result);
372
+ // Add token usage to response
373
+ result = this.logger.addTokenUsageToResponse(result);
372
374
  return result;
373
375
  }
374
376
  catch (error) {
@@ -66,6 +66,11 @@ export declare class MCPLogger {
66
66
  * Get token usage
67
67
  */
68
68
  getTokenUsage(): TokenUsage;
69
+ /**
70
+ * Add token usage to MCP response
71
+ * Helper method to append token usage to tool response
72
+ */
73
+ addTokenUsageToResponse(result: any): any;
69
74
  /**
70
75
  * Reset token usage
71
76
  */
@@ -131,7 +131,8 @@ class MCPLogger {
131
131
  */
132
132
  operationStart(operation, params) {
133
133
  this.startTime = Date.now();
134
- this.info(`šŸš€ Starting: ${operation} (tokens reset)`, params);
134
+ this.resetTokens(); // Actually reset tokens when starting new operation!
135
+ this.info(`šŸš€ Starting: ${operation}`, params);
135
136
  }
136
137
  /**
137
138
  * Log operation complete
@@ -161,6 +162,21 @@ class MCPLogger {
161
162
  getTokenUsage() {
162
163
  return { ...this.tokenUsage };
163
164
  }
165
+ /**
166
+ * Add token usage to MCP response
167
+ * Helper method to append token usage to tool response
168
+ */
169
+ addTokenUsageToResponse(result) {
170
+ const tokenUsage = this.getTokenUsage();
171
+ if (result && result.content && Array.isArray(result.content) && tokenUsage.total > 0) {
172
+ // Append token usage info to the last content item
173
+ const lastContent = result.content[result.content.length - 1];
174
+ if (lastContent && lastContent.type === 'text') {
175
+ lastContent.text += `\n\nšŸ“Š Token Usage: ${tokenUsage.total} (Input: ${tokenUsage.input}, Output: ${tokenUsage.output})`;
176
+ }
177
+ }
178
+ return result;
179
+ }
164
180
  /**
165
181
  * Reset token usage
166
182
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.4.20",
3
+ "version": "3.4.21",
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",