Skip to main content
Glama

Structured data extraction: text to JSON by your JSON Schema (LLM, validated)

ai_extract
Read-only

Structured extraction task: send text (max 12,000 chars) and a JSON Schema; get back JSON that has been validated against your schema (type, properties, required, enum, items, min/max, pattern, anyOf/oneOf). One automatic repair attempt; if it still does not validate you get 422 and are not charged. Fixed extraction prompt (copy, don't invent). Runs on our Cloudflare Worker using Workers AI (IBM Granite 4.0 micro, Apache-2.0). Not a chat or model-access API. Limited daily capacity: 503 (not charged) when used up. Price: $0.004 USDC on Base per call, paid with x402 (MCP transport: an unpaid call returns the x402 PaymentRequired object; retry with params._meta["x402/payment"]). Same tool over HTTP: POST /api/ai/extract.

Input Schema

NameRequiredDescriptionDefault
textYessource text, max 12,000 characters
schemaYesJSON Schema (object or array at top level, max 8,000 chars, no $ref); as a JSON string in GET
instructionsNooptional extra guidance, max 500 chars

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior5/5

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

Goes well beyond the annotations by disclosing the 12,000-char input cap, one automatic repair attempt, the 422-no-charge failure path, daily capacity limits with 503-no-charge, pricing ($0.004 USDC on Base), and the x402 payment retry flow via params._meta['x402/payment']. It also names the backend (Cloudflare Worker, IBM Granite 4.0 micro), which the annotations do not cover.

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?

Front-loaded with the core task and output guarantee, then layers on repair, capacity, and pricing details. Dense but nearly every sentence carries operational information an agent needs (payment flow, failure codes); only the model/license parenthetical is arguably extraneous.

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?

For a paid, schema-validated extraction tool with no output schema, the description covers the success shape (validated JSON), both failure modes (422, 503) with billing implications, capacity limits, and the exact payment retry mechanism. Nothing an agent needs to invoke and pay correctly 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 description coverage is 100%, so the schema already documents text, schema, and instructions with their limits. The description only reinforces the 12,000-char text cap and the schema constraints, with one genuinely new detail ('as a JSON string in GET'); it adds little about the instructions parameter beyond what the schema says.

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 and resource: send text plus a JSON Schema and receive JSON validated against it, including the validation keywords checked. This clearly distinguishes it from siblings like ai_classify, ai_embed, and web_extract, which do not take a caller-supplied schema.

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?

Explicitly rules out the wrong use case ('Not a chat or model-access API') and states the fixed-prompt constraint ('copy, don't invent'). It does not, however, route the agent to a specific sibling for related tasks (e.g., ai_classify for labeling or web_extract for fetching), so the when-to-use-vs-alternatives guidance is strong but not fully explicit.

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