Skip to main content
Glama

extract-json

extract_json
Read-only

3 free MCP calls per day (all tools together), then $0.01 USDC via x402 or card credits (paid in-band: params._meta["x402/payment"]). Extract JSON: Messy text + JSON Schema in, clean JSON out. Uses a small LLM (Cloudflare Workers AI, Llama 3.1 8B, JSON mode) when available, else a deterministic key:value/regex extractor; the result is type-checked against your schema and missing fields are null. Limits: text <= 6,000 chars, schema <= 30 top-level properties (flat objects, arrays of scalars); the model can misread ambiguous text, so check important values. Params: text, schema (JSON string), mode=auto|heuristic. GET query or POST JSON body. When to use: Use extract-json for short free text with your own JSON schema; for invoices and receipts use invoice-json.

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": {
      "text": "<text>",
      "schema": "<schema>"
    },
    "name": "extract_json"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNo
textYesinput text, max 6000 chars
schemaYesJSON Schema (type object with properties) as a JSON string

Output Schema

NameRequiredDescriptionDefault
dataNo
modelNo
limitsNo
methodNo
missingNo
sourcesNo
not_verbatim_in_textNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedOutput schema / description
      Previous value: -"Inferred from a real response captured on 2026-10-24; extra fields may appear, null-valued fields are untyped."New value: +"Inferred from a real response captured on 2026-10-26; extra fields may appear, null-valued fields are untyped."
  2. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "description": "Inferred from a real response captured on 2026-10-24; extra fields may appear, null-valued fields are untyped.",
      +  "properties": {
      +    "data": {
      +      "properties": {
      +        "company": {
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        },
      +        "due": {
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        },
      +        "order_id": {
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        },
      +        "total": {
      +          "type": [
      +            "number",
      +            "null"
      +          ]
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "limits": {
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "method": {
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "missing": {
      +      "type": [
      +        "array",
      +        "null"
      +      ]
      +    },
      +    "model": {
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "not_verbatim_in_text": {
      +      "type": [
      +        "array",
      +        "null"
      +      ]
      +    },
      +    "sources": {
      +      "items": {
      +        "properties": {
      +          "name": {
      +            "type": [
      +              "string",
      +              "null"
      +            ]
      +          },
      +          "url": {
      +            "type": [
      +              "string",
      +              "null"
      +            ]
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    }
      +  },
      +  "type": "object"
      +}
  3. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Far beyond the readOnlyHint/openWorldHint annotations: it discloses the pricing model (3 free calls/day, $0.01 USDC via x402 with payment passed in params._meta), the implementation fallback (Llama 3.1 8B JSON mode vs deterministic key:value/regex extractor), post-processing behavior (type-check against schema, missing fields nulled), and an accuracy caveat that the model can misread ambiguous text. Nothing here contradicts the annotations — the tool is a pure read/extract operation.

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?

Very dense and mostly every sentence earns its place, but the billing/payment preamble is front-loaded ahead of the purpose statement, which is the least useful opening for tool selection. The trailing 'Params: text, schema (JSON string), mode=...' line also partially repeats the schema.

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?

An output schema exists, so return values needn't be explained. The description covers what an agent still needs: size limits (6000 chars, 30 top-level properties, flat objects/arrays of scalars), the transport options (GET query or POST JSON body), cost gating, and accuracy risk. Complete for a 3-parameter extraction tool.

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 67%, so the structured fields already document text (max 6000 chars) and schema. The description restates those and lists 'mode=auto|heuristic' without explaining what each mode does, leaving the one parameter undocumented in the schema only half-covered. 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 concrete verb and transformation: 'Messy text + JSON Schema in, clean JSON out.' It also names the closest sibling (invoice_json) and the distinguishing scope (short free text, your own schema), so an agent can select it without opening any schema.

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

Usage Guidelines5/5

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

An explicit 'When to use' clause plus a named alternative with the condition that selects it: 'for invoices and receipts use invoice-json.' This is the when/when-not/alternative pattern done properly.

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