From 50ab76bcefe633274541d70cb0afd9f28516f117 Mon Sep 17 00:00:00 2001 From: alaa-eddine Date: Tue, 16 Sep 2025 13:12:34 +0200 Subject: [PATCH] MCP logs tweak --- packages/core/src/Components/MCPClient.class.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/Components/MCPClient.class.ts b/packages/core/src/Components/MCPClient.class.ts index f15de836..dec5d3df 100644 --- a/packages/core/src/Components/MCPClient.class.ts +++ b/packages/core/src/Components/MCPClient.class.ts @@ -51,7 +51,7 @@ export class MCPClient extends Component { } // TODO [Forhad]: Need to check and validate input prompt token - const { client } = await this.connectMCP(mcpUrl); + const { client } = await this.connectMCP(mcpUrl, logger); const toolsData = await client.listTools(); const conv = new Conversation( @@ -105,17 +105,17 @@ export class MCPClient extends Component { return { _error: `Error on running MCP Client!\n${error?.message || JSON.stringify(error)}`, _debug: logger.output }; } } - private async connectMCP(mcpUrl: string) { + private async connectMCP(mcpUrl: string, logger: any) { const client = new Client({ name: 'auto-client', version: '1.0.0' }); // 1) Try Streamable HTTP first try { const st = new StreamableHTTPClientTransport(new URL(mcpUrl)); await client.connect(st); - console.debug('Connected to MCP using Streamable HTTP'); + logger.debug('Connected to MCP using Streamable HTTP'); return { client, transport: 'streamable' as const }; } catch (e: any) { - console.debug('Failed to connect to MCP using Streamable HTTP, falling back to SSE'); + logger.debug('Failed to connect to MCP using Streamable HTTP, falling back to SSE'); // 2) If clearly unsupported, fall back to SSE const msg = String(e?.message || e); const isUnsupported = /404|405|ENOTFOUND|ECONNREFUSED|CORS/i.test(msg);