## Tool: `get_index`

Get a Firestore index.

The following code sample shows how to use `curl` to call the `get_index` MCP tool.

| Curl Request |
|---|
| ```bash curl --location 'https://firestore.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "get_index", "arguments": { // Provide these details according to the MCP tool specification. } }, "jsonrpc": "2.0", "id": 1 }' ``` |

## Input Schema

The request for `FirestoreAdmin.GetIndex`.

### GetIndexRequest

| JSON representation |
|---|
| ``` { "name": string } ``` |

| Fields ||
|---|---|
| `name` | `string` Required. A name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` |

## Output Schema

Cloud Firestore indexes enable simple and complex queries against documents in a database.

In Standard edition databases, single-field indexes are managed using the `google.firestore.admin.v1.Field` resource, and composite indexes are managed using the `https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.Index` resource.

In Enterprise edition databases, both single-field and composite indexes are managed using the `https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.Index` resource.

### Index

| JSON representation |
|---|
| ``` { "name": string, "queryScope": enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.QueryScope`), "apiScope": enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.ApiScope`), "fields": [ { object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.IndexField`) } ], "state": enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.State`), "density": enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.Density`), "multikey": boolean, "shardCount": integer, "unique": boolean, "searchIndexOptions": { object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchIndexOptions`) } } ``` |

| Fields ||
|---|---|
| `name` | `string` A server-defined name for this index. Output only. When used in the `https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.Index` resource, the value is of the form: `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` When used in the `google.firestore.admin.v1.Field` resource, the value is empty. |
| `queryScope` | ``enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.QueryScope`)`` Indexes with a collection query scope specified allow queries against a collection that is the child of a specific document, specified at query time, and that has the same collection ID. Indexes with a collection group query scope specified allow queries against all collections descended from a specific document, specified at query time, and that have the same collection ID as this index. |
| `apiScope` | ``enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.ApiScope`)`` The API scope supported by this index. |
| `fields[]` | ``object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.IndexField`)`` The fields supported by this index. At most 100 fields may be specified. In Standard edition databases only: - At least 2 fields must be specified. - The last field entry is always for the field path `__name__`. If, on creation, `__name__` was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in the index is not directional, the `__name__` will be ordered ASCENDING (unless explicitly specified). |
| `state` | ``enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.State`)`` Output only. The serving state of the index. |
| `density` | ``enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.Density`)`` Immutable. The density configuration of the index. |
| `multikey` | `boolean` Optional. Whether the index is multikey. By default, the index is not multikey. For non-multikey indexes, none of the paths in the index definition reach or traverse an array, except via an explicit array index. For multikey indexes, at most one of the paths in the index definition reach or traverse an array, except via an explicit array index. Violations will result in errors. Note this field only applies to index with MONGODB_COMPATIBLE_API ApiScope. |
| `shardCount` | `integer` Optional. The number of shards for the index. |
| `unique` | `boolean` Optional. Whether it is an unique index. Unique index ensures all values for the indexed field(s) are unique across documents. |
| `searchIndexOptions` | ``object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchIndexOptions`)`` Optional. Options for search indexes that are at the index definition level. This field is only currently supported for indexes with MONGODB_COMPATIBLE_API ApiScope. |

### IndexField

| JSON representation |
|---|
| ``` { "fieldPath": string, // Union field `value_mode` can be only one of the following: "order": enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.Order`), "arrayConfig": enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.ArrayConfig`), "vectorConfig": { object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.VectorConfig`) }, "searchConfig": { object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchConfig`) } // End of list of possible types for union field `value_mode`. } ``` |

| Fields ||
|---|---|
| `fieldPath` | `string` Can be **name**. For single field indexes, this must match the name of the field or may be omitted. |
| Union field `value_mode`. How the field value is indexed. `value_mode` can be only one of the following: ||
| `order` | ``enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.Order`)`` Indicates that this field supports ordering by the specified order or comparing using =, !=, \<, \<=, \>, \>=. |
| `arrayConfig` | ``enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/create_index#Input.Schema.ArrayConfig`)`` Indicates that this field supports operations on `array_value`s. |
| `vectorConfig` | ``object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.VectorConfig`)`` Indicates that this field supports nearest neighbor and distance operations on vector. |
| `searchConfig` | ``object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchConfig`)`` Indicates that this field supports search operations. |
|   ||

### VectorConfig

