Skip to main content
Glama

docx-removeContent

Remove specific content blocks from DOCX files by index using JSON schema. Simplify document editing and management with structured, programmatic content removal.

Instructions

Remove a block at index.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
indexYes

Implementation Reference

  • src/index.ts:69-72 (registration)
    Tool registration including description and input schema
    "docx-removeContent": { description: "Remove a block at index.", inputSchema: { type: "object", required: ["id", "index"], properties: { id: { type: "string" }, index: { type: "integer", minimum: 0 } } } },
  • MCP tool call handler that validates input and delegates to DocRegistry.removeContent
    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 });
  • Core logic: removes the content block at the specified index from the document 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; }); }
  • Helper method called by removeContent to apply JSON updates, validate, rebuild the docx Document object, and update timestamps
    updateJson(id: DocId, updater: (json: DocxJSON) => DocxJSON): ManagedDoc { const cur = this.require(id); const next = updater(this.clone(cur.json)); this.assertValid(next); cur.json = next; // Note: doc rebuild will be async if images with paths are present this.rebuildDoc(cur); cur.updatedAt = new Date().toISOString(); return cur; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lihongjie0209/docx-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server