@probelabs/probe 0.6.0-rc296 → 0.6.0-rc298

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.
@@ -164,6 +164,8 @@ export class MCPClientManager {
164
164
  this.debug = options.debug || process.env.DEBUG_MCP === '1';
165
165
  this.config = null;
166
166
  this.tracer = options.tracer || null;
167
+ // Optional event emitter for broadcasting tool call lifecycle to the agent (#522)
168
+ this.agentEvents = options.agentEvents || null;
167
169
  }
168
170
 
169
171
  /**
@@ -452,6 +454,7 @@ export class MCPClientManager {
452
454
  }
453
455
 
454
456
  const startTime = Date.now();
457
+ const toolCallId = `mcp-${toolName}-${startTime}`;
455
458
 
456
459
  // Record tool call start
457
460
  this.recordMcpEvent('tool.call_started', {
@@ -460,6 +463,17 @@ export class MCPClientManager {
460
463
  originalToolName: tool.originalName
461
464
  });
462
465
 
466
+ // Emit toolCall event so the agent's activeTools map tracks MCP tool calls (#522)
467
+ if (this.agentEvents) {
468
+ this.agentEvents.emit('toolCall', {
469
+ toolCallId,
470
+ name: toolName,
471
+ args,
472
+ status: 'started',
473
+ timestamp: new Date().toISOString(),
474
+ });
475
+ }
476
+
463
477
  try {
464
478
  if (this.debug) {
465
479
  console.error(`[MCP DEBUG] Calling ${toolName} with args:`, JSON.stringify(args, null, 2));
@@ -502,6 +516,16 @@ export class MCPClientManager {
502
516
  durationMs
503
517
  });
504
518
 
519
+ // Emit toolCall completion so agent's activeTools removes this entry (#522)
520
+ if (this.agentEvents) {
521
+ this.agentEvents.emit('toolCall', {
522
+ toolCallId,
523
+ name: toolName,
524
+ status: 'completed',
525
+ timestamp: new Date().toISOString(),
526
+ });
527
+ }
528
+
505
529
  return result;
506
530
  } catch (error) {
507
531
  const durationMs = Date.now() - startTime;
@@ -521,6 +545,16 @@ export class MCPClientManager {
521
545
  isTimeout: error.message.includes('timeout')
522
546
  });
523
547
 
548
+ // Emit toolCall error so agent's activeTools removes this entry (#522)
549
+ if (this.agentEvents) {
550
+ this.agentEvents.emit('toolCall', {
551
+ toolCallId,
552
+ name: toolName,
553
+ status: 'error',
554
+ timestamp: new Date().toISOString(),
555
+ });
556
+ }
557
+
524
558
  throw error;
525
559
  }
526
560
  }
@@ -36,6 +36,7 @@ export class MCPXmlBridge {
36
36
  constructor(options = {}) {
37
37
  this.debug = options.debug || false;
38
38
  this.tracer = options.tracer || null;
39
+ this.agentEvents = options.agentEvents || null;
39
40
  this.mcpTools = {};
40
41
  this.mcpManager = null;
41
42
  this.toolDescriptions = {};
@@ -84,7 +85,7 @@ export class MCPXmlBridge {
84
85
  console.error('[MCP DEBUG] Initializing MCP client manager...');
85
86
  }
86
87
 
87
- this.mcpManager = new MCPClientManager({ debug: this.debug, tracer: this.tracer });
88
+ this.mcpManager = new MCPClientManager({ debug: this.debug, tracer: this.tracer, agentEvents: this.agentEvents });
88
89
  const result = await this.mcpManager.initialize(mcpConfigs);
89
90
 
90
91
  // Get tools from the manager (already in Vercel format)