delete-document
Remove a document by its ID from a Meilisearch index to manage search data and maintain index accuracy.
Instructions
Delete a document by its ID from a Meilisearch index
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | Yes | Unique identifier of the index | |
| documentId | Yes | ID of the document to delete |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"documentId": {
"description": "ID of the document to delete",
"type": "string"
},
"indexUid": {
"description": "Unique identifier of the index",
"type": "string"
}
},
"required": [
"indexUid",
"documentId"
],
"type": "object"
}
Implementation Reference
- src/tools/document-tools.ts:201-210 (handler)Handler function that deletes the specified document from the Meilisearch index by issuing a DELETE request to the API endpoint.async ({ indexUid, documentId }: DeleteDocumentParams) => { try { const response = await apiClient.delete(`/indexes/${indexUid}/documents/${documentId}`); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } }
- src/tools/document-tools.ts:197-200 (schema)Zod schema defining the input parameters for the delete-document tool: indexUid and documentId.{ indexUid: z.string().describe('Unique identifier of the index'), documentId: z.string().describe('ID of the document to delete'), },
- src/tools/document-tools.ts:194-211 (registration)Direct registration of the delete-document tool using server.tool(), specifying name, description, input schema, and handler.server.tool( 'delete-document', 'Delete a document by its ID from a Meilisearch index', { indexUid: z.string().describe('Unique identifier of the index'), documentId: z.string().describe('ID of the document to delete'), }, async ({ indexUid, documentId }: DeleteDocumentParams) => { try { const response = await apiClient.delete(`/indexes/${indexUid}/documents/${documentId}`); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } );
- src/index.ts:65-65 (registration)Top-level registration call that invokes the document tools module, including delete-document.registerDocumentTools(server);
- src/tools/document-tools.ts:40-43 (schema)TypeScript interface defining the parameters for the delete-document handler.interface DeleteDocumentParams { indexUid: string; documentId: string; }