Browse Source

Exclude MCP from system prompt if mode does not support it

Matt Rubens 10 months ago
parent
commit
003cd1bce1
2 changed files with 13 additions and 5 deletions
  1. 5 0
      .changeset/fluffy-pumpkins-sip.md
  2. 8 5
      src/core/prompts/system.ts

+ 5 - 0
.changeset/fluffy-pumpkins-sip.md

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

+ 8 - 5
src/core/prompts/system.ts

@@ -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()}