Пакетное удаление
bpm_batch_deleteDelete multiple records by UUID in one OData v4 $batch request. Supports continue on error. Action is irreversible.
Instructions
Удаляет несколько записей по UUID в одном $batch (только OData v4). Поддерживает continue_on_error. Действие необратимо.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | ||
| ids | Yes | Массив UUID записей для удаления | |
| continue_on_error | No | Не прерывать batch на первой ошибке |
Implementation Reference
- src/tools/batch-tools.ts:204-271 (handler)Handler function for bpm_batch_delete tool. Takes collection, ids array, and optional continue_on_error. Builds DELETE batch requests, executes via odataClient.executeBatch, and returns a summary of succeeded/failed operations.
// bpm_batch_delete { const meta = getTool('bpm_batch_delete'); server.registerTool( meta.name, { title: meta.title, description: meta.description, inputSchema: { collection: z.string(), ids: z.array(z.string()).describe('Массив UUID записей для удаления'), continue_on_error: z.boolean().optional().describe('Не прерывать batch на первой ошибке'), }, annotations: meta.annotations, }, async (params): Promise<CallToolResult> => { if (!services.initialized) return notInitialized(); try { await services.authManager.ensureAuthenticated(); if (params.ids.length === 0) { return { content: [{ type: 'text', text: 'Массив ID пуст. Нечего удалять.' }], isError: true }; } const batchRequests = params.ids.map((id) => ({ method: 'DELETE' as const, url: services.odataClient.buildRecordPath(params.collection, id), })); const result = await services.odataClient.executeBatch(batchRequests, params.continue_on_error ?? false); const succeeded = result.responses .map((r, i) => ({ index: i, ...r })) .filter((r) => r.status >= 200 && r.status < 300); const failed = result.responses .map((r, i) => ({ index: i, ...r })) .filter((r) => r.status >= 300); const lines = [ `Пакетное удаление из ${params.collection}:`, ` Всего запросов: ${params.ids.length}`, ` Успешно удалено: ${succeeded.length}`, ` Ошибок: ${failed.length}`, ]; if (failed.length > 0) { lines.push('', 'Ошибки:'); failed.forEach((f) => lines.push(` #${f.index + 1} (id=${params.ids[f.index]}): HTTP ${f.status} — ${JSON.stringify(f.body).slice(0, 300)}`) ); } return { content: [{ type: 'text', text: lines.join('\n') }], isError: failed.length > 0 && succeeded.length === 0, structuredContent: { collection: params.collection, total: params.ids.length, succeeded: succeeded.length, failed: failed.length, first_failed_index: failed.length > 0 ? failed[0].index : null, }, }; } catch (error) { const toolError = formatToolError(error, params.collection); return { content: [{ type: 'text', text: JSON.stringify(toolError, null, 2) }], isError: true }; } } ); } - src/tools/batch-tools.ts:212-216 (schema)Input schema for bpm_batch_delete: requires 'collection' (string), 'ids' (array of UUID strings), and optional 'continue_on_error' (boolean).
inputSchema: { collection: z.string(), ids: z.array(z.string()).describe('Массив UUID записей для удаления'), continue_on_error: z.boolean().optional().describe('Не прерывать batch на первой ошибке'), }, - src/tools/registry.ts:205-213 (registration)Tool descriptor registration in the TOOLS array: defines name, title, description, annotations (destructive=true), blurb, and category (batch).
{ name: 'bpm_batch_delete', title: 'Пакетное удаление', description: 'Удаляет несколько записей по UUID в одном $batch (только OData v4). Поддерживает continue_on_error. Действие необратимо.', annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true }, blurb: 'пакетное удаление (OData v4)', category: 'batch', }, - src/index.ts:72-72 (registration)Registration call that wires registerBatchTools into the MCP server startup sequence.
registerBatchTools(server, services);