Skip to main content
Glama

Extract Structured Data

extract_structured_data

Extract structured JSON from text or files (PDF, image, audio, video) by specifying desired fields in instructions. Optionally constrain output with a JSON schema.

Instructions

Extract structured JSON from text or almost any local file (text/code, PDF, image, audio, video) using Gemini JSON mode. Describe the fields you want in instructions, optionally constrain the output with a json_schema (Gemini/OpenAPI subset). Returns parsed JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instructionsYesWhat to extract, e.g. "invoice number, date, total, and an array of line items".
textNoThe source text to extract from. Provide this or file_path.
file_pathNoAbsolute path to a local file to extract from (text/code, PDF, image, audio, video).
json_schemaNoOptional response schema (Gemini OpenAPI subset) to enforce the JSON shape. JSON string or object.
modelNoModel to use (defaults to the configured chat/analysis model).
max_tokensNoMaximum tokens in response (default 16384).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
successYes
Behavior3/5

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

With no annotations provided, the description must fully disclose behavior. It mentions 'Gemini JSON mode' and that it 'returns parsed JSON', but does not discuss error handling, file size limits, or permissions needed. The phrase 'almost any local file' is vague. There is no annotation contradiction.

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 description is only two sentences, with the purpose and method in the first sentence and key parameters in the second. It is front-loaded and waste-free. However, it could be slightly more structured by separating the input types from the output.

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?

Given the tool's complexity (6 parameters, wide input types) and the presence of an output schema (though not provided), the description covers the core functionality well: what it does, how to specify fields, and how to constrain output. It is complete enough for most use cases, though it does not detail the exact return format (referencing 'parsed JSON' is sufficient given output schema).

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?

All 6 parameters have descriptions in the input schema (100% coverage), so the description adds minimal extra meaning. It clarifies the purpose of 'instructions' and mentions that 'json_schema' can constrain output, but these points are already implied by the schema descriptions. Baseline 3 is appropriate.

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 clearly states it extracts structured JSON from text or local files using Gemini JSON mode. It is specific about the verb 'extract' and the resource 'structured JSON', but does not explicitly differentiate from sibling tools like 'analyze_image' or 'ocr', which could also extract data from files. However, the scope is broad, and the description is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description suggests using the tool when you need structured data from various file types, but it does not provide when-not-to-use or alternatives among siblings. The mention of 'optional' json_schema gives some guidance, but there is no explicit usage context or exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Raindancer118/gemini-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server