mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Show stderr output from mcp servers in debug mode (#4049)
This commit is contained in:
@@ -127,6 +127,7 @@ export async function discoverMcpTools(
|
||||
mcpServers: Record<string, MCPServerConfig>,
|
||||
mcpServerCommand: string | undefined,
|
||||
toolRegistry: ToolRegistry,
|
||||
debugMode: boolean,
|
||||
): Promise<void> {
|
||||
// Set discovery state to in progress
|
||||
mcpDiscoveryState = MCPDiscoveryState.IN_PROGRESS;
|
||||
@@ -147,7 +148,12 @@ export async function discoverMcpTools(
|
||||
|
||||
const discoveryPromises = Object.entries(mcpServers).map(
|
||||
([mcpServerName, mcpServerConfig]) =>
|
||||
connectAndDiscover(mcpServerName, mcpServerConfig, toolRegistry),
|
||||
connectAndDiscover(
|
||||
mcpServerName,
|
||||
mcpServerConfig,
|
||||
toolRegistry,
|
||||
debugMode,
|
||||
),
|
||||
);
|
||||
await Promise.all(discoveryPromises);
|
||||
|
||||
@@ -174,6 +180,7 @@ async function connectAndDiscover(
|
||||
mcpServerName: string,
|
||||
mcpServerConfig: MCPServerConfig,
|
||||
toolRegistry: ToolRegistry,
|
||||
debugMode: boolean,
|
||||
): Promise<void> {
|
||||
// Initialize the server status as connecting
|
||||
updateMCPServerStatus(mcpServerName, MCPServerStatus.CONNECTING);
|
||||
@@ -223,6 +230,17 @@ async function connectAndDiscover(
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
debugMode &&
|
||||
transport instanceof StdioClientTransport &&
|
||||
transport.stderr
|
||||
) {
|
||||
transport.stderr.on('data', (data) => {
|
||||
const stderrStr = data.toString().trim();
|
||||
console.debug(`[DEBUG] [MCP STDERR (${mcpServerName})]: `, stderrStr);
|
||||
});
|
||||
}
|
||||
|
||||
const mcpClient = new Client({
|
||||
name: 'gemini-cli-mcp-client',
|
||||
version: '0.0.1',
|
||||
|
||||
Reference in New Issue
Block a user