Skip to main content
Glama

util_json_patch

Read-only

JSON Patch / Merge Patch apply — Apply a patch to a JSON document, fully offline. Supports RFC 6902 JSON Patch (array of add, remove, replace, move, copy, test operations with RFC 6901 JSON Pointer paths incl. ~0/~1 escapes and the - array append) and RFC 7396 JSON Merge Patch (object: null deletes, objects merge recursively). Required: doc= (JSON text) and patch= (JSON text). Optional: mode=auto|json-patch|merge-patch (auto picks json-patch for an array, merge-patch for an object). Returns the patched result, whether anything changed, per-op steps and op counts. JSON Patch is atomic: a failed test or a bad path returns HTTP 422 with the failing operation index and reason (you are not charged). Up to 200,000 characters and 1,000 operations. Pairs with /v1/util/json-diff (which produces RFC 6902 patches). Price: $0.002 USDC (Base, via x402).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "doc": "<doc>",
      "patch": "<patch>"
    },
    "name": "util_json_patch"
  }
}

Input Schema

NameRequiredDescriptionDefault
docYes{"name":"Ada","tags":["math"]}
patchYes[{"op":"replace","path":"/name","value":"Ada Lovelace"},{"op":"add","path":"/tags/-","value":"computing"}]

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the annotations (readOnlyHint=true already covers safety) by disclosing atomicity, that a failed test or bad path returns HTTP 422 with the failing operation index and reason, that such failures are not charged, hard limits of 200,000 characters and 1,000 operations, and the $0.002 USDC x402 price. It also describes the return payload (patched result, changed flag, per-op steps, op counts) despite there being no output schema. The 'fully offline' phrasing sits in mild tension with openWorldHint=true, but it plainly refers to the patch computation being done server-side without external calls, not to the transport.

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 verb and standards, then requirements, then return/error semantics, then limits and pricing — a sensible priority order. It is a dense single block rather than structured sections, and the pricing/endpoint sentence is less relevant to invocation, but almost every sentence carries operational value.

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 two-parameter tool with no output schema, the description covers input format, mode selection, success payload shape, failure semantics with status code and error fields, and resource limits — everything an agent needs to call it correctly and to interpret both outcomes.

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

Parameters4/5

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

Schema coverage is already 100%, so the baseline is 3; the description adds real meaning by specifying that doc and patch are JSON *text* (strings, not objects) and by enumerating the accepted operation set, RFC 6901 pointer syntax including ~0/~1 escapes and the - append token, and merge-patch null-deletes. The one flaw is that it advertises an optional mode=auto|json-patch|merge-patch parameter that does not exist in the input schema, which could mislead an agent into sending it.

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 the specific operation ('Apply a patch to a JSON document') plus both supported standards (RFC 6902 and RFC 7396), and explicitly names the sibling it pairs with (/v1/util/json-diff) and what that sibling does. An agent can distinguish it from util_json_diff, util_json_schema and the other format converters without opening a 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?

Gives concrete selection guidance via mode=auto, spelling out the rule ('auto picks json-patch for an array, merge-patch for an object'), and routes the agent to util_json_diff when a patch needs to be produced rather than applied. What is missing is an explicit when-not clause, e.g. that this tool cannot compute a diff or validate a document without applying a patch.

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