bulk_delete
Delete multiple memories permanently by their IDs in a single operation, supporting up to 100 IDs per call.
Instructions
Delete multiple memories at once by their IDs. Maximum 100 IDs per call. This is permanent.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ids | Yes | Array of memory IDs to delete (max 100) |
Implementation Reference
- src/tools.ts:554-561 (handler)The async handler function that executes the bulk_delete tool logic. It takes an array of memory IDs, calls the CogmemAi API's bulk-delete endpoint, and returns the result wrapped in MCP response format.
async ({ ids }) => { try { const result = await api('/cogmemai/bulk-delete', 'POST', { ids }); return wrapResult(result); } catch (error) { return wrapError(error); } } - src/tools.ts:544-562 (registration)Registration of the bulk_delete tool with the MCP server using server.tool(). Includes the tool name, description, input schema, and handler function.
server.tool( 'bulk_delete', 'Delete multiple memories at once by their IDs. Maximum 100 IDs per call. This is permanent.', { ids: z .array(z.coerce.number().int()) .min(1) .max(100) .describe('Array of memory IDs to delete (max 100)'), }, async ({ ids }) => { try { const result = await api('/cogmemai/bulk-delete', 'POST', { ids }); return wrapResult(result); } catch (error) { return wrapError(error); } } ); - src/tools.ts:547-553 (schema)Zod schema definition for bulk_delete input validation. Validates that 'ids' is an array of integers with minimum 1 and maximum 100 items.
{ ids: z .array(z.coerce.number().int()) .min(1) .max(100) .describe('Array of memory IDs to delete (max 100)'), }, - src/tools.ts:37-44 (helper)wrapResult helper function that formats successful API responses into MCP tool response format with optional context reminders.
function wrapResult(result: unknown, skipReminder = false): { content: Array<{ type: 'text'; text: string }> } { let text = JSON.stringify(result, null, 2); toolCallCount++; if (!contextLoaded && !skipReminder && toolCallCount <= MAX_REMINDER_CALLS) { text += CONTEXT_REMINDER; } return { content: [{ type: 'text' as const, text }] }; } - src/api.ts:74-120 (helper)The api() function that makes authenticated HTTP requests to the CogmemAi backend. Used by bulk_delete to call the /cogmemai/bulk-delete endpoint.
export async function api( path: string, method: 'GET' | 'POST' | 'PATCH' | 'DELETE' = 'GET', body?: Record<string, unknown>, timeoutMs?: number ): Promise<unknown> { const url = `${API_BASE}${path}`; const headers: Record<string, string> = { 'Content-Type': 'application/json', 'User-Agent': `CogmemAi-MCP/${VERSION}`, }; if (API_KEY) { headers['Authorization'] = `Bearer ${API_KEY}`; } const options: RequestInit = { method, headers }; if (body && method !== 'GET') { options.body = JSON.stringify(body); } // For GET with query params, append to URL if (body && method === 'GET') { const params = new URLSearchParams(); for (const [key, value] of Object.entries(body)) { if (value !== undefined && value !== null && value !== '') { params.set(key, String(value)); } } const qs = params.toString(); if (qs) { const separator = url.includes('?') ? '&' : '?'; const fullUrl = `${url}${separator}${qs}`; const res = await fetchWithRetry(fullUrl, { method, headers }, timeoutMs); const data = await res.json(); if (!res.ok) { if (res.status === 402) { throw new Error(format402Error(data)); } const error = (data as { error?: string }).error || `HTTP ${res.status}`; throw new Error(error); } return data; }