Stop checking MCP tool schemas for type definitions#9574
Conversation
Summary of ChangesHello @geoffdowns, 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 refines the handling of Model Context Protocol (MCP) tools by eliminating an overly stringent schema validation check. 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.
Code Review
This pull request correctly removes the hasValidTypes validation for MCP tool schemas, which was overly restrictive. The function and its direct tests have been removed. However, a related test case that verifies the skipping of tools with invalid schemas was missed and will now fail. This needs to be removed to complete the change.
fixed |
…options (google-gemini#9540) Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com>
…ni#9517) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Shreya Keshive <skeshive@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
11c995e
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com> Co-authored-by: anthony bushong <agmsb@users.noreply.github.com> Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com> Co-authored-by: Sandy Tao <sandytao520@icloud.com> Co-authored-by: Jacob MacDonald <jakemac@google.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: christine betts <chrstn@uw.edu> Co-authored-by: Adam Weidman <65992621+adamfweidman@users.noreply.github.com> Co-authored-by: matt korwel <matt.korwel@gmail.com> Co-authored-by: Shreya Keshive <skeshive@gmail.com> Co-authored-by: HugoMurillo <mhugorodrigo@google.com> Co-authored-by: Shreya Keshive <shreyakeshive@google.com> Co-authored-by: Miguel Solorio <miguelsolorio@google.com> Co-authored-by: Christie Warwick (Wilson) <bobcatfish@gmail.com> Co-authored-by: shrutip90 <shruti.p90@gmail.com>
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com> Co-authored-by: anthony bushong <agmsb@users.noreply.github.com> Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com> Co-authored-by: Sandy Tao <sandytao520@icloud.com> Co-authored-by: Jacob MacDonald <jakemac@google.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: christine betts <chrstn@uw.edu> Co-authored-by: Adam Weidman <65992621+adamfweidman@users.noreply.github.com> Co-authored-by: matt korwel <matt.korwel@gmail.com> Co-authored-by: Shreya Keshive <skeshive@gmail.com> Co-authored-by: HugoMurillo <mhugorodrigo@google.com> Co-authored-by: Shreya Keshive <shreyakeshive@google.com> Co-authored-by: Miguel Solorio <miguelsolorio@google.com> Co-authored-by: Christie Warwick (Wilson) <bobcatfish@gmail.com> Co-authored-by: shrutip90 <shruti.p90@gmail.com>
…-proprietary#4774) In the past, Gemini CLI doesn't work with the Semgrep MCP server when we use our custom types. [Other MCP servers are also running into this error.](google-gemini/gemini-cli#6219) Gemini recently [released a fix ](google-gemini/gemini-cli#9574 this, so we should add the types back so models like GPT-5 can call our tools properly. Fixes SAF-2262 ## Test plan: ``` ███ █████████ ██████████ ██████ ██████ █████ ██████ █████ █████ ░░░███ ███░░░░░███░░███░░░░░█░░██████ ██████ ░░███ ░░██████ ░░███ ░░███ ░░░███ ███ ░░░ ░███ █ ░ ░███░█████░███ ░███ ░███░███ ░███ ░███ ░░░███ ░███ ░██████ ░███░░███ ░███ ░███ ░███░░███░███ ░███ ███░ ░███ █████ ░███░░█ ░███ ░░░ ░███ ░███ ░███ ░░██████ ░███ ███░ ░░███ ░░███ ░███ ░ █ ░███ ░███ ░███ ░███ ░░█████ ░███ ███░ ░░█████████ ██████████ █████ █████ █████ █████ ░░█████ █████ ░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ v0.9.0-nightly.20251001.163dba7e Tips for getting started: 1. Ask questions, edit files, or run commands. 2. Be specific for the best results. 3. Create GEMINI.md files to customize your interactions with Gemini. 4. /help for more information. > /mcp Configured MCP servers: 🟢 serverName - Ready (7 tools, 2 prompts) Tools: - get_abstract_syntax_tree - get_supported_languages - semgrep_findings - semgrep_rule_schema - semgrep_scan - semgrep_scan_supply_chain - semgrep_scan_with_custom_rule Prompts: - setup_semgrep_mcp - write_custom_semgrep_rule 💡 Tips: - Use /mcp desc to show server and tool descriptions - Use /mcp schema to show tool parameter schemas - Use /mcp nodesc to hide descriptions - Use /mcp auth <server-name> to authenticate with OAuth-enabled servers - Press Ctrl+T to toggle tool descriptions on/off Using: 1 MCP server (ctrl+t to view) ╭──────────────────────────────────────────────────────────────────────────────────╮ │ > Type your message or @path/to/file │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ~/Desktop/semgrep-proprietary no sandbox (see gemini-2.5-pro (100% (katrina/mcp-types*) /docs) context left) ``` Also tested that Cursor was able to call `semgrep_scan` after the change with the GPT-5 model (and that it was not able to call the tool nicely before the change)  synced from Pro 6ee3493829fff70665a892703aef809bf8899094
…-proprietary#4774) In the past, Gemini CLI doesn't work with the Semgrep MCP server when we use our custom types. [Other MCP servers are also running into this error.](google-gemini/gemini-cli#6219) Gemini recently [released a fix ](google-gemini/gemini-cli#9574 this, so we should add the types back so models like GPT-5 can call our tools properly. Fixes SAF-2262 ## Test plan: ``` ███ █████████ ██████████ ██████ ██████ █████ ██████ █████ █████ ░░░███ ███░░░░░███░░███░░░░░█░░██████ ██████ ░░███ ░░██████ ░░███ ░░███ ░░░███ ███ ░░░ ░███ █ ░ ░███░█████░███ ░███ ░███░███ ░███ ░███ ░░░███ ░███ ░██████ ░███░░███ ░███ ░███ ░███░░███░███ ░███ ███░ ░███ █████ ░███░░█ ░███ ░░░ ░███ ░███ ░███ ░░██████ ░███ ███░ ░░███ ░░███ ░███ ░ █ ░███ ░███ ░███ ░███ ░░█████ ░███ ███░ ░░█████████ ██████████ █████ █████ █████ █████ ░░█████ █████ ░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ v0.9.0-nightly.20251001.163dba7e Tips for getting started: 1. Ask questions, edit files, or run commands. 2. Be specific for the best results. 3. Create GEMINI.md files to customize your interactions with Gemini. 4. /help for more information. > /mcp Configured MCP servers: 🟢 serverName - Ready (7 tools, 2 prompts) Tools: - get_abstract_syntax_tree - get_supported_languages - semgrep_findings - semgrep_rule_schema - semgrep_scan - semgrep_scan_supply_chain - semgrep_scan_with_custom_rule Prompts: - setup_semgrep_mcp - write_custom_semgrep_rule 💡 Tips: - Use /mcp desc to show server and tool descriptions - Use /mcp schema to show tool parameter schemas - Use /mcp nodesc to hide descriptions - Use /mcp auth <server-name> to authenticate with OAuth-enabled servers - Press Ctrl+T to toggle tool descriptions on/off Using: 1 MCP server (ctrl+t to view) ╭──────────────────────────────────────────────────────────────────────────────────╮ │ > Type your message or @path/to/file │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ~/Desktop/semgrep-proprietary no sandbox (see gemini-2.5-pro (100% (katrina/mcp-types*) /docs) context left) ``` Also tested that Cursor was able to call `semgrep_scan` after the change with the GPT-5 model (and that it was not able to call the tool nicely before the change)  synced from Pro 6ee3493829fff70665a892703aef809bf8899094
…-proprietary#4774) In the past, Gemini CLI doesn't work with the Semgrep MCP server when we use our custom types. [Other MCP servers are also running into this error.](google-gemini/gemini-cli#6219) Gemini recently [released a fix ](google-gemini/gemini-cli#9574 this, so we should add the types back so models like GPT-5 can call our tools properly. Fixes SAF-2262 ## Test plan: ``` ███ █████████ ██████████ ██████ ██████ █████ ██████ █████ █████ ░░░███ ███░░░░░███░░███░░░░░█░░██████ ██████ ░░███ ░░██████ ░░███ ░░███ ░░░███ ███ ░░░ ░███ █ ░ ░███░█████░███ ░███ ░███░███ ░███ ░███ ░░░███ ░███ ░██████ ░███░░███ ░███ ░███ ░███░░███░███ ░███ ███░ ░███ █████ ░███░░█ ░███ ░░░ ░███ ░███ ░███ ░░██████ ░███ ███░ ░░███ ░░███ ░███ ░ █ ░███ ░███ ░███ ░███ ░░█████ ░███ ███░ ░░█████████ ██████████ █████ █████ █████ █████ ░░█████ █████ ░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ v0.9.0-nightly.20251001.163dba7e Tips for getting started: 1. Ask questions, edit files, or run commands. 2. Be specific for the best results. 3. Create GEMINI.md files to customize your interactions with Gemini. 4. /help for more information. > /mcp Configured MCP servers: 🟢 serverName - Ready (7 tools, 2 prompts) Tools: - get_abstract_syntax_tree - get_supported_languages - semgrep_findings - semgrep_rule_schema - semgrep_scan - semgrep_scan_supply_chain - semgrep_scan_with_custom_rule Prompts: - setup_semgrep_mcp - write_custom_semgrep_rule 💡 Tips: - Use /mcp desc to show server and tool descriptions - Use /mcp schema to show tool parameter schemas - Use /mcp nodesc to hide descriptions - Use /mcp auth <server-name> to authenticate with OAuth-enabled servers - Press Ctrl+T to toggle tool descriptions on/off Using: 1 MCP server (ctrl+t to view) ╭──────────────────────────────────────────────────────────────────────────────────╮ │ > Type your message or @path/to/file │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ~/Desktop/semgrep-proprietary no sandbox (see gemini-2.5-pro (100% (katrina/mcp-types*) /docs) context left) ``` Also tested that Cursor was able to call `semgrep_scan` after the change with the GPT-5 model (and that it was not able to call the tool nicely before the change)  synced from Pro 6ee3493829fff70665a892703aef809bf8899094
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com> Co-authored-by: anthony bushong <agmsb@users.noreply.github.com> Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com> Co-authored-by: Sandy Tao <sandytao520@icloud.com> Co-authored-by: Jacob MacDonald <jakemac@google.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: christine betts <chrstn@uw.edu> Co-authored-by: Adam Weidman <65992621+adamfweidman@users.noreply.github.com> Co-authored-by: matt korwel <matt.korwel@gmail.com> Co-authored-by: Shreya Keshive <skeshive@gmail.com> Co-authored-by: HugoMurillo <mhugorodrigo@google.com> Co-authored-by: Shreya Keshive <shreyakeshive@google.com> Co-authored-by: Miguel Solorio <miguelsolorio@google.com> Co-authored-by: Christie Warwick (Wilson) <bobcatfish@gmail.com> Co-authored-by: shrutip90 <shruti.p90@gmail.com>
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com> Co-authored-by: anthony bushong <agmsb@users.noreply.github.com> Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com> Co-authored-by: Sandy Tao <sandytao520@icloud.com> Co-authored-by: Jacob MacDonald <jakemac@google.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: christine betts <chrstn@uw.edu> Co-authored-by: Adam Weidman <65992621+adamfweidman@users.noreply.github.com> Co-authored-by: matt korwel <matt.korwel@gmail.com> Co-authored-by: Shreya Keshive <skeshive@gmail.com> Co-authored-by: HugoMurillo <mhugorodrigo@google.com> Co-authored-by: Shreya Keshive <shreyakeshive@google.com> Co-authored-by: Miguel Solorio <miguelsolorio@google.com> Co-authored-by: Christie Warwick (Wilson) <bobcatfish@gmail.com> Co-authored-by: shrutip90 <shruti.p90@gmail.com>
TLDR
This change removes the
hasValidTypesmethod added in #5694 as the check is overly restrictive and prevents the use of valid MCP tools.Dive Deeper
The
hasValidTypesmethod attempted to enforce that MCP tools provide a JSON schema that would be accepted by the Gemini/Vertex AI APIs (after first being converted into a FunctionDeclaration by the GenAI SDK). The restriction was added in response to #4594 and (related): awslabs/mcp#661However, the JSON schema generated by the MCP server referenced in those issues is a valid JSON schema and has types defined for all the schema elements. The MCP inputSchema is:
This JSON schema uses JSON pointer references. The
hasValidTypesmethod incorrectly rejects MCP tools that use this JSON schema feature.The original error was caused by lossy conversion of the MCP input schema in the GenAI SDK. The information loss was remediated by setting the
functionDeclaration.parametersJsonSchemainstead of converting to the genai-js types.Schema object and setting thefunctionDeclaration.parametersfield. This change was made in: googleapis/js-genai@36f6350#diff-fdde9372aec859322b7c5a5efe467e0ad25a57210c7229724586ee90ea4f5a30The original intent of #5694 was to prevent one bad MCP tool schema from causing all Gemini API calls to fail. The underlying issue was never with the MCP tool schemas, however, and the Gemini API accepts JSON schemas that use $ref/$def or even omit type information altogether.
Reviewer Test Plan
Use GCLI with any MCP tool that uses the $refs JSON schema feature. The tool should no longer be filtered out during initialization. Gemini API calls should succeed and the tool should work as expected.
Testing Matrix
Linked issues / bugs
Fixes #6219