From 617d9aed96464d0a172827cb91e0c50c8051c5d5 Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Wed, 26 Aug 2026 20:48:34 +0200 Subject: [PATCH] ui: skip MCP init when flow policy disables the MCP category Resolve the effective tool policy before deciding whether to initialize MCP so flows that will not send any MCP tools skip the init work. Callers without a policy keep falling back to global defaults. Assisted-by: pi --- tools/ui/src/lib/stores/agentic/index.svelte.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/ui/src/lib/stores/agentic/index.svelte.ts b/tools/ui/src/lib/stores/agentic/index.svelte.ts index b58cba15b4..3d47c50d86 100644 --- a/tools/ui/src/lib/stores/agentic/index.svelte.ts +++ b/tools/ui/src/lib/stores/agentic/index.svelte.ts @@ -324,7 +324,14 @@ class AgenticStore { if (!agenticConfig.enabled) return { handled: false }; - const hasMcpServers = mcpStore.hasEnabledServers(); + // callers without an explicit policy fall back to the global defaults + const disabledTools = new Set(toolPolicy?.disabledTools ?? toolsStore.disabledTools); + const disabledToolCategories = new Set( + toolPolicy?.disabledToolCategories ?? toolsStore.disabledToolCategories + ); + // skip MCP init when the policy disables the whole MCP category + const hasMcpServers = + mcpStore.hasEnabledServers() && !disabledToolCategories.has(ToolSource.MCP); if (hasMcpServers) { const initialized = await mcpStore.ensureInitialized(); @@ -334,11 +341,7 @@ class AgenticStore { } } - // callers without an explicit policy fall back to the global defaults - const tools = toolsStore.getEnabledToolsForLLM( - new Set(toolPolicy?.disabledTools ?? toolsStore.disabledTools), - new Set(toolPolicy?.disabledToolCategories ?? toolsStore.disabledToolCategories) - ); + const tools = toolsStore.getEnabledToolsForLLM(disabledTools, disabledToolCategories); if (tools.length === 0) { return { handled: false };