gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

feat (mcp): Refresh MCP prompts on list changed notification

Open MrLesk opened this issue 2 months ago • 2 comments

Summary

This PR follows up on https://github.com/google-gemini/gemini-cli/pull/13178 and adds automatic refresh of MCP prompts when the mcp client receives a PromptListChanged Notification.

Details

I used the same logic of refreshing tools and resources but for prompts.

Related Issues

https://github.com/google-gemini/gemini-cli/pull/13178#issuecomment-3620823418

How to Validate

Pre-Merge Checklist

  • [ ] Updated relevant documentation and README (if needed)
  • [ ] Added/updated tests (if needed)
  • [ ] Noted breaking changes (if any)
  • [ ] Validated on required platforms/methods:
    • [x] MacOS
      • [x] npm run
      • [ ] npx
      • [ ] Docker
      • [ ] Podman
      • [ ] Seatbelt
    • [ ] Windows
      • [ ] npm run
      • [ ] npx
      • [ ] Docker
    • [ ] Linux
      • [ ] npm run
      • [ ] npx
      • [ ] Docker

MrLesk avatar Dec 09 '25 23:12 MrLesk

Summary of Changes

Hello @MrLesk, I'm Gemini Code Assist[^1]! 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 enhances the Model Context Protocol (MCP) client by introducing an automatic refresh mechanism for prompts. When the MCP server signals a change in the prompt list via a PromptListChanged notification, the client will now proactively update its internal prompt registry. This ensures that the client always operates with the most current set of prompts, aligning prompt management with the existing, robust refresh patterns already in place for tools and resources.

Highlights

  • Automatic Prompt Refresh: The MCP client now automatically refreshes its list of prompts when it receives a PromptListChanged notification from the server.
  • Consistent Refresh Logic: This change implements prompt refresh logic that mirrors the existing mechanisms for refreshing tools and resources, ensuring consistency across different types of server-managed entities.
  • New Test Case: A new test case has been added to mcp-client.test.ts to verify the correct behavior of prompt refreshing upon receiving a list changed notification.
  • Concurrency Handling: The refresh mechanism includes logic to prevent multiple simultaneous refresh operations and to queue pending refreshes, ensuring efficient and reliable updates.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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 :thumbsup: and :thumbsdown: 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.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot] avatar Dec 09 '25 23:12 gemini-code-assist[bot]

Hi @chrstnb @jackwotherspoon This is the 2nd out of the 3 follow up PRs we agreed in https://github.com/google-gemini/gemini-cli/pull/13178

Only the 20mb guard for resources is missing which I will follow up when https://github.com/google-gemini/gemini-cli/pull/14854 is merged

MrLesk avatar Dec 09 '25 23:12 MrLesk

Looks good to me, thank you!

@chrstnb feel free to merge as the window of merging to main is very small because frequent commits, I would always miss it.

MrLesk avatar Dec 18 '25 17:12 MrLesk

Hi @MrLesk, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

bdmorgan avatar Jan 15 '26 03:01 bdmorgan

hey @bdmorgan this PR was requested by @chrstnb in https://github.com/google-gemini/gemini-cli/pull/14854

MrLesk avatar Jan 15 '26 22:01 MrLesk

@chrstnb I updated the branch after I noticed that some tests were failing because of some new logic. Everything should run fine now

MrLesk avatar Jan 20 '26 19:01 MrLesk

Looks like quite a few test runs are still failing (example error: https://github.com/google-gemini/gemini-cli/actions/runs/21337928627/job/61412700393?pr=14863#step:4:81)

Please address and then ping @chrstnb or myself again

bdmorgan avatar Jan 25 '26 19:01 bdmorgan

@bdmorgan I added the missing argument to the mcp client test. They should pass now

MrLesk avatar Jan 26 '26 22:01 MrLesk