You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If no entry was found after checking all enabled tools and their potential overrides
441
442
if(!mapEntry||!originalQualifiedName){
442
-
logger.error(`Attempted to call tool with exposed name "${requestedExposedName}", but no corresponding enabled tool or override configuration found.`);
443
-
thrownewError(`Unknown or disabled tool: ${requestedExposedName}`);
443
+
consterrorMessage=`Attempted to call tool with exposed name "${requestedExposedName}", but no corresponding enabled tool or override configuration found.`;
444
+
logger.error(errorMessage);
445
+
thrownewMcpError(-32601,errorMessage);// Method not found error code
444
446
}
445
447
446
448
// Now we have the correct mapEntry and the originalQualifiedName
logger.error(`SSE Reconnection to server '${clientForTool.name}' failed.`);
491
-
// If reconnect fails, break retry loop
492
-
break;
493
+
// If reconnect fails, throw an error to exit the retry loop and propagate
494
+
thrownewMcpError(-32000,`SSE Reconnection to server '${clientForTool.name}' failed for tool '${requestedExposedName}'.`);
493
495
}
494
-
}
495
-
}
496
+
}
497
+
}
496
498
497
499
try{
498
500
logger.log(`Forwarding tool call for exposed name '${requestedExposedName}' (original qualified name: '${originalQualifiedName}'). Forwarding to server '${clientForTool.name}' as tool '${originalToolNameForBackend}' (Attempt ${attempt+1})`);
// If the loop finishes without returning, it means all retries failed.
539
551
consterrorMessage=`Error calling tool '${requestedExposedName}' after ${maxRetries} retries (on backend server '${clientForTool.name}', original tool name '${originalToolNameForBackend}'): ${lastError?.message||'An unknown error occurred'}`;
540
552
logger.error(errorMessage,lastError);
541
-
thrownewError(errorMessage);
553
+
// Ensure a structured McpError is returned to the client
0 commit comments