Skip to main content
Glama

layout_apply

Apply a page plan to a .docx: set section starts, breaks, numbering, and header/footer text as tracked changes. Preview with dry_run; the write is atomic or nothing.

Instructions

Bring the document to a page plan, the shape layout.get returns: per section its start (from address), break, page-number start and format, first-page difference, and header/footer text per kind ({PAGE}, {NUMPAGES}, {chapter} become fields; null inherits). Keys left out stay as they are. Edit the layout.get result and send it back. Breaks, numbering and header text are tracked changes; a new header part, a dropped reference, two_sided or mirror_margins need untracked: true. All or nothing: UNSUPPORTED_CONTENT if the result would differ from the plan or a section has a pending setup change. dry_run lists the changes.

Input Schema

NameRequiredDescriptionDefault
docYesPath to the .docx.
tagNoAppended to the author.
planYesThe page plan, as layout.get returns it: version 1, two_sided, mirror_margins and sections, each with a `from` address; keys left out stay as they are, and numbering.shown is checked, not set. Every section already in the document must be kept. A header/footer text a section already prints changes nothing; a shared part is rewritten only when every section using it asks the same text, else the section gets a new part. Changing a header or footer that a later section inherits is refused. A split-off section keeps the number format of the one it came from unless the plan states one.
authorNoRevision author.
expectNoWrite guard: the sha256 read earlier (doc.info, or a reply's doc.sha256), e.g. {"sha256": "9f86d081…"}; a file changed since is DOC_CHANGED_ON_DISK.
dry_runNoPreview only; write nothing.
untrackedNoAllow a change Word cannot track (LAYOUT D-L2).

Output Schema

NameRequiredDescriptionDefault
okYesAlways true on success.
opYesThe operation that ran.
apiYesAPI version (1.0).
docNoThe document read or written: path, sha256 and paragraph count.
nextYesCursor for the next page (pass as cursor), or null.
resultYesWhat the operation returns.
warningsYesThings to know about the result.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.7.2
    • addedInput schema / properties / expect / description
      Added value: +"Write guard: the sha256 read earlier (doc.info, or a reply's doc.sha256), e.g. {\"sha256\": \"9f86d081…\"}; a file changed since is DOC_CHANGED_ON_DISK."
    • changedInput schema / properties / plan / description
      Previous value: -"The page plan: version 1 and sections, each with a from address."New value: +"The page plan, as layout.get returns it: version 1, two_sided, mirror_margins and sections, each with a `from` address; keys left out stay as they are, and numbering.shown is checked, not set. Every section already in the document must be kept. A header/footer text a section already prints changes nothing; a shared part is rewritten only when every section using it asks the same text, else the section gets a new part. Changing a header or footer that a later section inherits is refused. A split-off section keeps the number format of the one it came from unless the plan states one."
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "api": {
      +      "description": "API version (1.0).",
      +      "type": "string"
      +    },
      +    "doc": {
      +      "description": "The document read or written: path, sha256 and paragraph count.",
      +      "properties": {
      +        "characters": {
      +          "description": "text.normalize of a text string: its length.",
      +          "type": "integer"
      +        },
      +        "paragraphs": {
      +          "description": "Body paragraphs.",
      +          "type": "integer"
      +        },
      +        "path": {
      +          "description": "Path of the document.",
      +          "type": "string"
      +        },
      +        "sha256": {
      +          "description": "sha256 of the file (pass as expect.sha256 to a write).",
      +          "type": "string"
      +        },
      +        "source": {
      +          "description": "A .txt/.md/.odt source's format, encoding and split mode; \"text\" for a text string (text.normalize).",
      +          "type": [
      +            "object",
      +            "string"
      +          ]
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "next": {
      +      "description": "Cursor for the next page (pass as cursor), or null.",
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "ok": {
      +      "description": "Always true on success.",
      +      "type": "boolean"
      +    },
      +    "op": {
      +      "description": "The operation that ran.",
      +      "type": "string"
      +    },
      +    "result": {
      +      "description": "What the operation returns.",
      +      "properties": {
      +        "backup": {
      +          "description": "Path of the backup taken before the write.",
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        },
      +        "changes": {
      +          "description": "What changed (or would): section properties, breaks, header/footer text, settings.",
      +          "items": {
      +            "additionalProperties": true,
      +            "description": "A change.",
      +            "properties": {
      +              "at": {
      +                "description": "Where: section <n> or a paragraph address.",
      +                "type": "string"
      +              },
      +              "kind": {
      +                "description": "section.props, section.break, settings, header/footer text...",
      +                "type": "string"
      +              },
      +              "revision_ids": {
      +                "description": "w:id of every revision this write created.",
      +                "items": {
      +                  "type": [
      +                    "integer",
      +                    "string"
      +                  ]
      +                },
      +                "type": "array"
      +              },
      +              "tracked": {
      +                "description": "Whether it is a tracked change.",
      +                "type": "boolean"
      +              }
      +            },
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "dry_run": {
      +          "description": "True when nothing was written (a preview).",
      +          "type": "boolean"
      +        },
      +        "op_id": {
      +          "description": "Undo-log id of this write (history.undo / history.restore).",
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        },
      +        "plan": {
      +          "description": "The page plan after the write (as layout.get returns it).",
      +          "properties": {
      +            "mirror_margins": {
      +              "description": "Mirrored margins.",
      +              "type": "boolean"
      +            },
      +            "sections": {
      +              "description": "Each section, in order.",
      +              "items": {
      +                "description": "A section of the plan.",
      +                "properties": {
      +                  "break": {
      +                    "description": "nextPage, oddPage, evenPage or continuous.",
      +                    "type": "string"
      +                  },
      +                  "first_page_different": {
      +                    "description": "Different first page.",
      +                    "type": "boolean"
      +                  },
      +                  "footer": {
      +                    "description": "Text per kind; {PAGE}, {NUMPAGES} and {chapter} stand for fields; null: inherited.",
      +                    "properties": {
      +                      "default": {
      +                        "description": "Default (odd) pages.",
      +                        "type": [
      +                          "string",
      +                          "null"
      +                        ]
      +                      },
      +                      "even": {
      +                        "description": "Even pages.",
      +                        "type": [
      +                          "string",
      +                          "null"
      +                        ]
      +                      },
      +                      "first": {
      +                        "description": "First page.",
      +                        "type": [
      +                          "string",
      +                          "null"
      +                        ]
      +                      }
      +                    },
      +                    "type": "object"
      +                  },
      +                  "from": {
      +                    "description": "Paragraph address, p<n>#<fingerprint> (story-prefixed in notes/headers).",
      +                    "type": "string"
      +                  },
      +                  "header": {
      +                    "description": "Text per kind; {PAGE}, {NUMPAGES} and {chapter} stand for fields; null: inherited.",
      +                    "properties": {
      +                      "default": {
      +                        "description": "Default (odd) pages.",
      +                        "type": [
      +                          "string",
      +                          "null"
      +                        ]
      +                      },
      +                      "even": {
      +                        "description": "Even pages.",
      +                        "type": [
      +                          "string",
      +                          "null"
      +                        ]
      +                      },
      +                      "first": {
      +                        "description": "First page.",
      +                        "type": [
      +                          "string",
      +                          "null"
      +                        ]
      +                      }
      +                    },
      +                    "type": "object"
      +                  },
      +                  "numbering": {
      +                    "description": "Page numbering.",
      +                    "properties": {
      +                      "format": {
      +                        "description": "decimal, lowerRoman, upperRoman, lowerLetter, upperLetter...",
      +                        "type": "string"
      +                      },
      +                      "shown": {
      +                        "description": "A page number is printed (checked, not set).",
      +                        "type": "boolean"
      +                      },
      +                      "start": {
      +                        "description": "Restart value, or null to continue.",
      +                        "type": [
      +                          "integer",
      +                          "null"
      +                        ]
      +                      }
      +                    },
      +                    "type": "object"
      +                  }
      +                },
      +                "type": "object"
      +              },
      +              "type": "array"
      +            },
      +            "two_sided": {
      +              "description": "Different even and odd headers.",
      +              "type": "boolean"
      +            },
      +            "version": {
      +              "description": "Plan format version (1).",
      +              "type": "integer"
      +            }
      +          },
      +          "type": "object"
      +        },
      +        "revision_ids": {
      +          "description": "w:id of every revision this write created.",
      +          "items": {
      +            "type": [
      +              "integer",
      +              "string"
      +            ]
      +          },
      +          "type": "array"
      +        },
      +        "sha256": {
      +          "description": "sha256 of the file after the write (pass as expect.sha256 next).",
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        }
      +      },
      +      "required": [
      +        "dry_run",
      +        "changes",
      +        "plan"
      +      ],
      +      "type": "object"
      +    },
      +    "warnings": {
      +      "description": "Things to know about the result.",
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    }
      +  },
      +  "required": [
      +    "api",
      +    "ok",
      +    "op",
      +    "result",
      +    "warnings",
      +    "next"
      +  ],
      +  "type": "object"
      +}
  2. First observedv0.1.0

TDQS

A4.3/5.0
Behavior5/5

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

Despite annotations already flagging a non-read-only write, the description discloses substantial behavior beyond them: which edits are tracked vs. require untracked: true, header-sharing/rewrite rules, inheritance refusal, and the all-or-nothing UNSUPPORTED_CONTENT failure mode. This is unusually rich disclosure for a mutation tool.

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

Conciseness4/5

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

Purpose is front-loaded and nearly every clause carries needed operational detail (tracking rules, error semantics, flag conditions). The long run-on sentences with dense parentheticals reduce readability, but little is genuinely redundant.

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

Completeness5/5

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

For a 7-parameter mutation tool with nested objects and an output schema, the description covers the workflow, tracking model, guards, and failure behavior. Return values are delegated to the output schema, and nothing an agent needs to invoke it correctly appears missing.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds interpretation: '{PAGE}, {NUMPAGES}, {chapter} become fields; null inherits' and 'dry_run lists the changes' go beyond the schema's terse 'Preview only; write nothing.' It largely mirrors the plan schema's inheritance rules, keeping it at 4 rather than 5.

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 opening clause ('Bring the document to a page plan, the shape layout.get returns') states a specific action and resource and explicitly anchors the tool to its read sibling, so an agent can distinguish it from layout_get. It is slightly indirect in phrasing rather than a crisp verb+resource, but the target (per-section start, break, numbering, header/footer text) is concrete.

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

Usage Guidelines4/5

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

It supplies a clear workflow: 'Edit the layout.get result and send it back,' and gives conditions for the optional flags (untracked: true for new header parts, dropped references, two_sided, mirror_margins; dry_run lists changes). It names the source tool rather than a competing sibling, so alternatives are contextualized but no explicit when-not guidance is given.

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