docx-removeContent
Remove a content block from a Word document by specifying the document ID and block index. Enables precise deletion of individual sections in a DOCX file.
Instructions
Remove a block at index.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| index | Yes |
Implementation Reference
- src/index.ts:69-72 (registration)Tool registration: Defines the 'docx-removeContent' tool with its description and inputSchema (requires id and index).
"docx-removeContent": { description: "Remove a block at index.", inputSchema: { type: "object", required: ["id", "index"], properties: { id: { type: "string" }, index: { type: "integer", minimum: 0 } } } }, - src/index.ts:197-201 (handler)Handler: In the CallToolRequestSchema switch statement, handles 'docx-removeContent' by parsing args and calling registry.removeContent(id, index).
case "docx-removeContent": { const { id, index } = parseArgs<{ id: string; index: number }>(args, tools["docx-removeContent"].inputSchema); const res = registry.removeContent(id, index); return ok({ id: res.id, updatedAt: res.updatedAt }); } - src/docx-utils.ts:230-237 (helper)Helper: DocRegistry.removeContent() removes a block at a given index from the document's content array via updateJson.
removeContent(id: DocId, index: number) { return this.updateJson(id, (json) => { const arr = [...json.content]; if (index < 0 || index >= arr.length) throw new Error("index out of range"); arr.splice(index, 1); return { ...json, content: arr } as DocxJSON; }); }