Skip to main content
Glama

Extract a document to structured JSON

extract_document

Send one document (PDF, photo, or text) and receive structured JSON with per-field confidence and source grounding. Use a built-in schema name (see list_schemas, e.g. 'invoice', 'receipt') or pass your own draft-07 JSON Schema as schema_json. Processing runs in the EU on Vertex; documents are not retained. Photos can take a while — allow generous timeouts.

Input Schema

NameRequiredDescriptionDefault
schemaNoBuilt-in schema id, e.g. 'invoice' or 'receipt'. Mutually usable with schema_json (schema_json wins).
file_nameNoOriginal file name, e.g. 'invoice.pdf' (helps type detection).
force_ocrNoForce OCR even when a text layer is detected. Leave off unless the text layer is garbage.
mime_typeNoMIME type if known, e.g. 'application/pdf', 'image/jpeg'. Inferred from file_name otherwise.
file_base64YesThe document bytes, base64-encoded. PDF, image (PNG/JPG/WEBP) or text file.
schema_jsonNoCustom JSON Schema (draft-07) as a string, for anything beyond the built-ins.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.1/5.0
Behavior4/5

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

No annotations, so description must carry behavioral burden. It discloses that processing runs in the EU on Vertex, documents are not retained, and that photos can take a while (timeout guidance). It doesn't mention rate limits, auth needs, or error handling, but the privacy and performance disclosures are valuable and non-obvious.

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?

Three sentences, front-loaded with purpose and output, then schema options, then operational notes. Efficient, though the final sentence about timeouts is slightly tangential but useful. No wasted words.

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 tool with no annotations, no output schema, and 6 parameters, the description covers output structure ('per-field confidence and source grounding'), schema usage, and operational constraints. It's fairly complete, though it could mention what happens on failure or how to handle large files, but overall adequate.

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 all parameters are documented in the schema. The description adds meaning by explaining the relationship between schema and schema_json ('using built-in or custom') and hints at timeout, but doesn't provide additional parameter syntax beyond what the schema already gives. Baseline 3 is appropriate.

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?

States a specific verb+resource ('Send one document... receive structured JSON') and the exact output shape (per-field confidence and source grounding). This distinguishes it from sibling classify_document (which likely returns a label) and list_schemas (which lists schemas). Very clear.

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?

Gives clear context: use for extraction with built-in schema names or custom schema_json. Names list_schemas as related. However, it doesn't explicitly contrast with classify_document (when to classify vs extract), which is a sibling that could be confused.

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.