Manage Google Cloud Firestore databases via REST API
This skill is built on top of the official Firebase Firestore REST API reference documentation: https://firebase.google.com/docs/firestore/reference/rest
It enables you to interact with Google Cloud Firestore using the Firestore REST API through curl commands. It uses gcloud auth print-access-token to obtain authentication tokens, allowing you to perform Create, Read, Update, and Delete (CRUD) operations on Firestore documents and collections.
For related documentation:
This skill requires curl and gcloud CLI.
For full installation and setup instructions, see installation.md.
This skill uses OAuth 2.0 access tokens generated by gcloud auth print-access-token. The token is valid for a limited time (typically 1 hour) and inherits the permissions of the authenticated Google Cloud account.
This skill must run only with a dedicated service account context. Do not use personal user credentials or broad admin identities.
Before any operation, generate a fresh access token:
ACCESS_TOKEN=$(gcloud auth print-access-token)
Before any operation, verify the active identity is a service account:
gcloud config list --format='text(core.account,core.project)'
If the active account is not a service account (for example, it does not end with gserviceaccount.com), stop and ask the user to switch credentials before proceeding.
Security Recommendations:
gcloud config list before executing commands.gcloud auth revokeImportant: This skill can access Firestore data with the same permissions as the authenticated Google Cloud account. For safety, this skill requires explicit user approval before executing any operation, including read-only operations.
To minimize risk:
gcloud config list output before allowing any operationsroles/datastore.viewer for read-only access or roles/datastore.user for limited read/writeroles/datastore.owner or roles/owner with this skillYou can perform the following operations on Firestore databases:
All operations use the Firestore REST API endpoint:
https://firestore.googleapis.com/v1/projects/{PROJECT_ID}/databases/{DATABASE_ID}/documents
Before executing any Firestore operation, you MUST follow this workflow:
gcloud config list --format='text(core.account,core.project)' to display the active account and project. Present this to the user so they are aware of which credentials and project will be used.```bash
ACCESS_TOKEN=$(gcloud auth print-access-token)
```
Authorization: Bearer $ACCESS_TOKEN headerContent-Type: application/json for requests with bodyACCESS_TOKEN=$(gcloud auth print-access-token) before any operation.?documentId=YOUR_ID in the URL, Firestore will automatically generate a unique document ID.updateMask.fieldPaths to specify which fields to update.All operations require explicit user confirmation before execution.
This includes:
For every operation, the agent must:
Firestore uses typed field values in JSON. Common types:
stringValue — Text stringsintegerValue — Integer numbers (as strings)doubleValue — Floating-point numbersbooleanValue — true/falsetimestampValue — ISO 8601 timestampsarrayValue — Arrays of valuesmapValue — Nested objectsExample document structure:
{
"fields": {
"name": { "stringValue": "John Doe" },
"age": { "integerValue": "30" },
"active": { "booleanValue": true }
}
}
Few-shot prompts and full command examples are available in examples.md.
When constructing queries, use these operators in the fieldFilter.op field:
EQUAL — Field equals valueNOT_EQUAL — Field does not equal valueLESS_THAN — Field is less than valueLESS_THAN_OR_EQUAL — Field is less than or equal to valueGREATER_THAN — Field is greater than valueGREATER_THAN_OR_EQUAL — Field is greater than or equal to valueARRAY_CONTAINS — Array field contains valueIN — Field value is in the provided arrayARRAY_CONTAINS_ANY — Array field contains any of the provided valuesFor dedicated troubleshooting guidance, see troubleshooting.md.
共 1 个版本