docx-removeContent
Remove specific content blocks from Word documents by index to edit DOCX files programmatically.
Instructions
Remove a block at index.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| index | Yes |
Implementation Reference
- src/docx-utils.ts:230-237 (handler)Core handler function in DocRegistry that removes the content block at the given index from the document's JSON content array, validates the index, updates the JSON, and triggers document rebuild 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; }); }
- src/index.ts:197-201 (handler)MCP server tool call handler (switch case) that parses input arguments using the tool's schema and delegates execution to the DocRegistry.removeContent method.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/index.ts:69-72 (registration)Tool registration in the tools object, including name, description, and inputSchema used for validation and listing tools."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:71-72 (schema)Input schema definition for the docx-removeContent tool, specifying required id (string) and index (non-negative integer).inputSchema: { type: "object", required: ["id", "index"], properties: { id: { type: "string" }, index: { type: "integer", minimum: 0 } } } },