From fe44a8abca6dae93fa0291bfaab647c748aab7e9 Mon Sep 17 00:00:00 2001 From: Matteo Date: Wed, 9 Sep 2026 09:05:45 +0200 Subject: [PATCH] fix(mcp): pin the tools/list cache hint to private MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `tools/list` is now filtered per caller — by organization and by MCP role — so its result must never be cached and reused for a different principal. A 'public' hint invites a client or proxy to do exactly that, which would serve one tenant's tool inventory to another and silently undo the scoping the previous commit added. 'private' is already the default, so this changes no behaviour. It is pinned because the consequence of changing it is invisible from the call site that depends on it: nothing in McpEndpointController would fail, and no test would break — the leak would simply reappear at whichever cache sits in front. mcp-nest does warn when the hint is 'public' while the list varies by caller, but that warning only fires at startup and only if someone reads the logs. --- packages/backend/src/mcp-server/mcp-strategy.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/backend/src/mcp-server/mcp-strategy.ts b/packages/backend/src/mcp-server/mcp-strategy.ts index 1009ca39..6a508d1f 100644 --- a/packages/backend/src/mcp-server/mcp-strategy.ts +++ b/packages/backend/src/mcp-server/mcp-strategy.ts @@ -34,4 +34,11 @@ export const mcpStrategy = new McpStrategy({ name: 'anythingmcp', version: '0.1.0', transports: [mcpHttpTransport], + // `tools/list` is filtered per caller — by organization and by MCP role — + // so its result must never be cached and reused for a different principal. + // 'private' is already the default, but it is pinned here because the + // consequence of changing it is invisible: a 'public' hint lets a client or + // proxy serve one tenant's tool inventory to another, silently undoing the + // scoping in McpEndpointController.attachVisibleTools. + cacheHints: { 'tools/list': { cacheScope: 'private', ttlMs: 0 } }, });