-
Notifications
You must be signed in to change notification settings - Fork 8.5k
fix: prevent tools discovery error for prompt-only MCP servers #10367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent tools discovery error for prompt-only MCP servers #10367
Conversation
- Add capability check in discoverTools() before calling mcpToTool() - Return empty array when server does not advertise tool support - Follow same pattern as discoverPrompts() capability check - Add tests to verify tools are only discovered when server supports them - Update existing tests to mock getServerCapabilities() properly This fixes the "-32601: tools not supported" error that occurs when connecting to MCP servers that only provide prompts (no tools).
Summary of ChangesHello @vasayxtx, 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 addresses an issue where the MCP client would encounter an error when attempting to discover tools on servers that are configured to only support prompts. By introducing a pre-check for server capabilities within the Highlights
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly fixes an error that occurred when connecting to prompt-only MCP servers. The change adds a check for tool support in discoverTools
before proceeding, which is consistent with how discoverPrompts
works. The accompanying tests are well-written, covering both scenarios where a server supports tools and where it does not. The changes are sound and address the issue effectively.
The CI failures appear to be flaky tests - both fail at interactive mode startup, which is unrelated to my MCP capability checking changes. @scidomino, could you re-run the failed jobs? Thanks! |
There was a flakey test fix that was checked in recently that you didn't have. I updated your branch and am running them again. |
Co-authored-by: Tommaso Sciortino <[email protected]>
Co-authored-by: Tommaso Sciortino <[email protected]>
TLDR
This fixes the "-32601: tools not supported" error that occurs when connecting to MCP servers that only provide prompts (no tools).
Dive Deeper
Similar to how
discoverPrompts()
checks for prompt support:if (mcpClient.getServerCapabilities()?.prompts == null) return [];
The
discoverTools()
function should check for tool support before attempting to callmcpToTool()
, and silently return an empty array if tools are not supported.Reviewer Test Plan
Connect to an MPC server which doesn't implement the tools/list handler, you will no longer see an error on startup (but would previously).
Testing Matrix
Linked issues / bugs
Fixes #10365