| JSON representation |
|---|
| ``` { "dimension": integer, // Union field `type` can be only one of the following: "flat": { object (`FlatIndex`) } // End of list of possible types for union field `type`. } ``` |

| Fields ||
|---|---|
| `dimension` | `integer` Required. The vector dimension this configuration applies to. The resulting index will only include vectors of this dimension, and can be used for vector search with the same dimension. |
| Union field `type`. The type of index used. `type` can be only one of the following: ||
| `flat` | ``object (`FlatIndex`)`` Indicates the vector index is a flat index. |
|   ||

### SearchConfig

| JSON representation |
|---|
| ``` { "textSpec": { object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchTextSpec`) }, "geoSpec": { object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchGeoSpec`) } } ``` |

| Fields ||
|---|---|
| `textSpec` | ``object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchTextSpec`)`` Optional. The specification for building a text search index for a field. |
| `geoSpec` | ``object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchGeoSpec`)`` Optional. The specification for building a geo search index for a field. |

### SearchTextSpec

| JSON representation |
|---|
| ``` { "indexSpecs": [ { object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchTextIndexSpec`) } ] } ``` |

| Fields ||
|---|---|
| `indexSpecs[]` | ``object (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.SearchTextIndexSpec`)`` Required. Specifications for how the field should be indexed. Repeated so that the field can be indexed in multiple ways. |

### SearchTextIndexSpec

| JSON representation |
|---|
| ``` { "indexType": enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.TextIndexType`), "matchType": enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.TextMatchType`) } ``` |

| Fields ||
|---|---|
| `indexType` | ``enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.TextIndexType`)`` Required. How to index the text field value. |
| `matchType` | ``enum (`https://docs.cloud.google.com/firestore/docs/reference/mcp/tools_list/get_index#Output.Schema.TextMatchType`)`` Required. How to match the text field value. |

### SearchGeoSpec

| JSON representation |
|---|
| ``` { "geoJsonIndexingDisabled": boolean } ``` |

| Fields ||
|---|---|
| `geoJsonIndexingDisabled` | `boolean` Optional. Disables geoJSON indexing for the field. By default, geoJSON points are indexed. Firestore GeoPoints are indexed regardless of the value of this field. |

### SearchIndexOptions

| JSON representation |
|---|
| ``` { "textLanguage": string, "textLanguageOverrideFieldPath": string } ``` |

| Fields ||
|---|---|
| `textLanguage` | `string` Optional. The language to use for text search indexes. Used as the default language if not overridden at the document level by specifying the `text_language_override_field`. The language is specified as a BCP 47 language code. For indexes with MONGODB_COMPATIBLE_API ApiScope: If unspecified, the default language is English. For indexes with `ANY_API` ApiScope: If unspecified, the default behavior is autodetect. |
| `textLanguageOverrideFieldPath` | `string` Optional. The field in the document that specifies which language to use for that specific document. For indexes with MONGODB_COMPATIBLE_API ApiScope: if unspecified, the language is taken from the "language" field if it exists or from `text_language` if it does not. |

### QueryScope

Query Scope defines the scope at which a query is run. This is specified on a StructuredQuery's `from` field.

| Enums ||
|---|---|
| `QUERY_SCOPE_UNSPECIFIED` | The query scope is unspecified. Not a valid option. |
| `COLLECTION` | Indexes with a collection query scope specified allow queries against a collection that is the child of a specific document, specified at query time, and that has the collection ID specified by the index. |
| `COLLECTION_GROUP` | Indexes with a collection group query scope specified allow queries against all collections that has the collection ID specified by the index. |
| `COLLECTION_RECURSIVE` | Include all the collections's ancestor in the index. Only available for Datastore Mode databases. |

### ApiScope

API Scope defines the APIs (Firestore Native, or Firestore in Datastore Mode) that are supported for queries.

| Enums ||
|---|---|
| `ANY_API` | The index can only be used by the Firestore Native query API. This is the default. |
| `DATASTORE_MODE_API` | The index can only be used by the Firestore in Datastore Mode query API. |
| `MONGODB_COMPATIBLE_API` | The index can only be used by the MONGODB_COMPATIBLE_API. |

### Order

The supported orderings.

| Enums ||
|---|---|
| `ORDER_UNSPECIFIED` | The ordering is unspecified. Not a valid option. |
| `ASCENDING` | The field is ordered by ascending field value. |
| `DESCENDING` | The field is ordered by descending field value. |

