🔧 fix: Ensure getServerToolFunctions Handles Errors (#9895)

* ensure getServerToolFunctions handles errors

* remove reduntant test
This commit is contained in:
Federico Ruggi 2025-09-30 14:48:39 +02:00 committed by GitHub
parent b8720a9b7a
commit c5d1861acf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 190 additions and 13 deletions

View file

@ -97,22 +97,30 @@ export class MCPManager extends UserConnectionManager {
userId: string,
serverName: string,
): Promise<t.LCAvailableTools | null> {
if (this.appConnections?.has(serverName)) {
return this.serversRegistry.getToolFunctions(
serverName,
await this.appConnections.get(serverName),
try {
if (this.appConnections?.has(serverName)) {
return this.serversRegistry.getToolFunctions(
serverName,
await this.appConnections.get(serverName),
);
}
const userConnections = this.getUserConnections(userId);
if (!userConnections || userConnections.size === 0) {
return null;
}
if (!userConnections.has(serverName)) {
return null;
}
return this.serversRegistry.getToolFunctions(serverName, userConnections.get(serverName)!);
} catch (error) {
logger.warn(
`[getServerToolFunctions] Error getting tool functions for server ${serverName}`,
error,
);
}
const userConnections = this.getUserConnections(userId);
if (!userConnections || userConnections.size === 0) {
return null;
}
if (!userConnections.has(serverName)) {
return null;
}
return this.serversRegistry.getToolFunctions(serverName, userConnections.get(serverName)!);
}
/**