mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-14 22:48:10 +01:00
🔧 fix: Ensure getServerToolFunctions Handles Errors (#9895)
* ensure getServerToolFunctions handles errors * remove reduntant test
This commit is contained in:
parent
b8720a9b7a
commit
c5d1861acf
2 changed files with 190 additions and 13 deletions
|
|
@ -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)!);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue