feat(plan): implement support for MCP servers in Plan mode#18229
feat(plan): implement support for MCP servers in Plan mode#18229
Conversation
Summary of ChangesHello @Adib234, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the system's 'Plan Mode' capabilities by integrating support for read-only Model Context Protocol (MCP) tools. It enables the agent to safely utilize non-mutating third-party tools during the planning and strategy phases, thereby expanding the agent's information gathering and analytical capabilities without introducing risks associated with state-changing operations. The changes involve updates to tool discovery, policy enforcement, and prompt generation to seamlessly incorporate these newly recognized read-only tools. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Size Change: +1.13 kB (0%) Total Size: 23.7 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request effectively enables read-only MCP tools in Plan Mode, which is a great enhancement for safety and usability during the design phase. The implementation is logical and includes relevant tests. I've identified one area for improvement to enhance robustness. My specific comment provides a suggestion to address this point.
jerop
left a comment
There was a problem hiding this comment.
- how does default mode handle read-only mcp tools? does it ask user for permissions? should we carry over this change to default mode as well? we want to make sure that plan mode is most conservative (that is, don't want it to be more permissive than default mode)
- is there a way to configure this in policy engine? it'd be great if policy engine was the source of truth for all tool permissions, both core or mcp tools
default mode asks for users's permission when a tool from an MCP server will execute. i've updated to make sure that we ask for the user permission every time a tool from an mcp server will execute in plan mode.
yes it seems there is, we can use PolicyDecision.ASK_USER to make sure the user is asked for a tool's execution |
Summary
This PR enables read-only MCP tools to be automatically available and allowed when operating in Plan Mode. By leveraging the optional readOnlyHint annotation in MCP tool definitions, the agent can now utilize safe, non-mutating third-party tools (like documentation search or data retrieval) during the design and strategy phase without compromising safety.
Details
Related Issues
Fixes #16748
Fixes #18261
How to Validate
To validate locally you can turn on plan mode and add a MCP server to the settings file.
Here's the code for the MCP server that includes readOnlyHint in its' annotation https://paste.googleplex.com/5838293042331648
Now if you ask Gemini CLI to execute the tool in plan mode, it should be able to do it
Also tested with Github MCP server and invoked a read-only tool
Pre-Merge Checklist