fraim-framework 2.0.95 → 2.0.96

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.
@@ -1411,15 +1411,6 @@ class FraimLocalMCPServer {
1411
1411
  }
1412
1412
  const response = await this._doProxyToRemote(injectedRequest, requestId);
1413
1413
  const processedResponse = await this.finalizeToolResponse(injectedRequest, response, requestSessionId, requestId);
1414
- // Single point for usage tracking - log all tool calls
1415
- if (injectedRequest.method === 'tools/call' && requestSessionId && toolName) {
1416
- const success = !processedResponse.error;
1417
- this.log(`📊 Collecting usage: ${toolName} (session: ${requestSessionId}, success: ${success})`);
1418
- this.usageCollector.collectMCPCall(toolName, args, requestSessionId, success);
1419
- }
1420
- else if (injectedRequest.method === 'tools/call') {
1421
- this.log(`⚠️ Skipping usage collection: toolName=${toolName}, sessionId=${requestSessionId}`);
1422
- }
1423
1414
  this.log(`📤 ${injectedRequest.method} → ${processedResponse.error ? 'ERROR' : 'OK'}`);
1424
1415
  return processedResponse;
1425
1416
  }
@@ -1540,6 +1531,8 @@ class FraimLocalMCPServer {
1540
1531
  const response = await this.handleRequest(message);
1541
1532
  // Only send response if we got one (null means we handled it internally)
1542
1533
  if (response) {
1534
+ // Collect usage for all tools/call requests before sending response
1535
+ this.collectUsageForResponse(message, response);
1543
1536
  process.stdout.write(JSON.stringify(response) + '\n');
1544
1537
  }
1545
1538
  }
@@ -1593,6 +1586,26 @@ class FraimLocalMCPServer {
1593
1586
  });
1594
1587
  this.log('✅ FRAIM Local MCP Server ready');
1595
1588
  }
1589
+ /**
1590
+ * Collect usage analytics for tools/call requests
1591
+ */
1592
+ collectUsageForResponse(request, response) {
1593
+ // Only collect usage for tools/call requests
1594
+ if (request.method !== 'tools/call') {
1595
+ return;
1596
+ }
1597
+ const toolName = request.params?.name;
1598
+ const args = request.params?.arguments || {};
1599
+ const requestSessionId = this.extractSessionIdFromRequest(request);
1600
+ if (toolName && requestSessionId) {
1601
+ const success = !response.error;
1602
+ this.log(`📊 Collecting usage: ${toolName} (session: ${requestSessionId}, success: ${success})`);
1603
+ this.usageCollector.collectMCPCall(toolName, args, requestSessionId, success);
1604
+ }
1605
+ else if (request.method === 'tools/call') {
1606
+ this.log(`⚠️ Skipping usage collection: toolName=${toolName}, sessionId=${requestSessionId}`);
1607
+ }
1608
+ }
1596
1609
  /**
1597
1610
  * Flush collected usage data to the local database
1598
1611
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fraim-framework",
3
- "version": "2.0.95",
3
+ "version": "2.0.96",
4
4
  "description": "FRAIM v2: Framework for Rigor-based AI Management - Transform from solo developer to AI manager orchestrating production-ready code with enterprise-grade discipline",
5
5
  "main": "index.js",
6
6
  "bin": {