diff --git a/src/everything/server/roots.ts b/src/everything/server/roots.ts index 30671b17..05a6f90f 100644 --- a/src/everything/server/roots.ts +++ b/src/everything/server/roots.ts @@ -27,8 +27,8 @@ export const syncRoots = async (server: McpServer, sessionId?: string) => { const clientCapabilities = server.server.getClientCapabilities() || {}; const clientSupportsRoots: boolean = clientCapabilities.roots !== undefined; - // If roots have not been fetched for this client, fetch them - if (clientSupportsRoots && !roots.has(sessionId)) { + // Fetch the roots list for this client + if (clientSupportsRoots) { // Function to request the updated roots list from the client const requestRoots = async () => { try { diff --git a/src/everything/tools/get-roots-list.ts b/src/everything/tools/get-roots-list.ts index 0d8fe9c5..24369070 100644 --- a/src/everything/tools/get-roots-list.ts +++ b/src/everything/tools/get-roots-list.ts @@ -1,6 +1,6 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; -import { roots, syncRoots } from "../server/roots.js"; +import { syncRoots } from "../server/roots.js"; // Tool configuration const name = "get-roots-list"; @@ -39,17 +39,8 @@ export const registerGetRootsListTool = (server: McpServer) => { name, config, async (args, extra): Promise => { - // Check if the roots list is already cached for this client - const rootsCached = roots?.has(extra.sessionId); - - // Fetch the current roots list from the client if need be - const currentRoots = rootsCached - ? roots.get(extra.sessionId) - : await syncRoots(server, extra.sessionId); - - // If roots had to be fetched, store them in the cache - if (currentRoots && !rootsCached) - roots.set(extra.sessionId, currentRoots); + // Get the current rootsFetch the current roots list from the client if need be + const currentRoots = await syncRoots(server, extra.sessionId); // Respond if client supports roots but doesn't have any configured if (