@@ -210,10 +210,19 @@ export class McpManager {
210
210
} )
211
211
212
212
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
+
215
224
throw new AgenticChatError (
216
- `MCP: server '${ serverName } ' failed to connect: ${ isConfigError ? 'Invalid configuration' : err . message } ` ,
225
+ `MCP: server '${ serverName } ' failed to connect: ${ errorMessage } ` ,
217
226
'MCPServerConnectionFailed'
218
227
)
219
228
} )
@@ -467,6 +476,9 @@ export class McpManager {
467
476
await this . initOneServer ( serverName , newCfg )
468
477
}
469
478
} catch ( err ) {
479
+ this . features . logging . error (
480
+ `Failed to add MCP server '${ serverName } ': ${ err instanceof Error ? err . message : String ( err ) } `
481
+ )
470
482
this . handleError ( serverName , err )
471
483
return
472
484
}
0 commit comments