Skip to content

feat(mcp): Add support for filtering on reference_value and timestamp_value in firestore_query_collection#10481

Open
MrAlek wants to merge 3 commits into
firebase:mainfrom
MrAlek:mcp-firestore-query-value-types
Open

feat(mcp): Add support for filtering on reference_value and timestamp_value in firestore_query_collection#10481
MrAlek wants to merge 3 commits into
firebase:mainfrom
MrAlek:mcp-firestore-query-value-types

Conversation

@MrAlek
Copy link
Copy Markdown

@MrAlek MrAlek commented May 9, 2026

Description

Adds the ability to filter on reference values and timestamps in the firestore MCP.

Scenarios Tested

Tested through MCP Inspector.

Sample Commands

  {
    "collection_path": "posts",
    "filters": [
      {
        "field": "author",
        "op": "EQUAL",
        "compare_value": { "reference_value": "users/abc123" }
      }
    ]
  }
  {
    "collection_path": "posts",
    "filters": [
      {
        "field": "createTime",
        "op": "EQUAL",
        "compare_value": { "timestamp_value": "2026-05-09T12:34:56Z" }
      }
    ]
  }

MrAlek added 2 commits May 9, 2026 10:19
Adds a `reference_value` field to the `compare_value` schema so MCP
clients can filter Firestore collections by document reference. Relative
document paths are expanded to a full resource name using the active
project and database; full resource names are passed through unchanged.
Adds a `timestamp_value` field to the `compare_value` schema, encoded as
a Firestore `timestampValue` (RFC 3339/ISO 8601) so MCP clients can
filter collections by date/time fields.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 enhances the Firestore tool by adding support for reference_value and timestamp_value filters in the query_collection tool, including automatic expansion of relative document paths to full resource names. Feedback highlights a critical bug in the filter validation logic that could lead to runtime crashes or incorrect filtering when multiple values are provided. Additionally, a violation of the repository style guide was noted regarding the use of generic errors instead of FirebaseError for user-facing exceptions.

Comment thread src/mcp/tools/firestore/query_collection.ts Outdated
Comment thread src/mcp/tools/firestore/converter.ts Outdated
…collection

The previous `&&`-chained guard only triggered when *all* compare_value
fields were set simultaneously, so it never caught a request with two
values, and an empty `compare_value` crashed on `out[0]` destructuring.
Switch to a length check so any count other than 1 produces a clean
error, and align with the rest of the file by returning the error
instead of throwing. Also use `mcpError` for the missing-projectId
guard in the firestore converter for consistency.
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