cancel-tasks
Cancel queued or processing tasks in Meilisearch by filtering by status, type, index, or task ID to manage task execution and resource allocation.
Instructions
Cancel tasks based on provided filters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| statuses | No | Statuses of tasks to cancel | |
| types | No | Types of tasks to cancel | |
| indexUids | No | UIDs of the indexes on which tasks to cancel were performed | |
| uids | No | UIDs of the tasks to cancel |
Implementation Reference
- src/tools/task-tools.ts:107-122 (handler)The core handler function for the "cancel-tasks" tool. It constructs a request body from the input filters and sends a POST request to the Meilisearch API endpoint `/tasks/cancel`, returning the response as text content or an error.async ({ statuses, types, indexUids, uids }: CancelTasksParams) => { try { const body: Record<string, any> = {}; if (statuses && statuses.length > 0) body.statuses = statuses; if (types && types.length > 0) body.types = types; if (indexUids && indexUids.length > 0) body.indexUids = indexUids; if (uids && uids.length > 0) body.uids = uids; const response = await apiClient.post('/tasks/cancel', body); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } }
- src/tools/task-tools.ts:101-106 (schema)Zod schema defining the input parameters for the "cancel-tasks" tool, including optional filters for statuses, types, indexUids, and uids.{ statuses: z.array(z.enum(["enqueued", "processing"])).optional().describe("Statuses of tasks to cancel"), types: z.array(z.enum(["indexCreation", "indexUpdate", "indexDeletion", "documentAddition", "documentUpdate", "documentDeletion", "settingsUpdate", "dumpCreation", "taskCancelation"])).optional().describe("Types of tasks to cancel"), indexUids: z.array(z.string()).optional().describe("UIDs of the indexes on which tasks to cancel were performed"), uids: z.array(z.number()).optional().describe("UIDs of the tasks to cancel"), },
- src/tools/task-tools.ts:98-123 (registration)Direct registration of the "cancel-tasks" tool using server.tool(), including name, description, input schema, and handler reference.server.tool( "cancel-tasks", "Cancel tasks based on provided filters", { statuses: z.array(z.enum(["enqueued", "processing"])).optional().describe("Statuses of tasks to cancel"), types: z.array(z.enum(["indexCreation", "indexUpdate", "indexDeletion", "documentAddition", "documentUpdate", "documentDeletion", "settingsUpdate", "dumpCreation", "taskCancelation"])).optional().describe("Types of tasks to cancel"), indexUids: z.array(z.string()).optional().describe("UIDs of the indexes on which tasks to cancel were performed"), uids: z.array(z.number()).optional().describe("UIDs of the tasks to cancel"), }, async ({ statuses, types, indexUids, uids }: CancelTasksParams) => { try { const body: Record<string, any> = {}; if (statuses && statuses.length > 0) body.statuses = statuses; if (types && types.length > 0) body.types = types; if (indexUids && indexUids.length > 0) body.indexUids = indexUids; if (uids && uids.length > 0) body.uids = uids; const response = await apiClient.post('/tasks/cancel', body); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } );
- src/index.ts:70-70 (registration)Invocation of registerTaskTools on the main MCP server instance, which in turn registers the "cancel-tasks" tool among other task tools.registerTaskTools(server);