delete-documents
Remove multiple documents by their IDs from a Meilisearch index to manage data and maintain search relevance.
Instructions
Delete multiple documents by their IDs from a Meilisearch index
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | Yes | Unique identifier of the index | |
| documentIds | Yes | JSON array of document IDs to delete |
Implementation Reference
- src/tools/document-tools.ts:221-241 (handler)Handler function that parses the provided documentIds (JSON string) into an array and deletes the batch using the Meilisearch API.async ({ indexUid, documentIds }: DeleteDocumentsParams) => { try { // Parse the document IDs string to ensure it's valid JSON const parsedDocumentIds = JSON.parse(documentIds); // Ensure document IDs is an array if (!Array.isArray(parsedDocumentIds)) { return { isError: true, content: [{ type: 'text', text: 'Document IDs must be a JSON array' }], }; } const response = await apiClient.post(`/indexes/${indexUid}/documents/delete-batch`, parsedDocumentIds); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } }
- src/tools/document-tools.ts:217-220 (schema)Zod input schema defining parameters for the delete-documents tool.{ indexUid: z.string().describe('Unique identifier of the index'), documentIds: z.string().describe('JSON array of document IDs to delete'), },
- src/tools/document-tools.ts:45-48 (schema)TypeScript interface for the parameters used in the handler.interface DeleteDocumentsParams { indexUid: string; documentIds: string; }
- src/index.ts:65-65 (registration)Top-level registration call that invokes the document tools registration, including delete-documents.registerDocumentTools(server);
- src/tools/document-tools.ts:214-242 (registration)Specific registration of the delete-documents tool using server.tool, including schema and handler.server.tool( 'delete-documents', 'Delete multiple documents by their IDs from a Meilisearch index', { indexUid: z.string().describe('Unique identifier of the index'), documentIds: z.string().describe('JSON array of document IDs to delete'), }, async ({ indexUid, documentIds }: DeleteDocumentsParams) => { try { // Parse the document IDs string to ensure it's valid JSON const parsedDocumentIds = JSON.parse(documentIds); // Ensure document IDs is an array if (!Array.isArray(parsedDocumentIds)) { return { isError: true, content: [{ type: 'text', text: 'Document IDs must be a JSON array' }], }; } const response = await apiClient.post(`/indexes/${indexUid}/documents/delete-batch`, parsedDocumentIds); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } );