Skip to main content
Glama

extract_document

Turn a document into JSON shaped like template, with a calibrated confidence (0-1) for every field.

template: the shape of the answer; each leaf names a type: "verbatim-string" (copied exactly), "string",
  "number", "integer", "date" (YYYY-MM-DD), "date-time", "boolean", ["a", "b"] (pick one), [["a", "b"]] (pick
  any), ["string"] (a list), or [{...}] (a list of objects, e.g. line items).
  Example: {"merchant": "verbatim-string", "total": "number", "date": "date",
            "items": [{"name": "verbatim-string", "price": "number"}]}
Give the document as exactly one of:
  text: the document as text.
  image: a JPEG or PNG, base64 or a data URL (a photo, scan or screenshot of one page).
  pdf: a PDF with a text layer, base64.
  file_path: a JPEG/PNG, PDF or text file on this machine (local server only).
instructions: optional guidance, e.g. "dates are day/month/year" or "amounts in kobo".

Long documents (over 120,000 characters) are split into parts, extracted in parallel and merged; that can take
minutes. Missing values come back as null. Treat fields with confidence below about 0.95 as needing a check.

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

Input Schema

NameRequiredDescriptionDefault
pdfNo
textNo
imageNo
templateYes
file_pathNo
instructionsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/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 burden and does most of it: it discloses that long documents are split, extracted in parallel and merged with multi-minute latency, that missing values return as null, that file_path is local-server only, and how to interpret low confidence. It does not cover error behavior or whether a long extraction blocks the call, which is the remaining gap.

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 core contract is front-loaded in the first sentence, then the template vocabulary, input options, and operational caveats follow in a readable order. It is long, but nearly every line carries operational meaning; the type enumeration and example are load-bearing rather than 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 complex tool with a nested free-form object, no annotations and no output schema, the description covers return shape, confidence semantics, null handling and latency. The only meaningful omission is how a multi-minute parallel extraction is surfaced to the caller (synchronous wait vs. deferred retrieval).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate entirely, and it does: each of the four input-source parameters is described with accepted formats and encodings (base64/data URL, text layer required, local-only path). The `template` parameter receives a full type vocabulary plus a worked nested example, which is more than the schema provides.

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 opening sentence names a specific verb (turn into JSON), a specific resource (a document), and the exact output contract (JSON shaped like `template` with per-field confidence). This is clearly distinct from siblings such as decide, detect_language, or restore_diacritics without needing to name them.

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 explicit input-selection guidance ('Give the document as exactly one of' text/image/pdf/file_path) and explains the optional `instructions` field with concrete examples. It stops short of stating when to prefer this tool over an alternative, but the guidance for how to invoke it correctly is clear.

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.