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