Skip to content

feat(firestore-mongodb): add firestore-execute-mql and firestore-get-… - #3826

Open
pl04351820 wants to merge 10 commits into
googleapis:mainfrom
pl04351820:feat/firestore-mongodb-tools
Open

feat(firestore-mongodb): add firestore-execute-mql and firestore-get-…#3826
pl04351820 wants to merge 10 commits into
googleapis:mainfrom
pl04351820:feat/firestore-mongodb-tools

Conversation

@pl04351820

Copy link
Copy Markdown

Description

This PR introduces two new Model Context Protocol (MCP) tools for Firestore with MongoDB-compatibility (NL2NoSQL) support:

  1. firestore-execute-mql (execute_mql):

    • Executes MongoDB Query Language (MQL) queries and aggregation pipelines directly against Firestore backend instances.
    • Wraps incoming MQL queries into a structuredPipeline with the "iql" stage and read_only: true option, dispatching to Firestore's documents:executePipeline endpoint with routing headers (x-goog-request-params and x-goog-firestore-api-requester).
  2. firestore-get-schema (get_schema):

    • Introspects collection structures and data schemas for Firestore collections.
    • Invokes the "get_schema" structured pipeline stage with mongodb semantics ({ "collection": "<name>", "semantics": "mongodb" }), flattening nested fields into dot-separated paths with their data types.
    • Includes graceful fallback document sampling when pipeline stages are unavailable.

Reference: go/fs-nl2nosql-mcp-tools

Summary of Changes:

  • internal/sources/firestore/firestore.go: Added ExecutePipeline and GetSchema methods with structured pipeline payloads and header context.
  • internal/tools/firestoremongodb/: Added firestore-execute-mql and firestore-get-schema tool implementations with parameters, annotations, and input validation.
  • Unit Tests: Added test suites covering YAML unmarshaling, mock tool invocations, destructive/read-only annotations, schema extraction, and type resolution (firestoreexecutemql_test.go, firestoregetschema_test.go, firestore_internal_test.go).
  • cmd/internal/imports.go: Registered new tool packages.
  • docs/en/integrations/firestore/tools/: Added documentation pages following Hugo documentation standards.

PR Checklist

  • Make sure you reviewed CONTRIBUTING.md
  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea.
  • Ensure you have manually reviewed the entire diff before requesting a review
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes #<issue_number_goes_here>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 introduces MongoDB Query Language (MQL) query execution and schema retrieval capabilities for Firestore by adding the firestore-execute-mql and firestore-get-schema tools, along with their respective documentation and unit tests. Feedback on the changes includes improving the robustness of the Firestore source implementation by using json.Marshal instead of fmt.Sprintf for query construction, capping the sampleSize to prevent potential memory issues, and including the response body in API error messages. Additionally, the reviewer noted that the firestore-execute-mql tool should default to read-only annotations rather than destructive annotations, which also requires updating the corresponding unit tests.

Comment thread internal/sources/firestore/firestore.go Outdated
Comment thread internal/sources/firestore/firestore.go Outdated
Comment thread internal/sources/firestore/firestore.go Outdated
Comment thread internal/tools/firestoremongodb/firestoreexecutemql/firestoreexecutemql.go Outdated
Comment thread internal/tools/firestoremongodb/firestoreexecutemql/firestoreexecutemql_test.go Outdated
@pl04351820
pl04351820 marked this pull request as ready for review August 14, 2026 16:34
@pl04351820
pl04351820 requested review from a team as code owners August 14, 2026 16:34
@pl04351820
pl04351820 enabled auto-merge (squash) August 14, 2026 16:34
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.

2 participants