Skip to content

fix: preserve MCP JSON Schema references in Gemini tool declarations - #564

Merged
chenyme merged 1 commit into
devfrom
mcp_tool
Aug 3, 2026
Merged

fix: preserve MCP JSON Schema references in Gemini tool declarations#564
chenyme merged 1 commit into
devfrom
mcp_tool

Conversation

@chenyme

@chenyme chenyme commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes MCP tool schemas losing $ref branches when converted for Gemini.

Generate Content now uses the official parametersJsonSchema field, while Gemini Interactions passes the original JSON Schema directly. This preserves array items, property references, anyOf, and $defs without custom dereferencing or compatibility code.

Change type

  • Bug fix

Affected areas

  • Backend / API
  • Conversations / streaming
  • MCP / tools

Verification

  • cd backend && go test ./... -count=1
  • cd backend && go test -race ./internal/infra/llm -count=1
  • cd backend && go vet ./...
  • cd backend && make build
  • git diff --check

Screenshots, API examples, or logs

Not applicable.

Configuration, migration, and compatibility notes

  • No configuration or database changes.
  • No migration required.
  • No API contract changes outside Gemini tool declaration payloads.
  • MCP schemas are passed through using the current official Gemini JSON Schema fields.
  • External $ref URLs are not resolved or fetched.

Documentation

  • Documentation is not needed for this change.

Security and privacy

  • No secrets, tokens, credentials, or personal data are included.
  • User data access remains scoped by authenticated user context.
  • No external schema references are fetched.
  • Security-sensitive behavior was reviewed.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests and static verification were run.
  • User-facing behavior and API compatibility impact were reviewed.
  • Generated artifacts are not included.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme self-assigned this Aug 3, 2026
@chenyme
chenyme merged commit d38ed7d into dev Aug 3, 2026
11 checks passed
@chenyme
chenyme deleted the mcp_tool branch August 3, 2026 11:50
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.

[Bug]: MCP tools using $ref in JSON Schema lose items when converted to Gemini function declarations (HTTP 400 "items: missing field")

1 participant