File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -1593,8 +1593,6 @@ ${params.message}`,
15931593 )
15941594 } else if ( [ 'mcp-disable-server' , 'mcp-delete-server' , 'mcp-enable-server' ] . includes ( params . id ) ) {
15951595 messager . onListMcpServers ( )
1596- } else if ( params . id === 'refresh-mcp-list' ) {
1597- messager . onListMcpServers ( { 'refresh-mcp-list' : 'refresh-mcp-list' } )
15981596 } else if ( params . id === 'update-mcp-list' ) {
15991597 if ( isMcpServersListActive ) {
16001598 messager . onListMcpServers ( )
Original file line number Diff line number Diff line change @@ -552,8 +552,15 @@ export class McpManager {
552552 this . features . logging . info ( 'Reinitializing MCP servers' )
553553
554554 try {
555+ // Save the current tool name mapping to preserve tool names across reinitializations
556+ const savedToolNameMapping = this . getToolNameMapping ( )
557+
555558 // close clients, clear state, but don't reset singleton
556559 await this . close ( true )
560+
561+ // Restore the saved tool name mapping
562+ this . setToolNameMapping ( savedToolNameMapping )
563+
557564 await this . discoverAllServers ( )
558565
559566 const reinitializedServerCount = McpManager . #instance?. mcpServers . size
Original file line number Diff line number Diff line change @@ -337,6 +337,19 @@ export function createNamespacedToolName(
337337 allNamespacedTools : Set < string > ,
338338 toolNameMapping : Map < string , { serverName : string ; toolName : string } >
339339) : string {
340+ // First, check if this server/tool combination already has a mapping
341+ // If it does, reuse that name to maintain consistency across reinitializations
342+ for ( const [ existingName , mapping ] of toolNameMapping . entries ( ) ) {
343+ if ( mapping . serverName === serverName && mapping . toolName === toolName ) {
344+ // If the name is already in the set, it's already registered
345+ // If not, add it to the set
346+ if ( ! allNamespacedTools . has ( existingName ) ) {
347+ allNamespacedTools . add ( existingName )
348+ }
349+ return existingName
350+ }
351+ }
352+
340353 const sep = '___'
341354 // If tool name alone isn't unique or is too long, try adding server prefix
342355 const fullName = `${ serverName } ${ sep } ${ toolName } `
You can’t perform that action at this time.
0 commit comments