Exclude MCP from system prompt if mode does not support it

This commit is contained in:
Matt Rubens 2025-03-03 10:46:54 -05:00
parent dba32ef117
commit 003cd1bce1
2 changed files with 13 additions and 5 deletions

View file

@ -0,0 +1,5 @@
---
"roo-cline": patch
---
Exclude MCP instructions from the prompt if the mode doesn't support MCP

View file

@ -7,6 +7,7 @@ import {
defaultModeSlug,
ModeConfig,
getModeBySlug,
getGroupName,
} from "../../shared/modes"
import { DiffStrategy } from "../diff/DiffStrategy"
import { McpHub } from "../../services/mcp/McpHub"
@ -50,15 +51,17 @@ async function generatePrompt(
// If diff is disabled, don't pass the diffStrategy
const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
const [mcpServersSection, modesSection] = await Promise.all([
getMcpServersSection(mcpHub, effectiveDiffStrategy, enableMcpServerCreation),
getModesSection(context),
])
// Get the full mode config to ensure we have the role definition
const modeConfig = getModeBySlug(mode, customModeConfigs) || modes.find((m) => m.slug === mode) || modes[0]
const roleDefinition = promptComponent?.roleDefinition || modeConfig.roleDefinition
const [modesSection, mcpServersSection] = await Promise.all([
getModesSection(context),
modeConfig.groups.some((groupEntry) => getGroupName(groupEntry) === "mcp")
? getMcpServersSection(mcpHub, effectiveDiffStrategy, enableMcpServerCreation)
: Promise.resolve(""),
])
const basePrompt = `${roleDefinition}
${getSharedToolUseSection()}