Skip to main content
Glama

Extraer bloques de código

code-blocks-extract
Read-onlyIdempotent

Extrae bloques de código delimitados (``` o ~~~) de Markdown o respuestas de LLM, con su lenguaje. 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: encontrar y analizar objetos/arreglos JSON dentro de un texto libre (json-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: Extracts fenced code blocks (``` or ~~~) from Markdown or LLM output with their language tags and line counts, optionally filtered by language. When: an agent loop needs an exact, repeatable result for a bookkeeping step (tokens, costs, retries, chunking, ranking, JSON clean-up). Not for: finding and parsing JSON objects/arrays embedded in free text (json-extract). [EN completo / full EN: inputSchema.description]

Input Schema

NameRequiredDescriptionDefault
textYesText (string; required).
languageNoOnly this language tag (string; optional; up to 40 chars).

Output Schema

NameRequiredDescriptionDefault
countNo
blocksNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / text / examples
      Added value: +[
      +  "Run:\n```bash\nnpm test\n```\nand\n```js\nconsole.log(1)\nconsole.log(2)\n```"
      +]
  2. Changed1 schema field changed
    • addedInput schema / description
      Added value: +"EN: Extracts fenced code blocks (``` or ~~~) from Markdown or LLM output with their language tags and line counts, optionally filtered by language. When: an agent loop needs an exact, repeatable result for a bookkeeping step (tokens, costs, retries, chunking, ranking, JSON clean-up). Not for: finding and parsing JSON objects/arrays embedded in free text (json-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.2/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, openWorldHint=false and idempotentHint, so 'sin efectos secundarios' and 'determinista' are largely restatements. What genuinely adds value beyond annotations is the operational envelope (1 s per call, up to 1 MB of result) and the note that results include language tags and line counts. One caveat: the stated 'input up to 64 KB' conflicts with the schema's text maxLength of 1048576, which could mislead an agent sizing its input.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The content is front-loaded and cleanly segmented (purpose / when / not-for / effects / limits), but the full text is duplicated in Spanish and English and then terminated with a pointer '[EN completo / full EN: inputSchema.description]' that repeats what is already in the schema description. Roughly half the length is redundancy, which dilutes the signal for a tool this simple.

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?

With an output schema present, the description correctly avoids explaining return values, and it covers side effects, determinism, time and size limits, and the sibling boundary. The only real gap is the internal inconsistency between the 64 KB input cap and the schema's 1 MB text maxLength, which leaves the actual input limit ambiguous.

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 both `text` and `language` are documented with types, maxLength and an example, giving a baseline of 3. The description only adds that filtering by language tag is optional and how output is tagged; it offers no extra syntax or matching rules (e.g. case sensitivity, alias handling like 'js' vs 'javascript') that the schema does not already convey.

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 ('Extracts fenced code blocks (``` or ~~~) from Markdown or LLM output'), including the delimiters, the language tags and the line counts, and even names the sibling it is not (json-extract). An agent can distinguish it from json-extract, markdown-* and html-* extractors 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?

Has explicit 'Cuando/When' (exact, repeatable bookkeeping step: tokens, costs, retries, chunking, ranking, JSON clean-up) and explicit 'No para/Not for' with the named alternative json-extract plus the condition that selects it (parsing JSON objects/arrays embedded in free text). Nothing is left to inference.

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