Skip to main content
Glama

Generate merged documents

generate_merged_documents
Read-onlyIdempotent

Use this when the user wants to mail merge from Excel or CSV to PDF: personalized letters from a spreadsheet (thank-you letters for each donor, the same letter to 200 people with their names), certificates in bulk from a name list (award, completion, participation), or envelopes from a contact list (#10 with return address). Fills {{Field}} placeholders with defaults, formats and {{#if}} conditions for each row and returns ONE combined PDF (one document per record, up to 2,000 per batch) plus a per-record merge report CSV. Does not send email, mail, or print anything, and does not make mailing labels. Do not use for Outlook or Gmail bulk email.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "document_type": "<document_type>"
    },
    "name": "generate_merged_documents"
  }
}

Input Schema

NameRequiredDescriptionDefault
dateNoDate printed on letters and certificates and used for {{today}}, as YYYY-MM-DD, e.g. 2026-10-03. Defaults to today (US Eastern time); pass the user's local date when known.
fileNoThe spreadsheet with one row per recipient: Excel .xlsx, CSV or TSV, first row = column headers, e.g. donors.xlsx.
namesNoShortcut for a plain list of names (one column called Name), e.g. ["Ana Lopez", "Ben Okafor"]. Handy for certificates.
sheetNoFor an .xlsx file: the sheet (tab) name to use, e.g. Donors. Defaults to the first sheet that has data.
styleNoCertificates: design style: classic (navy double border), gold (cream with gold seal), modern (teal geometric), deco (burgundy art deco). Default classic.
senderNoLetters: your name/organization and address at the top. Envelopes: the return address. One line per entry, e.g. ["Riverbend Animal Shelter", "120 Elm St", "Springfield, IL 62701"].
closingNoLetters: closing line, e.g. "With gratitude,". Defaults to "Sincerely," unless the template already ends with a closing. Use "" for none.
recordsNoAlternative to a file: the recipients typed as objects with the same keys, e.g. [{"First Name": "Ana", "Last Name": "Lopez", "Amount": 250}].
signersNoCertificates: up to 3 signature lines, e.g. [{"name": "Alan Brooks", "title": "Principal"}].
subjectNoLetters: optional subject line printed as "Re: ...", may contain fields, e.g. "Your {{Year}} giving statement".
csv_textNoAlternative to a file: the list pasted as CSV or tab-separated text with a header row, e.g. "First Name,Last Name,City\nAna,Lopez,Austin".
templateNoLetters: the letter text from the salutation to the last paragraph, with merge fields, e.g. "Dear {{First Name|Friend}},\n\nThank you for your gift of {{Amount:currency}} on {{Gift Date:date}}.{{#if Company}} Please thank everyone at {{Company}}.{{/if}}". Syntax: {{Field}}, {{Field|default}}, {{Field:format}} with formats currency, number, integer, ordinal, date, short_date, iso_date, upper, lower, title, first_word, last_word; {{#if Field}}...{{else}}...{{/if}}, {{#if Field = value}}, {{#if Gift > 0}} (also !=, <, >=, <=; numbers or dates), {{#unless Field}}...{{/unless}}; {{today}} is the document date.
field_mapNoOptional explicit links from template fields to column names when names differ, e.g. {"Gift": "Donation Amount (USD)"}.
has_headerNoSet false if the first row of the file is data, not column names (columns are then called Column A, Column B, ...). Default true.
usps_styleNoEnvelopes: print the delivery address in USPS style (uppercase, no periods or commas). Default false.
organizationNoCertificates: issuing organization printed at the top, e.g. Lincoln Elementary School.
start_recordNoFor lists over 2,000 records: first record of this batch, e.g. 2001 for the second batch. Default 1.
body_templateNoCertificates: the line under the name, may contain fields, e.g. "for completing {{Course}} ({{Hours}} hours) on {{Completed:date}}".
document_typeYesWhat to merge into: letter (US business letter, one per row), certificate (landscape award/completion/participation certificate, one per row), or envelope (#10 envelope with recipient and return address). Example: letter.
envelope_sizeNoEnvelopes: "10" for a #10 business envelope 4-1/8 x 9-1/2 in (default) or "a7" for a 5-1/4 x 7-1/4 in invitation envelope.
max_documentsNoHow many records to put in this PDF (1-2000), e.g. 500. Default all, up to 2,000 per PDF.
missing_valuesNoWhat to do when a record has an empty value for a field with no default: leave_blank (default), skip_record (leave that record out), or placeholder (print [Field Name] for proofreading).
presented_lineNoCertificates: the line above the name. Default "This certificate is proudly presented to" ("This certifies that" for completion).
signature_nameNoLetters: name printed under the closing, e.g. Maria Chen.
include_addressNoLetters: print the recipient address block above the salutation. Default true when the sheet has address columns.
signature_titleNoLetters: title under the signature name, e.g. Executive Director.
address_templateNoOptional recipient address block (letters: inside address; envelopes: delivery address), one line per row, e.g. "{{First Name}} {{Last Name}}\n{{Street}}\n{{City}}, {{State}} {{ZIP}}". Defaults to one built from the name, company and address columns.
certificate_kindNoCertificates: sets the default title and wording, e.g. completion -> "Certificate of Completion". Default achievement.
certificate_titleNoCertificates: custom title, e.g. "Certificate of Appreciation" or "Volunteer of the Year".
recipient_templateNoCertificates: the name line, e.g. "{{First Name}} {{Last Name}}". Defaults to the Name column (or First + Last).

Output Schema

NameRequiredDescriptionDefault
batchYes
paperYes
styleYes
countsYes
fieldsYes
sourceYes
missingYes
previewYes
summaryYes
warningsYes
downloadsYes
document_typeYes
missing_totalYes
unmatched_fieldsYes
needs_confirmationYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior5/5

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

Annotations already declare a safe, idempotent, local read-only operation, yet the description still adds real behavioral context: placeholder/default/conditional semantics, one combined PDF of one document per record, a per-record merge report CSV, and a hard 2,000-per-batch cap. It also discloses what the tool will NOT do (no sending, no printing, no labels), which is the failure mode an agent most needs warned about.

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?

Front-loaded with the triggering condition, then mechanics, then exclusions — three dense sentences with no filler. Every clause (examples, output shape, batch cap, negative scope) carries decision-relevant information.

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

Completeness4/5

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

For a 30-parameter tool with nested file/records inputs, the description conveys the workflow, output artifacts, and scale limit, and an output schema exists so return values need no explanation. It leaves the preview-versus-generate choice unaddressed and says nothing about what a 2,000-record run costs in time, which an agent weighing a preview would want.

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

Parameters3/5

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

Schema description coverage is 100% across 30 parameters, so the schema already carries the per-parameter burden (styles, formats, templates, batching). The description only restates a few high-level behaviors ({Field}/{{#if}} syntax, the 2,000 cap) and adds no parameter guidance the schema lacks — the baseline 3 for fully documented schemas.

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?

States a specific verb and resource ('mail merge from Excel or CSV to PDF') and immediately binds it to three concrete artifact types (letters, certificates, envelopes) with realistic examples. An agent can tell exactly what this produces — one combined PDF plus a merge report — without opening the schema.

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?

Explicit when-to-use framing ('Use this when the user wants to mail merge...') plus concrete negative cases: does not send email, mail, or print, does not make mailing labels, and is not for Outlook/Gmail bulk email. The only gap is that it never routes to the sibling preview_mail_merge for a dry-run/preview before committing to a 2,000-record batch.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources