Skip to main content
Glama

Extract JSON from text

extract_json
Read-only

Use this when you need to turn unstructured text (emails, invoices, receipts, job posts, listings, bios, support tickets, chat logs) into JSON matching a schema. Send the text plus a JSON Schema or a list of field names; get back data that validates against it. Missing values come back as null, never invented. Charged only on success. Price: $0.002 USDC per call (x402, eip155:8453); the first call returns payment requirements, then retry with an x402 payment in _meta["x402/payment"]. Not charged if extraction fails.

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "text": "Hi team, I'm Dana Ortiz, VP of Ops at Lumen Freight. Can we move Thursday's demo to Friday Nov 27 at 2pm ET? Reach me at dana@lumenfreight.com or (617) 555-0142.",
      "fields": [
        "name",
        "title",
        "company",
        "email",
        "phone",
        "requested_meeting_time"
      ]
    },
    "name": "extract_json"
  }
}

Input Schema

NameRequiredDescriptionDefault
textYesThe unstructured text to extract from (max 8000 characters).
fieldsNoShortcut instead of a schema: field names, optionally typed as name:type where type is string, number, integer, boolean, date, string[], number[] or object[] (e.g. ["name", "email", "total:number", "skills:string[]"]).
schemaNoA JSON Schema (type: object, with properties) describing the JSON you want back. Supports type, properties, required, items, enum, description. Provide this OR fields.
instructionsNoOptional extra guidance, e.g. 'dates as YYYY-MM-DD', 'amounts in USD'.

Output Schema

NameRequiredDescriptionDefault
dataYesThe extracted JSON. Validates against your schema; values not found in the text are null.
noteNo
modelYes
missingNoPaths of requested fields that were not found in the text (returned as null).
warningsYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.1/5.0
Behavior5/5

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

Beyond the readOnly/destructive/idempotent annotations, the description discloses the guarantees that matter here: missing values return null and are never invented, billing occurs only on success, the exact price and network, and the two-step x402 flow where the first call returns payment requirements and must be retried with a payment in _meta["x402/payment"]. That is invocation-critical behavior no annotation or schema conveys.

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?

It is front-loaded with the use case, then mechanics, then output guarantees, then payment, which matches the order an agent needs. The payment/x402 sentences are dense but earn their place because the retry protocol changes how the tool must be called.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, the description need not describe return values, and it still covers the non-obvious parts: null-for-missing guarantee, per-call price, and the x402 retry handshake. Nothing an agent needs to call this correctly and interpret a payment-required response is missing.

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 schema already documents text, fields, schema, and instructions, including the name:type shorthand and length limits. The description only adds the either/or framing ("a JSON Schema or a list of field names"), which the schema also states, so it does not meaningfully extend parameter meaning.

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?

States a specific verb and resource: turn unstructured text into JSON matching a supplied schema, and lists concrete input domains (emails, invoices, receipts, job posts). It is clear on its own, but never names or contrasts with the sibling extract_json_lite, so an agent has to infer which of the two to pick.

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?

"Use this when you need to turn unstructured text ... into JSON matching a schema" gives a clear triggering condition, and the input-domain list helps the agent recognize eligible inputs. There are no explicit exclusions or pointers to the lite variant for simpler cases, so the when-not half of the guidance is absent.

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