Skip to main content
Glama

docx-editContent

Replace content blocks in Word documents by specifying index and new content. Use with query and schema tools to identify blocks and understand structure.

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
idYes
indexYes
blockYes

Implementation Reference

  • Core implementation of docx-editContent tool: replaces the block at the given index in the document's content array and updates the JSON model, triggering document rebuild.
    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 server tool dispatch handler for 'docx-editContent': validates input using the tool schema and calls 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 for the docx-editContent tool, defining parameters id, index, and block (referencing Docx Block schema). Used for validation and tool listing.
    "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" } } }
    },
  • src/index.ts:101-103 (registration)
    Tool registration via ListToolsRequestHandler, which exposes all tools in the 'tools' object including docx-editContent.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: Object.entries(tools).map(([name, t]) => ({ name, description: t.description, inputSchema: t.inputSchema as any }))
    }));
  • Definition of the Block schema ($defs.Block) referenced by the tool's inputSchema for the '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" }
      ]
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions using other tools first, which adds some context about prerequisites, but it doesn't describe key behavioral traits such as whether this is a destructive operation, what permissions are needed, how errors are handled, or what the response looks like. For a mutation tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise with two sentences that are front-loaded and earn their place: the first states the purpose, and the second provides crucial usage guidelines. There is no wasted text, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a mutation tool with 3 parameters, no annotations, and no output schema, the description is partially complete. It covers purpose and usage well but lacks details on behavior, parameters, and return values. The reference to other tools helps, but it doesn't fully compensate for the missing structured information, making it adequate but with clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 3 parameters with 0% description coverage, meaning none are documented in the schema. The description adds minimal semantics by implying 'index' refers to a block position and 'block' is a structure to replace with, but it doesn't explain 'id' or provide details on block format beyond referencing other tools. This doesn't adequately compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'replace' and the resource 'a block at index', which specifies what the tool does. It distinguishes from siblings like docx-insertContent and docx-removeContent by focusing on replacement rather than addition or deletion. However, it doesn't fully differentiate from docx-editMeta, which might also modify content, leaving room for slight ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly provides usage guidance by stating 'Use docx-queryObjects first to see available blocks, and docx-getSchema to understand block structure.' This clearly indicates prerequisites and when to use this tool in relation to alternatives, helping the agent select it correctly in context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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