Skip to content

Commit cdab4d6

Browse files
fix: add more detailed log when mcp server initialize failed and tooltip change (#1594)
* fix: add more detailed log when mcp server initialize failed and tooltip change * fix: nit
1 parent a2d495a commit cdab4d6

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

chat-client/src/client/tabs/tabFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class TabFactory {
143143
tabBarButtons.push({
144144
id: McpServerTabButtonId,
145145
icon: MynahIcons.MCP,
146-
description: 'Opening MCP Servers configuration',
146+
description: 'Configure MCP servers',
147147
})
148148
}
149149

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpManager.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,19 @@ export class McpManager {
210210
})
211211

212212
const connectPromise = client.connect(transport).catch(err => {
213-
const invalidConfigErrorCodes = ['ENOENT', 'EINVAL', -32000]
214-
const isConfigError = invalidConfigErrorCodes.includes(err.code)
213+
let errorMessage = err.message
214+
215+
// Provide specific guidance for common command not found errors
216+
if (err.code === 'ENOENT') {
217+
errorMessage = `Command '${cfg.command}' not found. Please ensure it's installed and available in your PATH.`
218+
} else if (err.code === 'EINVAL') {
219+
errorMessage = `Invalid arguments. Please check the command and arguments.`
220+
} else if (err.code === -32000) {
221+
errorMessage = `MCP protocol error. The server may not be properly configured.`
222+
}
223+
215224
throw new AgenticChatError(
216-
`MCP: server '${serverName}' failed to connect: ${isConfigError ? 'Invalid configuration' : err.message}`,
225+
`MCP: server '${serverName}' failed to connect: ${errorMessage}`,
217226
'MCPServerConnectionFailed'
218227
)
219228
})
@@ -467,6 +476,9 @@ export class McpManager {
467476
await this.initOneServer(serverName, newCfg)
468477
}
469478
} catch (err) {
479+
this.features.logging.error(
480+
`Failed to add MCP server '${serverName}': ${err instanceof Error ? err.message : String(err)}`
481+
)
470482
this.handleError(serverName, err)
471483
return
472484
}

0 commit comments

Comments
 (0)