> [!WARNING]
>
> **Preview**
>
>
> This feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1), and the
> [Additional Terms for Generative AI
> Preview Products](https://cloud.google.com/trustedtester/aitos).
>
> Pre-GA features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

When you use the [context engineering agent](https://docs.cloud.google.com/gemini/data-agents/querydata/firestore-mongodb-compatibility/build-context-sets.md.txt), it can create and upload context sets automatically from your CLI. This document describes how to create, edit, and delete context sets in Firestore Studio when you want a visual interface in the Google Cloud console to manage context set files. When you create a context set in Firestore Studio, Firestore Studio stores it in the project's `default` context set group for the selected region and links it to the current database. Context set names (and their derived context set IDs) must be unique within the project's `default` context set group for a given region, across all databases and instances. In Firestore Studio, creating a context set with a name whose derived ID already exists fails validation; to overwrite its contents while keeping its database associations, edit the existing context set instead. Uploading directly through the context engineering agent or the Dataplex API with an existing context set ID replaces its contents and, if specified, its database associations.

The **Context sets** list in Firestore Studio shows only context sets in the `default` context set group across all supported regions that are linked to the current database. Context sets created for another database, or created through the API without linking the database resource in `databases` (or in a custom context set group), don't appear in the Firestore Studio list.
To learn about context sets, see [Context sets overview](https://docs.cloud.google.com/gemini/data-agents/querydata/firestore-mongodb-compatibility/context-sets-overview.md.txt).

## Before you begin

Complete the following prerequisites before creating or uploading a context set.

Context sets can be created in the `us-central1`, `us-east1`, `europe-west4`,
and `asia-southeast1` regions.

### Enable required services

Enable the following services for your project:

- [Data Analytics API with Gemini](https://console.cloud.google.com/apis/library/geminidataanalytics.googleapis.com)
- [Gemini for Google Cloud API](https://console.cloud.google.com/apis/library/cloudaicompanion.googleapis.com)
- [Knowledge Catalog API](https://console.cloud.google.com/apis/library/dataplex.googleapis.com)

### Prepare a Firestore database

Make sure that you have a Firestore Enterprise edition database with MongoDB compatibility.

If you're trying the examples on this page, we recommend that you create a new database for this purpose. For more information, see
[Create and manage databases](https://docs.cloud.google.com/firestore/mongodb-compatibility/docs/create-databases.md.txt).

### Required roles and permissions

- Grant the `roles/datastore.viewer`, `roles/serviceusage.serviceUsageConsumer`, and `roles/geminidataanalytics.queryDataUser` roles to the IAM user at the project level. For more information, see [Add IAM policy binding for a project](https://docs.cloud.google.com/sdk/gcloud/reference/projects/add-iam-policy-binding).

## Create a context set

To create a context set, perform the following steps:

1. In the Google Cloud console, go to the Firestore page.


   [Go to Firestore](https://console.cloud.google.com/firestore)
2. Select a database from the list. The database must be of the type **Firestore with MongoDB compatibility**.

3. In the navigation menu, click **Firestore Studio**.

4. In the **Explorer pane** , next to **Context sets** , click **View actions**.

5. Click **Create context set**.

6. In **Context set name** , provide a unique context set name. In **Firestore Studio** , the name must be 4 to 30 characters long and cannot begin with whitespace; Studio derives the context set ID by converting the name to lowercase and replacing non-alphanumeric characters with hyphens (`-`), and the derived context set ID must be unique within the project's `default` context set group for the selected region. For example, the context set name `querydata_e2e_test` has the context set ID `querydata-e2e-test`. When you upload a context set directly using the context engineering agent or the Dataplex API, the context set ID is case-sensitive, cannot contain slashes (`/`), and is not restricted to 4 to 30 characters or alphanumeric characters, hyphens, and underscores.

7. Optional. In **Context set description**, add a description for your context set.

8. Optional. To upload a context set file, click **Browse** in the **Upload context set file** section, and select the context set file.

9. Optional. To choose a region for the context set, click **Show Advanced Options** and select a region in **Select a location** (defaults to `us-east1` on each creation). If you choose a region other than `us-east1`, select the region before entering the context set name so Firestore Studio validates name uniqueness in that region.

10. Click **Create**.

> [!NOTE]
> **Note:** Creating a context set from **Firestore Studio** can take up to a few minutes while Firestore Studio processes the context set. Creating or uploading a context set through the context engineering agent or the Dataplex API typically completes in a few seconds.

## Build context sets

If you created an empty context set in Studio, or want to update an existing one, follow the steps in [Build and optimize context sets with the context engineering agent](https://docs.cloud.google.com/gemini/data-agents/querydata/firestore-mongodb-compatibility/build-context-sets.md.txt) to generate and optimize a context set file. The context engineering agent can create and upload your context set directly from the CLI, or you can edit your context set in Studio to upload the context set file manually.

## Edit a context set

To edit a context set, perform the following steps:

1. In the Google Cloud console, go to the Firestore page.


   [Go to Firestore](https://console.cloud.google.com/firestore)
2. Select the database from the list.

3. In the navigation menu, click **Firestore Studio**.

4. Click **View actions** next to the context set you want to edit.

5. Click **Edit context set**.

6. Optional. Edit **Context set description**.

7. Click **Browse** in the **Upload context set file** section, and select the context set file.

8. Click **Save**.

## Delete a context set

To delete a context set, perform the following steps:

1. In the Google Cloud console, go to the Firestore page.


   [Go to Firestore](https://console.cloud.google.com/firestore)
2. Select the database from the list.

3. In the navigation menu, click **Firestore Studio**.

4. Click **View actions** next to the context set you want to delete.

5. Click **Delete context set**.

6. In the **Delete context set** confirmation dialog, enter the ID of the context set.

7. Click **Confirm** to delete the context set.

> [!NOTE]
> **Note:** Deleting a database does not delete its context sets. To avoid orphaned context sets that still expose schema details, delete them before you delete the database.

## What's next

- Learn more about [context sets](https://docs.cloud.google.com/gemini/data-agents/querydata/firestore-mongodb-compatibility/context-sets-overview.md.txt).
- Learn how to [test QueryData in Firestore Studio](https://docs.cloud.google.com/gemini/data-agents/querydata/firestore-mongodb-compatibility/inspect-data-agent.md.txt).
- Learn how to [build and optimize context sets with the context engineering agent](https://docs.cloud.google.com/gemini/data-agents/querydata/firestore-mongodb-compatibility/build-context-sets.md.txt).
- Learn how to [integrate QueryData with an application](https://docs.cloud.google.com/gemini/data-agents/querydata/firestore-mongodb-compatibility/integrate-applications-data-agent.md.txt).