### ArrayConfig

The supported array value configurations.

| Enums ||
|---|---|
| `ARRAY_CONFIG_UNSPECIFIED` | The index does not support additional array queries. |
| `CONTAINS` | The index supports array containment queries. |

### TextIndexType

Ways to index the text field value.

| Enums ||
|---|---|
| `TEXT_INDEX_TYPE_UNSPECIFIED` | The index type is unspecified. Not a valid option. |
| `TOKENIZED` | Field values are tokenized. This is the only way currently supported for MONGODB_COMPATIBLE_API. |

### TextMatchType

Types of text matches that are supported for the field.

| Enums ||
|---|---|
| `TEXT_MATCH_TYPE_UNSPECIFIED` | The match type is unspecified. Not a valid option. |
| `MATCH_GLOBALLY` | Match on any indexed field. This is the only way currently supported for MONGODB_COMPATIBLE_API. |

### State

The state of an index. During index creation, an index will be in the `CREATING` state. If the index is created successfully, it will transition to the `READY` state. If the index creation encounters a problem, the index will transition to the `NEEDS_REPAIR` state.

| Enums ||
|---|---|
| `STATE_UNSPECIFIED` | The state is unspecified. |
| `CREATING` | The index is being created. There is an active long-running operation for the index. The index is updated when writing a document. Some index data may exist. |
| `READY` | The index is ready to be used. The index is updated when writing a document. The index is fully populated from all stored documents it applies to. |
| `NEEDS_REPAIR` | The index was being created, but something went wrong. There is no active long-running operation for the index, and the most recently finished long-running operation failed. The index is not updated when writing a document. Some index data may exist. Use the google.longrunning.Operations API to determine why the operation that last attempted to create this index failed, then re-create the index. |

### Density

The density configuration for the index.

| Enums ||
|---|---|
| `DENSITY_UNSPECIFIED` | Unspecified. It will use database default setting. This value is input only. |
| `SPARSE_ALL` | An index entry will only exist if ALL fields are present in the document. This is both the default and only allowed value for Standard edition databases (for both Cloud Firestore `ANY_API` and Cloud Datastore `DATASTORE_MODE_API`). Take for example the following document: { "__name__": "...", "a": 1, "b": 2, "c": 3 } an index on `(a ASC, b ASC, c ASC, __name__ ASC)` will generate an index entry for this document since `a`, 'b', `c`, and `__name__` are all present but an index of `(a ASC, d ASC, __name__ ASC)` will not generate an index entry for this document since `d` is missing. This means that such indexes can only be used to serve a query when the query has either implicit or explicit requirements that all fields from the index are present. |
| `SPARSE_ANY` | An index entry will exist if ANY field are present in the document. This is used as the definition of a sparse index for Enterprise edition databases. Take for example the following document: { "__name__": "...", "a": 1, "b": 2, "c": 3 } an index on `(a ASC, d ASC)` will generate an index entry for this document since `a` is present, and will fill in an `unset` value for `d`. An index on `(d ASC, e ASC)` will not generate any index entry as neither `d` nor `e` are present. An index that contains `__name__` will generate an index entry for all documents since Firestore guarantees that all documents have a `__name__` field. |
| `DENSE` | An index entry will exist regardless of if the fields are present or not. This is the default density for an Enterprise edition database. The index will store `unset` values for fields that are not present in the document. |

### Tool Annotations


[Tool annotations](https://modelcontextprotocol.io/specification/latest/schema#toolannotations) are sent to MCP clients to describe the basic risk of a given tool. Most clients treat these hints as untrusted, but they can be used to decide when a confirmation prompt might be sent to a user.


Along with the title string, the following boolean hints are defined as follows:

- `readOnlyHint`: If true, the tool doesn't modify its environment. Default: false.
- `destructiveHint`: If true, then the tool can perform destructive actions. If false, then the tool can only perform additive actions. Default: true.
- `idempotentHint`: If true, then calling the tool repeatedly with the same arguments will have no additional effect on its environment. Default: false.
- `openWorldHint`: If true, then the tool can interact with an 'open world' of external entities. If false, then the tool can only interact with internal entities. For example, a web search tool would be open world, while a memory tool would not be open world.

Destructive Hint: ❌ \| Idempotent Hint: ❌ \| Read Only Hint: ✅ \| Open World Hint: ❌