Skip to content

Conversation

mbleigh
Copy link
Contributor

@mbleigh mbleigh commented May 21, 2025

Had a report from a fellow Googler that the MCP server was throwing errors when used with ADK. While I had done testing with Genkit, we do some manual massaging of JSON schemas in Genkit to work around Gemini limitations.

This brings some of those workarounds directly to the MCP server. I also added a smoke test that can be run from scripts/mcp-tests to load all tool definitions into a simple Gemini model call so we can easily verify this going forward (automated would be great but I don't have time to figure that out today).

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.07%. Comparing base (2263d68) to head (6852bfc).
Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8637      +/-   ##
==========================================
+ Coverage   51.04%   51.07%   +0.03%     
==========================================
  Files         431      431              
  Lines       30986    31001      +15     
  Branches     6367     6368       +1     
==========================================
+ Hits        15818    15835      +17     
+ Misses      13752    13751       -1     
+ Partials     1416     1415       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@fredzqm fredzqm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an temporary thing or a "semi-permanent"?

Do other LLM run into similar issues?

} else {
const rtext = await response.text();
try {
console.dir(JSON.parse(rtext), { depth: null });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we know if the response conforms to what the tool expect?

Do we need to do some sort of zod validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of the smoke test is to make sure the Gemini API doesn't throw errors based on any of the tool input schemas provided - it's not testing actual tool calling. This is more of a sanity check than a complete solution, but is better than nothing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, what kind of error it may throw?

Does the Gemini API do any validation to make sure the response match the spec?

We can probably add that validation here later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tool schemas don't conform to the limited schema supported by Gemini, the request will 400 even if it's only one tool out of 35 that are broken. That's bad, so this smoke test ensures that all of our tools are vaild as far as the API is concerned.

Copy link
Contributor

@fredzqm fredzqm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool, script! Thanks for codify it!

Feel like we should add some manual test instructions to CONTRIBUTIONS.md of mcp.

@mbleigh mbleigh enabled auto-merge (squash) May 21, 2025 23:15
@mbleigh mbleigh merged commit 2ed56de into master May 21, 2025
48 of 50 checks passed
@mbleigh mbleigh deleted the mb/mcp/gemini-schema branch May 21, 2025 23:21
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions May 21, 2025
@billyjacobson
Copy link

Thank you for this fix! Looking forward to using :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants