Skip to main content
Glama

fill_and_save

Apply batch edits to a document template and save or return the result. Use after listing template targets to fill with chatbot-generated content.

Instructions

Apply a batch of edits to the template and write/return the result.

USE WHEN: You have called list_template_targets() and composed an edits list mapping the chatbot's generated content into the right target_ids. DO NOT USE WHEN: You have not yet fetched target_ids and text_hashes from list_template_targets() — fill_and_save will fail validation.

INPUT modes: provide the template via template_path OR template_b64 + template_filename.

OUTPUT modes: provide output_path (server-side write) OR set return_output_bytes=True (response includes output_b64). Required unless dry_run=True. Use bytes when the chatbot is in a different filesystem than the MCP server.

Each edit dict must include edit_type ("text" | "structural" | "style") plus the fields required for that type:

  • text: target_id, expected_text_hash, new_text (+ optional target_kind, reason)

  • structural: operation, target_id (+ position, text/rows/values, row_index, column_index)

  • style: target_id (+ any style fields: bold, color, font_size_pt, etc.)

STYLE EDIT TARGETING: Run-level fields (bold / italic / underline / color / font_size_pt) must use target_kind='run' against a run target. Paragraph-level fields (paragraph_align / left_indent_pt / etc.) use target_kind='paragraph'. Mixing the two raises a clean style_field_target_mismatch response.

BUILT-IN ROBUSTNESS:

  1. Auto-skip of container/child edit conflicts (cell↔paragraph, paragraph↔run). Skipped entries in skipped_redundant_edits.

  2. Pre-check for duplicate target_id.

  3. Output extension validation.

  4. Defensive type coercion (None edits → empty list).

Output format follows the template: DOCX→DOCX, HWP/HWPX→HWPX. PDF input cannot be written back as PDF.

Returns: dict with

  • status: ok / dry_run_ok / validation_failed / apply_failed / edit_parse_failed / not_found / duplicate_target_id / style_field_target_mismatch / format_requires_java / file_error / permission_error / runtime_error / bad_argument / output_extension_mismatch / format_not_writable

  • output_path OR output_b64 + output_size_bytes (status=ok)

  • length_safe, length_warnings, skipped_redundant_edits

  • recovery_hint (when status != ok)

  • edits_applied

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_pathNo
editsNo
output_pathNo
dry_runNo
template_b64No
template_filenameNo
return_output_bytesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

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

With no annotations, the description fully discloses behavior: input/output modes, edit type requirements, style targeting rules, built-in robustness (conflict skipping, duplicate checks, type coercion), output format limitations, and an exhaustive list of possible status values and return fields.

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?

The description is long but well-organized with sections (USE WHEN, INPUT modes, OUTPUT modes, edit dict structure, STYLE EDIT TARGETING, BUILT-IN ROBUSTNESS). Every sentence adds value, though it could be slightly more concise.

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?

Given the tool's complexity (7 parameters, edit types, multiple modes) and lack of annotations, the description covers all necessary aspects: preconditions, input/output options, error handling, and return format. The presence of an output schema (not shown but flagged) makes the return description somewhat redundant but still complete.

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

Parameters5/5

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

Schema coverage is 0% (only titles), but the description adds comprehensive meaning for all 7 parameters, including the complex edits structure with required fields per edit type, and alternative input/output modes. It fully compensates for the lack of schema descriptions.

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

Purpose5/5

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

The description clearly states 'Apply a batch of edits to the template and write/return the result,' which is a specific verb+resource. It distinguishes itself from sibling tools like list_template_targets, describe_template, and inspect_template by focusing on writing/returning the modified template.

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 'USE WHEN' and 'DO NOT USE WHEN' sections, advising to call list_template_targets first and warning that fill_and_save will fail without proper target_ids. It also details when to use different input/output modes, making usage clear.

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/jaykim429/report-mcp'

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