@@ -89,18 +89,36 @@ export class InstanceRouter {
8989 server . setRequestHandler ( CallToolRequestSchema , async ( request ) => {
9090 const { name : toolName , arguments : toolArgs } = request . params ;
9191
92+ // Look up the tool in the discovery cache to get its correct namespacedName.
93+ // processId is the installation name (e.g., "duckduckgo-mcp-server-john-plhdo1j4kuit0et-..."),
94+ // but the executor expects namespacedName using serverSlug (e.g., "duckduckgo-mcp-server:search").
95+ const allTools = this . toolDiscoveryManager . getAllTools ( ) ;
96+ const matchedTool = allTools . find (
97+ tool => tool . serverName === processId && tool . originalName === toolName
98+ ) ;
99+
100+ if ( ! matchedTool ) {
101+ this . logger . error ( {
102+ operation : 'instance_tool_not_found' ,
103+ process_id : processId ,
104+ tool_name : toolName ,
105+ available_tools : allTools
106+ . filter ( t => t . serverName === processId )
107+ . map ( t => t . originalName )
108+ } , `Tool not found: ${ toolName } on instance ${ processId } ` ) ;
109+
110+ throw new Error ( `Tool not found: ${ toolName } on instance ${ processId } ` ) ;
111+ }
112+
92113 this . logger . info ( {
93114 operation : 'instance_tool_call' ,
94115 process_id : processId ,
95- tool_name : toolName
116+ tool_name : toolName ,
117+ namespaced_name : matchedTool . namespacedName
96118 } , `Executing tool ${ toolName } on instance ${ processId } ` ) ;
97119
98- // Execute tool on this specific instance
99- // Need to convert tool name to namespaced format for executor
100- const namespacedToolName = `${ processId } :${ toolName } ` ;
101-
102120 const result = await this . toolExecutor . executeToolCall (
103- namespacedToolName ,
121+ matchedTool . namespacedName , // e.g., "duckduckgo-mcp-server:search"
104122 toolArgs || { } ,
105123 processId // Force routing to this specific process
106124 ) ;
0 commit comments