Skip to main content
Glama

Extraer JSON de un texto

json-extract
Read-onlyIdempotent

Encuentra y analiza objetos/arreglos JSON dentro de un texto libre (p. ej. respuesta de un LLM), con reparación opcional. Cuándo: un flujo de agente necesita un resultado exacto y repetible para un paso auxiliar (tokens, costos, reintentos, fragmentos, ranking, limpieza de JSON). No para: extraer bloques de código delimitados (code-blocks-extract). Efectos secundarios: ninguno (solo lectura, sin red, sin estado guardado). Determinista: la misma entrada da la misma salida. Límites: entrada JSON de hasta 64 KB, 1 s por llamada, resultado de hasta 1 MB.

EN: Finds and parses JSON objects/arrays embedded in free text (e.g. an LLM reply): fenced ```json blocks first, then balanced {…}/[…] spans; optionally repairs near-JSON. When: an agent loop needs an exact, repeatable result for a bookkeeping step (tokens, costs, retries, chunking, ranking, JSON clean-up). Not for: extracting fenced code blocks (code-blocks-extract). [EN completo / full EN: inputSchema.description]

Input Schema

NameRequiredDescriptionDefault
textYesText (string; required).
repairNoTry json-repair on spans that fail to parse (boolean; optional; default true).
max_resultsNoMax results (integer; optional; default 10; min 1; max 100).

Output Schema

NameRequiredDescriptionDefault
countNo
resultsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / text / examples
      Added value: +[
      +  "Sure! Here it is:\n```json\n{\"city\": \"Bogotá\", \"temp\": 14}\n```\nAlso [1,2,3] inline."
      +]
  2. Changed1 schema field changed
    • addedInput schema / description
      Added value: +"EN: Finds and parses JSON objects/arrays embedded in free text (e.g. an LLM reply): fenced ```json blocks first, then balanced {…}/[…] spans; optionally repairs near-JSON. When: an agent loop needs an exact, repeatable result for a bookkeeping step (tokens, costs, retries, chunking, ranking, JSON clean-up). Not for: extracting fenced code blocks (code-blocks-extract). Side effects: none (read-only, no network access, no stored state). Deterministic: the same input gives the same output. Limits: JSON input up to 64 KB, 1 s per call, result up to 1 MB."
  3. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive and closed-world, so the bar is lower; the description nonetheless adds determinism ('same input, same output'), extraction precedence (fenced ```json first, then balanced spans), and hard limits (64 KB, 1 s, 1 MB). The 'no network / no stored state' claims largely restate openWorldHint=false and readOnlyHint=true, which tempers the score.

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?

Well front-loaded with labeled sections (Cuándo / No para / Efectos / Determinista / Límites) and no filler sentences. However, the Spanish and English paragraphs are near-verbatim translations, so roughly half the text repeats information, inflating metadata size for no marginal signal.

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?

An output schema exists, so return-value explanation is rightly omitted, and the description covers the operational envelope (side effects, determinism, time/size limits). Minor gap: 'entrada JSON de hasta 64 KB' is ambiguous against the schema's 1 MB maxLength on text, leaving unclear whether 64 KB caps the input text or the extracted payload.

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 baseline is 3; 'reparación opcional' echoes the repair parameter already documented in the schema. Nothing is added about max_results or about ordering/truncation semantics when more spans than the limit are found.

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 ('Encuentra y analiza objetos/arreglos JSON dentro de un texto libre') plus the parsing strategy (fenced blocks first, then balanced spans). It also explicitly distinguishes itself from the adjacent sibling code-blocks-extract, so an agent can choose without opening either 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?

Uses explicit 'Cuándo:' / 'No para:' sections, naming concrete agent-loop scenarios (tokens, costs, retries, chunking, ranking) and a named exclusion with the alternative tool. This is the when/when-not/alternative pattern at full strength.

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