Skip to main content
Glama

Extract invoice fields

extract_invoice_fields

Read an uploaded invoice PDF and return the fields found on it — supplier, invoice number, dates, totals, VAT, currency, line items. Run this between create_invoice_upload_url and book_invoice: MCP cannot carry a binary, so this is how an agent learns what the PDF actually says instead of having to be told. Handles text PDFs, scanned/image PDFs (vision OCR) and embedded XInvoice XML. Writes the result to the document's extracted_fields and returns it. It EXTRACTS but does not book — the amounts and the tax treatment are still your decision, and book_invoice is what records them.

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_id": "<document_id>"
    },
    "name": "extract_invoice_fields"
  }
}

Input Schema

NameRequiredDescriptionDefault
forceNoRe-read the PDF even if extracted_fields is already populated. Default false, which returns what is already stored instead of paying for another extraction.
document_idYesThe document to read, from create_invoice_upload_url. The PDF must already be uploaded.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the annotations by disclosing that the result is persisted to the document's extracted_fields, that a re-extraction costs money unless force is set, and that OCR/XML fallbacks exist. These are real side effects and cost implications that readOnlyHint=false / destructiveHint=false do not convey.

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 what it does and what it returns, then workflow placement, then capability coverage, then the explicit non-goal. Four dense sentences with no filler.

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?

No output schema exists, and the description does disclose the returned fields and that they are written back to the document. Minor gap: it does not say what is returned on failure or for an unparseable PDF, which matters for a non-idempotent extraction call.

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 coverage is 100% and the force parameter's default and caching behavior are already documented in the schema itself, so the description adds little parameter-specific meaning. It only supplies indirect context around document_id ('from create_invoice_upload_url', 'must already be uploaded').

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?

Specific verb plus resource ('Read an uploaded invoice PDF and return the fields found on it') followed by an enumerated field list and the supported input formats (text, scanned/OCR, XInvoice XML). It is clearly separable from book_invoice and create_invoice_upload_url.

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?

Explicitly places the tool in the workflow — 'Run this between create_invoice_upload_url and book_invoice' — and states the boundary: it extracts but does not book; amounts and tax treatment remain the caller's decision and book_invoice records them. It also explains why the step is necessary (MCP cannot carry a binary).

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