update-index
Modify a Meilisearch index's primary key to ensure accurate document identification and retrieval within search operations.
Instructions
Update a Meilisearch index (currently only supports updating the primary key)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | Yes | Unique identifier of the index | |
| primaryKey | Yes | New primary key for the index |
Implementation Reference
- src/tools/index-tools.ts:122-133 (handler)The handler function that implements the logic for the 'update-index' tool by sending a PATCH request to update the primary key of the specified Meilisearch index.async ({ indexUid, primaryKey }: UpdateIndexParams) => { try { const response = await apiClient.patch(`/indexes/${indexUid}`, { primaryKey, }); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } }
- src/tools/index-tools.ts:28-31 (schema)Type definition for the input parameters of the update-index tool.interface UpdateIndexParams { indexUid: string; primaryKey: string; }
- src/tools/index-tools.ts:118-121 (schema)Zod schema for validating the input parameters of the 'update-index' tool.{ indexUid: z.string().describe('Unique identifier of the index'), primaryKey: z.string().describe('New primary key for the index'), },
- src/tools/index-tools.ts:115-134 (registration)Registration of the 'update-index' tool using server.tool() within the registerIndexTools function.server.tool( 'update-index', 'Update a Meilisearch index (currently only supports updating the primary key)', { indexUid: z.string().describe('Unique identifier of the index'), primaryKey: z.string().describe('New primary key for the index'), }, async ({ indexUid, primaryKey }: UpdateIndexParams) => { try { const response = await apiClient.patch(`/indexes/${indexUid}`, { primaryKey, }); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } );
- src/index.ts:64-64 (registration)Invocation of registerIndexTools on the main MCP server instance, which registers the 'update-index' tool among others.registerIndexTools(server);