Skip to main content
Glama

Extract data from a document: invoice, receipt, contract fields as JSON

document_extract
Read-only

Extract named fields from a document as JSON: give a PDF, Word, Excel or PowerPoint file, a scan or a photo (PNG, JPEG, WebP) by URL or in a POST body (up to 10 MB; images 3 MB) and the field names you want, such as invoice_number, total, due_date. An AI model reads the file, scans by OCR, and returns one JSON object, with null where a value is not stated. Use to turn invoices, receipts, orders and contracts into rows. Price $0.03/call via x402 USDC or a card key (/credits); failed calls free. Reads or computes only and changes nothing; each call is charged, so repeats are not free.

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": {
      "url": "<url>",
      "fields": "<fields>"
    },
    "name": "document_extract"
  }
}

Input Schema

NameRequiredDescriptionDefault
urlYesAbsolute public http(s) URL of the file (or send the file in a POST body instead). With no input at all (no URL) this reads the public sample invoice PDF in the example and the answer says so.
fieldsYesComma-separated field names to extract (1-30). For rows, give the row keys in brackets: line_items[description,quantity,amount]. Or one word, invoice or receipt, for the usual fields of that document with its line items

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / url / description
      Previous value: -"Absolute public http(s) URL of the file (or send the file in a POST body instead). With no input at all this reads the public sample invoice PDF in the example."New value: +"Absolute public http(s) URL of the file (or send the file in a POST body instead). With no input at all (no URL) this reads the public sample invoice PDF in the example and the answer says so."
  2. Changed1 schema field changed
    • changedInput schema / properties / url / description
      Previous value: -"Absolute public http(s) URL of the file (or send the file in a POST body instead)"New value: +"Absolute public http(s) URL of the file (or send the file in a POST body instead). With no input at all this reads the public sample invoice PDF in the example."
  3. Changed1 schema field changed
    • changedInput schema / properties / fields / description
      Previous value: -"Comma-separated field names to extract (1-30). For rows, give the row keys in brackets: line_items[description,quantity,amount]"New value: +"Comma-separated field names to extract (1-30). For rows, give the row keys in brackets: line_items[description,quantity,amount]. Or one word, invoice or receipt, for the usual fields of that document with its line items"
  4. Changed1 schema field changed
    • changedInput schema / properties / fields / description
      Previous value: -"Comma-separated field names to extract (1-30)"New value: +"Comma-separated field names to extract (1-30). For rows, give the row keys in brackets: line_items[description,quantity,amount]"
  5. Added

TDQS

A3.9/5.0
Behavior4/5

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

Beyond the annotations it discloses cost ($0.03/call via x402 USDC or card key), that failed calls are free, that every call is billed so repeats are not free, size limits (10 MB file, 3 MB image), OCR for scans, and null for unstated values. These are real behavioral additions, though the description is slightly inconsistent in saying a file may be sent 'in a POST body' while the schema exposes only url+fields, which could confuse an agent about the actual call shape.

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 purpose is front-loaded in the first clause and the remaining sentences are short and each carries payload (output shape, pricing, limits). The opening sentence is long and crams file types, transport and field examples together, which costs some readability but not much space.

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?

With no output schema, the description does the necessary work of describing the return value (one JSON object, null where a value is absent) and the no-URL sample-document fallback. Cost, error semantics and size limits are covered, leaving only the POST-body/schema mismatch and absent batching notes as gaps for a model-backed extraction tool.

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%, so both url and fields are already documented, and the description largely restates them (URL or POST body, field names such as invoice_number, total, due_date). The only genuinely new parameter guidance is the size ceiling, which is marginal added meaning over a fully documented schema, so the baseline 3 holds.

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

Purpose4/5

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

The description opens with a precise verb+result ('Extract named fields from a document as JSON') and enumerates the supported inputs (PDF, Word, Excel, PowerPoint, scans, PNG/JPEG/WebP) and output shape, so an agent knows exactly what it does. It never names a sibling such as document_text or extract, so the agent must infer differentiation from the input/output wording rather than from explicit contrast.

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?

It states a clear use case ('turn invoices, receipts, orders and contracts into rows') and the condition of supplying field names or a shorthand like invoice/receipt. It offers no when-not-to-use guidance and does not point at any alternative tool for plain text or rendered extraction, leaving the choice against siblings to inference.

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