Skip to main content
Glama

parse_partial_json

Parse and validate incomplete JSON fragments to extract structured data from partial inputs, enabling reliable data extraction from incomplete sources.

Instructions

Best-effort parse partial JSON, then validate the parsed fragment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYes
partial_jsonYes
allow_partialNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultNo
artifactsNo
diagnosticsNo
resolved_targetNo

Implementation Reference

  • The helper function that performs the parsing and validation logic for `parse_partial_json`.
    def parse_partial_json_report(
        runtime_target: RuntimeTarget,
        *,
        partial_json: str,
        allow_partial: bool,
    ) -> ToolResponse:
        try:
            parsed = from_json(partial_json, allow_partial=allow_partial)
        except ValueError as exc:
            return ToolResponse(
                resolved_target=runtime_target.resolved,
                diagnostics=[
                    Diagnostic(level="error", message=str(exc), code="partial_json_error")
                ],
                result={
                    "parsed_fragment": None,
                    "validation": {"ok": False, "errors": []},
                    "stopped_at": len(partial_json),
                },
            )
    
        validation = validate_with_adapter(
            runtime_target,
            data=parsed,
            mode="python",
            strict=False,
            context=None,
        )
        consumed = _approximate_json_consumed_length(partial_json)
        return ToolResponse(
            resolved_target=runtime_target.resolved,
            diagnostics=validation.diagnostics,
            result={
                "parsed_fragment": to_jsonable(parsed),
                "validation": validation.result,
                "stopped_at": consumed,
            },
        )
  • The tool definition/handler for `parse_partial_json`, which uses `parse_partial_json_report` to perform the actual work.
    def parse_partial_json(
        target: str,
        partial_json: str,
        allow_partial: bool = True,
    ) -> ToolResponse:
        """Best-effort parse partial JSON, then validate the parsed fragment."""
        runtime_target = resolve_target(
            target,
            registry=REGISTRY,
            settings=SERVER_SETTINGS,
        )
        response = parse_partial_json_report(
            runtime_target,
            partial_json=partial_json,
            allow_partial=allow_partial,
        )
        _record_response_errors("parse_partial_json", target, response)
        return response
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'best-effort' parsing and validation, hinting at non-guaranteed success, but lacks details on error handling, performance, or output format. For a tool with no annotations and an output schema, this is insufficient to inform the agent about operational behavior.

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?

The description is extremely concise and front-loaded in a single sentence: 'Best-effort parse partial JSON, then validate the parsed fragment.' Every word contributes to the purpose, with zero waste or redundancy, making it efficient for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no annotations, but an output schema exists), the description is incomplete. It states the core function but lacks usage context, parameter details, and behavioral traits. The output schema mitigates some gaps by defining return values, but overall, the description doesn't provide enough information for effective tool invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate by explaining parameters. It adds no meaning beyond the schema, failing to clarify what 'target', 'partial_json', or 'allow_partial' represent. With 3 parameters and no schema descriptions, this leaves the agent guessing about input semantics.

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 clearly states the tool's purpose: 'Best-effort parse partial JSON, then validate the parsed fragment.' It specifies the verb ('parse'), resource ('partial JSON'), and an additional action ('validate'). However, it doesn't explicitly differentiate from sibling tools like 'validate_data' or 'serialize_data', which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. There's no mention of scenarios where partial JSON parsing is needed, prerequisites, or comparisons to sibling tools such as 'validate_data' for complete JSON validation. This leaves the agent without context for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BitingSnakes/pydantic-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server