File tree Expand file tree Collapse file tree 2 files changed +43
-3
lines changed
server/aws-lsp-codewhisperer/src/language-server/agenticChat Expand file tree Collapse file tree 2 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -415,9 +415,27 @@ export class AgenticChatController implements ChatHandlers {
415
415
}
416
416
}
417
417
async onMcpServerClick ( params : McpServerClickParams ) {
418
- return {
419
- id : params . id ,
420
- success : true ,
418
+ switch ( params . id ) {
419
+ case 'refresh-mcp-list' :
420
+ try {
421
+ await McpManager . instance . reinitializeMcpServers ( )
422
+ return {
423
+ id : params . id ,
424
+ success : true ,
425
+ }
426
+ } catch ( err ) {
427
+ this . #features. logging . error ( `Failed to reinitialize MCP servers: ${ err } ` )
428
+ return {
429
+ id : params . id ,
430
+ success : false ,
431
+ error : err instanceof Error ? err . message : 'Unknown error when reinitializing MCP server' ,
432
+ }
433
+ }
434
+ default :
435
+ return {
436
+ id : params . id ,
437
+ success : true ,
438
+ }
421
439
}
422
440
}
423
441
Original file line number Diff line number Diff line change @@ -412,6 +412,28 @@ export class McpManager {
412
412
McpManager . #instance = undefined
413
413
}
414
414
415
+ /**
416
+ * Reinitialize all MCP servers by closing existing connections and rediscovering servers
417
+ */
418
+ public async reinitializeMcpServers ( ) : Promise < void > {
419
+ this . features . logging . info ( 'Reinitializing MCP servers' )
420
+
421
+ try {
422
+ // Close all existing connections
423
+ await this . close ( )
424
+
425
+ // Reinitialize with the same configuration paths
426
+ const newMcpManager = await McpManager . init ( this . configPaths , this . features )
427
+
428
+ this . features . logging . info (
429
+ `MCP servers reinitialized completed with mcpServers count: ${ newMcpManager . mcpServers . size } `
430
+ )
431
+ } catch ( err : any ) {
432
+ this . features . logging . error ( `Error reinitializing MCP servers: ${ err . message } ` )
433
+ throw err
434
+ }
435
+ }
436
+
415
437
/**
416
438
* Check if a tool requires approval.
417
439
*/
You can’t perform that action at this time.
0 commit comments