Tool: create_index
Create a composite index.
The following code sample shows how to use curl to call the create_index MCP tool.
| Curl Request |
|---|
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": "create_index", "arguments": { // Provide these details according to the MCP tool specification. } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
The request for [FirestoreAdmin.CreateIndex][].
CreateIndexRequest
| JSON representation |
|---|
{
"parent": string,
"index": {
object ( |
| Fields | |
|---|---|
parent |
Required. A parent name of the form |
index |
Required. The composite index to create. |
Index
| JSON representation |
|---|
{ "name": string, "queryScope": enum ( |
| Fields | |
|---|---|
name |
Output only. A server defined name for this index. The form of this name for composite indexes will be: |
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 |
The API scope supported by this index. |
fields[] |
A field in an index. The field_path describes which field is indexed, the value_mode describes how the field value is indexed. |
state |
Output only. The serving state of the index. |
density |
Immutable. The density configuration of the index. |
multikey |
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 |
Optional. The number of shards for the index. |
unique |
Optional. Whether it is an unique index. Unique index ensures all values for the indexed field(s) are unique across documents. |
IndexField
| JSON representation |
|---|
{ "fieldPath": string, // Union field |
| Fields | |
|---|---|
fieldPath |
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 |
Indicates that this field supports ordering by the specified order or comparing using =, !=, <, <=, >, >=. |
arrayConfig |
Indicates that this field supports operations on |
vectorConfig |
Indicates that this field supports nearest neighbor and distance operations on vector. |
VectorConfig
| JSON representation |
|---|
{ "dimension": integer } |
| Fields | |
|---|---|
dimension |
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. |
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. |
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 Take for example the following document: an index on 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: an index on An index that contains |
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 |
Output Schema
This resource represents a long-running operation that is the result of a network API call.
Operation
| JSON representation |
|---|
{ "name": string, "metadata": { "@type": string, field1: ..., ... }, "done": boolean, // Union field |
| Fields | |
|---|---|
name |
The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the |
metadata |
Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. An object containing fields of an arbitrary type. An additional field |
done |
If the value is |
Union field result. The operation result, which can be either an error or a valid response. If done == false, neither error nor response is set. If done == true, exactly one of error or response can be set. Some services might not provide the result. result can be only one of the following: |
|
error |
The error result of the operation in case of failure or cancellation. |
response |
The normal, successful response of the operation. If the original method returns no data on success, such as An object containing fields of an arbitrary type. An additional field |
Any
| JSON representation |
|---|
{ "typeUrl": string, "value": string } |
| Fields | |
|---|---|
typeUrl |
Identifies the type of the serialized Protobuf message with a URI reference consisting of a prefix ending in a slash and the fully-qualified type name. Example: type.googleapis.com/google.protobuf.StringValue This string must contain at least one The prefix is arbitrary and Protobuf implementations are expected to simply strip off everything up to and including the last All type URL strings must be legal URI references with the additional restriction (for the text format) that the content of the reference must consist only of alphanumeric characters, percent-encoded escapes, and characters in the following set (not including the outer backticks): In the original design of |
value |
Holds a Protobuf serialization of the type described by type_url. A base64-encoded string. |
Status
| JSON representation |
|---|
{ "code": integer, "message": string, "details": [ { "@type": string, field1: ..., ... } ] } |
| Fields | |
|---|---|
code |
The status code, which should be an enum value of |
message |
A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the |
details[] |
A list of messages that carry the error details. There is a common set of message types for APIs to use. An object containing fields of an arbitrary type. An additional field |
Tool Annotations
Tool annotations 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: ❌