mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 13:34:15 -07:00
feat(plan): implement support for MCP servers in Plan mode (#18229)
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
ENTER_PLAN_MODE_TOOL_NAME,
|
||||
} from '../tools/tool-names.js';
|
||||
import { resolveModel, isPreviewModel } from '../config/models.js';
|
||||
import { DiscoveredMCPTool } from '../tools/mcp-tool.js';
|
||||
|
||||
/**
|
||||
* Orchestrates prompt generation by gathering context and building options.
|
||||
@@ -48,6 +49,7 @@ export class PromptProvider {
|
||||
const isPlanMode = approvalMode === ApprovalMode.PLAN;
|
||||
const skills = config.getSkillManager().getSkills();
|
||||
const toolNames = config.getToolRegistry().getAllToolNames();
|
||||
const enabledToolNames = new Set(toolNames);
|
||||
const approvedPlanPath = config.getApprovedPlanPath();
|
||||
|
||||
const desiredModel = resolveModel(
|
||||
@@ -56,6 +58,28 @@ export class PromptProvider {
|
||||
);
|
||||
const isGemini3 = isPreviewModel(desiredModel);
|
||||
|
||||
// --- Context Gathering ---
|
||||
let planModeToolsList = PLAN_MODE_TOOLS.filter((t) =>
|
||||
enabledToolNames.has(t),
|
||||
)
|
||||
.map((t) => `- \`${t}\``)
|
||||
.join('\n');
|
||||
|
||||
// Add read-only MCP tools to the list
|
||||
if (isPlanMode) {
|
||||
const allTools = config.getToolRegistry().getAllTools();
|
||||
const readOnlyMcpTools = allTools.filter(
|
||||
(t): t is DiscoveredMCPTool =>
|
||||
t instanceof DiscoveredMCPTool && !!t.isReadOnly,
|
||||
);
|
||||
if (readOnlyMcpTools.length > 0) {
|
||||
const mcpToolsList = readOnlyMcpTools
|
||||
.map((t) => `- \`${t.name}\` (${t.serverName})`)
|
||||
.join('\n');
|
||||
planModeToolsList += `\n${mcpToolsList}`;
|
||||
}
|
||||
}
|
||||
|
||||
let basePrompt: string;
|
||||
|
||||
// --- Template File Override ---
|
||||
@@ -105,11 +129,11 @@ export class PromptProvider {
|
||||
'primaryWorkflows',
|
||||
() => ({
|
||||
interactive: interactiveMode,
|
||||
enableCodebaseInvestigator: toolNames.includes(
|
||||
enableCodebaseInvestigator: enabledToolNames.has(
|
||||
CodebaseInvestigatorAgent.name,
|
||||
),
|
||||
enableWriteTodosTool: toolNames.includes(WRITE_TODOS_TOOL_NAME),
|
||||
enableEnterPlanModeTool: toolNames.includes(
|
||||
enableWriteTodosTool: enabledToolNames.has(WRITE_TODOS_TOOL_NAME),
|
||||
enableEnterPlanModeTool: enabledToolNames.has(
|
||||
ENTER_PLAN_MODE_TOOL_NAME,
|
||||
),
|
||||
approvedPlan: approvedPlanPath
|
||||
@@ -121,11 +145,7 @@ export class PromptProvider {
|
||||
planningWorkflow: this.withSection(
|
||||
'planningWorkflow',
|
||||
() => ({
|
||||
planModeToolsList: PLAN_MODE_TOOLS.filter((t) =>
|
||||
new Set(toolNames).has(t),
|
||||
)
|
||||
.map((t) => `- \`${t}\``)
|
||||
.join('\n'),
|
||||
planModeToolsList,
|
||||
plansDir: config.storage.getProjectTempPlansDir(),
|
||||
approvedPlanPath: config.getApprovedPlanPath(),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user