Skip to main content
Glama
OrionPotter

Meilisearch MCP Server

by OrionPotter

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

NameRequiredDescriptionDefault
indexUidYesUnique identifier of the index
documentIdsYesJSON array of document IDs to delete

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "documentIds": { "description": "JSON array of document IDs to delete", "type": "string" }, "indexUid": { "description": "Unique identifier of the index", "type": "string" } }, "required": [ "indexUid", "documentIds" ], "type": "object" }

Implementation Reference

  • Handler function that parses the input documentIds as JSON array, validates it's an array, and performs batch delete via POST to Meilisearch API /indexes/{indexUid}/documents/delete-batch endpoint. Returns formatted response or error.
    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); } }
  • Zod input schema defining parameters: indexUid (string) and documentIds (string representing JSON array of IDs).
    { indexUid: z.string().describe('Unique identifier of the index'), documentIds: z.string().describe('JSON array of document IDs to delete'), },
  • MCP server.tool registration for 'delete-documents', specifying name, description, input schema, and handler function.
    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); } } );
  • src/index.ts:65-65 (registration)
    Top-level invocation of registerDocumentTools on the MCP server instance, which registers the 'delete-documents' tool among others.
    registerDocumentTools(server);
  • TypeScript interface defining the parameters for the delete-documents handler.
    interface DeleteDocumentsParams { indexUid: string; documentIds: string; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OrionPotter/iflow-mcp_meilisearch-ts-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server