create-index
Create a new Meilisearch index with a unique identifier and optional primary key to organize searchable data.
Instructions
Create a new Meilisearch index
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | Yes | Unique identifier for the new index | |
| primaryKey | No | Primary key for the index |
Implementation Reference
- src/tools/index-tools.ts:92-112 (registration)Primary registration of the 'create-index' tool with MCP server, including Zod input schema validation and the inline asynchronous handler function that executes the tool logic by making a POST request to the Meilisearch '/indexes' API endpoint.server.tool( 'create-index', 'Create a new Meilisearch index', { indexUid: z.string().describe('Unique identifier for the new index'), primaryKey: z.string().optional().describe('Primary key for the index'), }, async ({ indexUid, primaryKey }: CreateIndexParams) => { try { const response = await apiClient.post('/indexes', { uid: indexUid, primaryKey, }); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } );
- src/tools/index-tools.ts:23-26 (schema)TypeScript type definition for the parameters accepted by the 'create-index' tool handler.interface CreateIndexParams { indexUid: string; primaryKey?: string; }
- src/index.ts:64-64 (registration)Top-level registration call that invokes the index tools module registration, thereby making the 'create-index' tool available on the MCP server.registerIndexTools(server);