🧰 fix: Available Tools Retrieval with correct MCP Caching (#9181)

* fix: available tools retrieval with correct mcp caching and conversion

* test: Enhance PluginController tests with MCP tool mocking and conversion

* refactor: Simplify PluginController tests by removing unused mocks and enhancing test clarity
This commit is contained in:
Danny Avila 2025-08-20 22:33:54 -04:00 committed by GitHub
parent a49b2b2833
commit aba0a93d1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 268 additions and 195 deletions

View file

@ -58,6 +58,21 @@ export class MCPManager extends UserConnectionManager {
public getAppToolFunctions(): t.LCAvailableTools | null {
return this.serversRegistry.toolFunctions!;
}
/** Returns all available tool functions from all connections available to user */
public async getAllToolFunctions(userId: string): Promise<t.LCAvailableTools | null> {
const allToolFunctions: t.LCAvailableTools = this.getAppToolFunctions() ?? {};
const userConnections = this.getUserConnections(userId);
if (!userConnections || userConnections.size === 0) {
return allToolFunctions;
}
for (const [serverName, connection] of userConnections.entries()) {
const toolFunctions = await this.serversRegistry.getToolFunctions(serverName, connection);
Object.assign(allToolFunctions, toolFunctions);
}
return allToolFunctions;
}
/**
* Get instructions for MCP servers