Skip to main content
Glama

extract_json_from_text

Read-onlyIdempotent

Extract the first valid JSON object or array embedded in chaotic LLM output (surrounded by markdown fences, prose, or explanatory text). Handles ```json blocks and inline JSON.

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": {
      "input": "Here:\n```json\n{\"a\":[1,2]}\n```\nthanks"
    },
    "name": "extract_json_from_text"
  }
}

Input Schema

NameRequiredDescriptionDefault
inputYesRaw text (e.g., LLM output) that may contain a JSON object or array

Output Schema

NameRequiredDescriptionDefault
jsonNo
sourceNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "input": "Here:\n```json\n{\"a\":[1,2]}\n```\nthanks"
      +  }
      +]
  2. First observed

TDQS

A3.8/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 safety profile is covered. The description adds real behavioral information beyond that: only the FIRST valid object/array is returned, and both fenced ```json blocks and inline JSON are handled. It stops short of stating what happens when no JSON is present, which would have completed the picture.

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

Conciseness5/5

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

Two tight sentences with zero filler. The core behavior ('first valid JSON') is front-loaded, and the parenthetical examples of surrounding noise are exactly the detail an agent needs, in the right place.

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?

For a single-parameter read-only tool with an output schema, the description covers purpose, input expectations, and selection behavior well; return values need not be explained because the output schema carries them. The only real gap is the no-match/error case, which an agent would want to know before relying on the result.

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?

There is a single parameter with 100% schema description coverage, so the schema already explains that 'input' is raw text possibly containing JSON. The description's 'chaotic LLM output' framing reinforces the schema wording but adds no new syntax, format, or constraint information. Baseline 3 applies when the schema does the heavy lifting.

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?

The description uses a specific verb ('Extract') plus a precisely bounded resource ('the first valid JSON object or array'), and adds scope detail ('embedded in chaotic LLM output'). It implicitly separates itself from validation siblings like llm_output_validator or llm_json_schema_check by framing the job as extraction rather than checking, but it never names an alternative, so differentiation is inferred rather than stated.

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

Usage Guidelines3/5

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

Usage is implied by the phrase 'chaotic LLM output (surrounded by markdown fences, prose, or explanatory text)', which tells an agent the tool applies to messy model responses. There is no explicit when-not guidance and no pointer to sibling tools such as llm_format_check for cases where the text is already clean or needs schema validation.

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.