optimize_json
Reduce token usage by optimizing JSON payloads: extract specific fields via JSONPath, limit output size, and flatten deep nesting.
Instructions
Optimize any JSON payload to reduce token usage.
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": {
"data": "<data>"
},
"name": "optimize_json"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Raw JSON string to optimize, OR a file path to a JSON file. When an MCP tool response is too large and gets saved to a file, pass the file path here (e.g. '/path/to/tool-results/file.txt'). | |
| jsonpath | No | JSONPath expression to extract specific fields (e.g. '$[*].name', '$[?@.state=="open"]') | |
| max_chars | No | Maximum characters in output | |
| max_depth | No | Max nesting depth before flattening (default 5) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |