Skip to main content
Glama

extract_document

Extract STRUCTURED FIELDS from a document image: invoices, receipts, ID cards — or any custom JSON schema you supply. Every field returns {value, confidence, box} where the confidence and box come from the OCR geometry (never model guesswork); absent fields are null. preset="zatca" additionally decodes the Saudi ZATCA e-invoice QR (TLV) and cross-validates it against the printed fields — use it for Saudi tax invoices. Arabic-first accuracy. 2 credits/page (zatca 4).

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": {
      "image_base64": "<image_base64>"
    },
    "name": "extract_document"
  }
}

Input Schema

NameRequiredDescriptionDefault
langNoLanguage hint; default auto.auto
presetNoBuilt-in schema. Use zatca for Saudi e-invoices (adds QR validation).
schemaNoCustom extraction schema instead of a preset: an object whose keys are the fields you want, values describing them, e.g. {"policy_number": "string|null"}.
api_keyNoOptional Auto-Reader OCR key (nsk_live_...). If omitted, a free trial key is auto-provisioned and returned to you in the result.
image_base64YesThe document image as base64 (data: URI prefix accepted).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations, the description carries the full load and does well: it discloses the per-field return shape, that confidence and box come from OCR geometry rather than model guesswork, that absent fields are null, and the credit cost per page (2, or 4 for zatca). It does not cover failure modes, size/page limits, or what happens when the input is not a document.

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?

Dense and front-loaded: the capability comes first, then the return contract, then the zatca special case, then cost. Every clause carries information; nothing is padding.

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 five-parameter tool with a nested custom-schema object and no output schema, the definition explains the per-field result structure and pricing, which is what an agent most needs. It stops short of describing the top-level response envelope or constraints on image size and page count.

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%, so the baseline is 3, and the description largely restates what the schema already says about preset and schema. It adds a little on zatca (TLV QR decoding plus cross-validation against printed fields), but that duplicates the schema's own note about QR validation.

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?

The description opens with a specific verb and resource ('Extract STRUCTURED FIELDS from a document image') and enumerates the document classes it covers plus the custom-schema case. That framing makes it distinguishable from a plain text-OCR sibling without needing 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?

It gives a concrete routing rule inside the tool ('use zatca for Saudi tax invoices') and explains when to supply a custom schema instead of a preset. What it never states is when to prefer this over plain OCR/translation siblings, so the agent must infer that structured output is the deciding factor.

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.