Skip to main content
Glama

docx-editContent

Modify specific content blocks in Word documents by index using JSON schema. Identify blocks with docx-queryObjects and understand structure via docx-getSchema for precise edits.

Instructions

Replace a block at index. Use docx-queryObjects first to see available blocks, and docx-getSchema to understand block structure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockYes
idYes
indexYes

Implementation Reference

  • Core implementation of docx-editContent: replaces the content block at the specified index in the document's JSON content array, validates the update, rebuilds the docx Document object.
    editContent(id: DocId, index: number, newBlock: any) { return this.updateJson(id, (json) => { const arr = [...json.content]; if (index < 0 || index >= arr.length) throw new Error("index out of range"); arr[index] = newBlock; return { ...json, content: arr } as DocxJSON; }); }
  • MCP tool call handler: parses arguments using the tool's inputSchema and delegates to DocRegistry.editContent.
    case "docx-editContent": { const { id, index, block } = parseArgs<{ id: string; index: number; block: any }>(args, tools["docx-editContent"].inputSchema); const res = registry.editContent(id, index, block); return ok({ id: res.id, updatedAt: res.updatedAt }); }
  • Input schema definition for the docx-editContent tool, including parameters id, index, and block (referencing DocxSchema $defs/Block).
    "docx-editContent": { description: "Replace a block at index. Use docx-queryObjects first to see available blocks, and docx-getSchema to understand block structure.", inputSchema: { type: "object", required: ["id", "index", "block"], properties: { id: { type: "string" }, index: { type: "integer", minimum: 0 }, block: { $ref: "docx:/$defs/Block" } } } },
  • DocxSchema.$defs.Block: the JSON schema for content blocks used in the tool's 'block' parameter.
    Block: { type: "object", oneOf: [ { $ref: "#/$defs/Paragraph" }, { $ref: "#/$defs/Table" }, { $ref: "#/$defs/Image" }, { $ref: "#/$defs/Heading" }, { $ref: "#/$defs/CodeBlock" }, { $ref: "#/$defs/List" }, { $ref: "#/$defs/PageBreak" }, { $ref: "#/$defs/HorizontalRule" }, { $ref: "#/$defs/Blockquote" }, { $ref: "#/$defs/InfoBox" }, { $ref: "#/$defs/TextBox" } ] },
  • src/index.ts:101-103 (registration)
    MCP server registration for listing tools, which exposes docx-editContent via the 'tools' object.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.entries(tools).map(([name, t]) => ({ name, description: t.description, inputSchema: t.inputSchema as any })) }));

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