Skip to content

Commit b4aa439

Browse files
committed
refactor: Remove unnecessary console logs from ToolAgent and MCP core functionalities
1 parent 91d2eec commit b4aa439

File tree

3 files changed

+1
-38
lines changed

3 files changed

+1
-38
lines changed

packages/components/nodes/agents/ToolAgent/ToolAgent.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ class ToolAgent_Agents implements INode {
172172
const handler = new CustomChainHandler(sseStreamer, chatId)
173173
const allCallbacks = [loggerHandler, handler, ...callbacks]
174174

175-
console.log("[Tool Agent] This is from the 'shouldStreamResponse", chatId, sseStreamer)
176-
177175
// Add detailed streaming handler if enabled
178176
if (enableDetailedStreaming && customStreamingHandler) {
179177
allCallbacks.push(customStreamingHandler)
@@ -212,8 +210,6 @@ class ToolAgent_Agents implements INode {
212210
} else {
213211
const allCallbacks = [loggerHandler, ...callbacks]
214212

215-
console.log("[Tool Agent] This is from the Else 'shouldStreamResponse", chatId, sseStreamer)
216-
217213
// Add detailed streaming handler if enabled
218214
if (enableDetailedStreaming && customStreamingHandler) {
219215
allCallbacks.push(customStreamingHandler)

packages/components/nodes/tools/MCP/core.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ export class MCPToolkit extends BaseToolkit {
9595
hasStreaming =
9696
(capabilities as any)?.notifications?.streaming === true ||
9797
(capabilities as any)?.experimental?.notifications?.streaming === true
98-
console.log(`🔍 [MCP Core] Server streaming capability:`, hasStreaming)
9998
} catch (error) {
100-
console.log(`⚠️ [MCP Core] Could not detect streaming capabilities, falling back to non-streaming:`, error.message)
99+
console.error(`⚠️ [MCP Core] Could not detect streaming capabilities, falling back to non-streaming:`, error.message)
101100
}
102101

103102
return { client, hasStreaming }
@@ -126,21 +125,6 @@ export class MCPToolkit extends BaseToolkit {
126125
throw new Error('Client is not initialized')
127126
}
128127

129-
// Log the incoming tool definition for debugging
130-
console.log(
131-
`📋 [MCP Tool Definition] ${tool.name}:`,
132-
JSON.stringify(
133-
{
134-
name: tool.name,
135-
description: tool.description,
136-
annotations: tool.annotations,
137-
inputSchema: tool.inputSchema ? 'present' : 'missing'
138-
},
139-
null,
140-
2
141-
)
142-
)
143-
144128
return await MCPTool({
145129
toolkit: this,
146130
name: tool.name,
@@ -175,14 +159,9 @@ export async function MCPTool({
175159
const { client, hasStreaming } = await toolkit.createClient()
176160
await client.close()
177161

178-
// Check if tool has streaming annotations
179162
const toolHasStreaming = annotations.streaming_enabled === true
180163
const shouldUseStreaming = hasStreaming && toolHasStreaming
181164

182-
console.log(
183-
`🔍 [MCP Tool] ${name} - Server streaming: ${hasStreaming}, Tool streaming: ${toolHasStreaming}, Using streaming: ${shouldUseStreaming}`
184-
)
185-
186165
return tool(
187166
async (input, config): Promise<string> => {
188167
return await executeMCPTool(toolkit, name, input, config, annotations)
@@ -267,7 +246,6 @@ async function handleToolResponse(
267246
}
268247

269248
// Streaming tools wait for completion
270-
console.log(`🔄 [MCP Tool] Waiting for streaming completion for ${name}`)
271249
return waitForStreamingCompletion(contentString, sseStreamer, chatId, name, notifications)
272250
}
273251

@@ -286,7 +264,6 @@ function waitForStreamingCompletion(
286264
completed = true
287265

288266
const fullResponse = buildFullResponse(contentString, notifications)
289-
console.log(`${reason} [MCP Tool] ${name} completed, returning full result`)
290267
resolve(fullResponse)
291268
}
292269

@@ -342,15 +319,12 @@ function setupNotificationHandlers(
342319

343320
// Detect completion based on tool's annotation signals
344321
if (completionSignals.includes(logger)) {
345-
console.log(`🎯 [MCP Tool] Completion signal detected: ${logger} for ${toolName}`)
346-
347322
// Add visual separation before LLM response
348323
sseStreamer.streamTokenEvent(chatId, '\n\n')
349324

350325
// Trigger cleanup after brief delay
351326
setTimeout(() => {
352327
sseStreamer.removeMcpConnection(chatId, toolName)
353-
console.log(`🔧 [MCP Tool] Auto-cleanup completed for ${toolName}`)
354328
}, MCP_STREAMING_CONFIG.NOTIFICATION_DELAY)
355329
}
356330
})

packages/server/src/utils/SSEStreamer.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,20 @@ export class SSEStreamer implements IServerSideEventStreamer {
3838
startTime: Date.now(),
3939
status: 'active'
4040
})
41-
console.log(`[SSEStreamer] Added MCP connection: ${connectionId}`)
4241
}
4342

4443
markMcpConnectionCompleting(chatId: string, toolName?: string) {
4544
const connectionId = `${chatId}:${toolName || 'unknown'}`
4645
const connection = this.activeMcpConnections.get(connectionId)
4746
if (connection) {
4847
connection.status = 'completing'
49-
console.log(`[SSEStreamer] Marking MCP connection as completing: ${connectionId}`)
5048
}
5149
}
5250

5351
removeMcpConnection(chatId: string, toolName?: string) {
5452
const connectionId = `${chatId}:${toolName || 'unknown'}`
5553
this.activeMcpConnections.delete(connectionId)
56-
console.log(`[SSEStreamer] Removed MCP connection: ${connectionId}`)
5754

58-
// Check if any active connections remain for this chatId
5955
const hasActiveConnections = Array.from(this.activeMcpConnections.keys()).some((key) => key.startsWith(`${chatId}:`))
6056

6157
if (!hasActiveConnections && this.clients[chatId]?.pendingRemoval) {
@@ -72,8 +68,6 @@ export class SSEStreamer implements IServerSideEventStreamer {
7268
if (client) {
7369
// Check if there are active MCP connections for this chatId
7470
if (this.hasMcpConnections(chatId)) {
75-
console.log(`[SSEStreamer] Delaying client removal for chatId: ${chatId} due to active MCP connections`)
76-
// Mark client for pending removal but don't close it yet
7771
client.pendingRemoval = true
7872
return
7973
}
@@ -85,7 +79,6 @@ export class SSEStreamer implements IServerSideEventStreamer {
8579
forceRemoveClient(chatId: string) {
8680
const client = this.clients[chatId]
8781
if (client) {
88-
console.log(`[SSEStreamer] Force removing client for chatId: ${chatId}`)
8982
const clientResponse = {
9083
event: 'end',
9184
data: '[DONE]'

0 commit comments

Comments
 (0)