contentrain_content_delete
Delete content entries or specific dictionary keys from Contentrain MCP. Changes are automatically committed to git after confirmation.
Instructions
Delete content entries. For dictionaries, use "keys" to remove specific keys (omit to delete entire locale file). Changes are auto-committed to git — do NOT manually edit .contentrain/ files after calling this tool.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Model ID | |
| id | No | Entry ID (collection) | |
| slug | No | Slug (document) | |
| locale | No | Locale code | |
| keys | No | Dictionary only: specific keys to remove. Omit to delete entire locale file. | |
| confirm | Yes | Must be true to confirm deletion |
Implementation Reference
- The handler function that executes the content deletion, including transaction management, branch health checks, and calling the underlying deleteContent logic.
async (input) => { const config = await readConfig(projectRoot) if (!config) { return { content: [{ type: 'text' as const, text: JSON.stringify({ error: 'Project not initialized.' }) }], isError: true, } } const model = await readModel(projectRoot, input.model) if (!model) { return { content: [{ type: 'text' as const, text: JSON.stringify({ error: `Model "${input.model}" not found` }) }], isError: true, } } // Branch health gate const deleteHealth = await checkBranchHealth(projectRoot) if (deleteHealth.blocked) { return { content: [{ type: 'text' as const, text: JSON.stringify({ error: deleteHealth.message, action: 'blocked', hint: 'Merge or delete old contentrain/* branches before creating new ones.', }, null, 2) }], isError: true, } } const branch = buildBranchName('content', input.model) const tx = await createTransaction(projectRoot, branch) try { let removed: string[] = [] await tx.write(async (wt) => { removed = await deleteContent(wt, model, { id: input.id, slug: input.slug, locale: input.locale, keys: input.keys, }) }) await tx.commit(`[contentrain] delete content: ${input.model}`) const gitResult = await tx.complete({ tool: 'contentrain_content_delete', model: input.model, locale: input.locale, }) return { content: [{ type: 'text' as const, text: JSON.stringify({ status: 'committed', message: 'Content deleted and committed to git. Do NOT manually edit .contentrain/ files.', deleted: true, files_removed: removed, git: { branch, action: gitResult.action, commit: gitResult.commit }, context_updated: true, }, null, 2) }], } } catch (error) { await tx.cleanup() return { content: [{ type: 'text' as const, text: JSON.stringify({ error: `Delete failed: ${error instanceof Error ? error.message : String(error)}`, }) }], isError: true, } } finally { await tx.cleanup() } }, - The input schema defining parameters for the content deletion tool, including model, id, slug, locale, keys, and confirmation.
{ model: z.string().describe('Model ID'), id: z.string().optional().describe('Entry ID (collection)'), slug: z.string().optional().describe('Slug (document)'), locale: z.string().optional().describe('Locale code'), keys: z.array(z.string()).optional().describe('Dictionary only: specific keys to remove. Omit to delete entire locale file.'), confirm: z.literal(true).describe('Must be true to confirm deletion'), }, - packages/mcp/src/tools/content.ts:164-166 (registration)Registration of the 'contentrain_content_delete' tool within the MCP server instance.
server.tool( 'contentrain_content_delete', 'Delete content entries. For dictionaries, use "keys" to remove specific keys (omit to delete entire locale file). Changes are auto-committed to git — do NOT manually edit .contentrain/ files after calling this tool.',