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
This commit is contained in:
Aleksander Grygier
2026-08-26 20:48:34 +02:00
committed by GitHub
parent 9eb3f7df95
commit 617d9aed96
@@ -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 };