Skip to main content
Glama

docx-insertContent

Insert content blocks into Word documents at specific positions to modify structure and add formatted text, tables, images, or lists.

Instructions

Insert a block at index. Use docx-queryObjects first to see current structure, and docx-getSchema to understand block structure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
indexYes
blockYes

Implementation Reference

  • Core handler function in DocRegistry that inserts a new block into the document's content array at the specified index by updating the JSON model and triggering a document rebuild.
    insertContent(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.splice(index, 0, newBlock);
        return { ...json, content: arr } as DocxJSON;
      });
  • MCP server handler that parses arguments using the tool schema and delegates to DocRegistry.insertContent.
    case "docx-insertContent": {
      const { id, index, block } = parseArgs<{ id: string; index: number; block: any }>(args, tools["docx-insertContent"].inputSchema);
      const res = registry.insertContent(id, index, block);
      return ok({ id: res.id, updatedAt: res.updatedAt });
  • src/index.ts:65-67 (registration)
    Tool registration entry defining the name, description, and input schema for listTools response.
    "docx-insertContent": {
      description: "Insert a block at index. Use docx-queryObjects first to see current structure, 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" } } }
  • JSON Schema definition for Block type, 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. While it mentions using other tools for preparation, it does not describe key behavioral traits such as whether this operation is destructive (e.g., overwrites existing content), requires specific permissions, or has side effects like affecting document structure. This leaves significant gaps in understanding the tool's behavior.

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 highly concise and well-structured, consisting of two sentences that directly address the tool's purpose and usage guidelines. Every sentence adds value without unnecessary elaboration, making it easy to parse and understand quickly.

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

Completeness2/5

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

Given the complexity of a content insertion tool with no annotations, no output schema, and 0% schema description coverage for three parameters, the description is incomplete. It provides good usage guidance but lacks essential details about behavioral traits, parameter meanings, and expected outcomes, leaving the agent with insufficient information to use the tool effectively.

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 schema description coverage is 0%, meaning none of the three parameters (id, index, block) are documented in the schema. The description does not add any semantic details about these parameters, such as what 'id' refers to, how 'index' is interpreted in the document structure, or what a 'block' entails. This fails to 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 action ('Insert a block at index') and identifies the resource ('a block'), making the purpose understandable. However, it does not explicitly differentiate this tool from its sibling 'docx-editContent', which might also modify content, leaving some ambiguity about when to choose one over the other.

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 provides explicit guidance on when to use this tool by recommending to 'Use docx-queryObjects first to see current structure, and docx-getSchema to understand block structure.' This clearly indicates prerequisites and alternative tools for preparation, helping the agent understand the proper context and sequence of operations.

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