Let the agent write the data, not the HTML
Описание и применение
Используя шаблоны и инструменты проверки, агенты могут подавать только структурированные данные, а не генерировать HTML, что обеспечивает согласованность и соблюдение обязательных требований к счетам.
Задача
AI agents produce inconsistent invoice documents when generating HTML directly, leading to mandatory detail errors and extra review effort.
Результат
Using a template‑first approach with validation tools reduces manual review, ensures compliance with mandatory invoice fields, and prevents rendering errors such as missing totals or NaN values.
Рабочий процесс
- Find the template with list_templates
- Learn the template schema via get_template_schema
- Validate the agent‑supplied data with validate_template
- Render the PDF with render
Доказательства
Ask it twice for "an invoice for these two line items" and nothing ties the second answer to the first: the column order, the wording of the VAT line, whether the payment terms mention a due date, whether the legal footer is there at all.
The shape that works has four parts, and our MCP server has a tool for each: Find the template, Learn what it expects, Check the data, Render.
validate_template answers: {"ok": true, "diagnostics": [{"severity": "warning", "code": "unknown-variable", "message": "\"line.total\" is not present in the sample data"...}]}
The schema check needs a stored schema. Every template has one inferred from its sample data, which is what get_template_schema hands the agent, but only a schema you stored decides what counts as wrong.
- Дата записи: 2026-10-05T11:55:50.433Z