response_slice
Extract targeted fragments from saved API response JSON files using logical jsonPath or line ranges, avoiding manual reads.
Instructions
response_slice
Extracts a specific fragment of a saved JSON response file by logical jsonPath or by line range.
When to use
Use this tool when you know which object, array, or field you want to inspect inside a large response. Prefer jsonPath over line numbers because it is stable and descriptive.
When NOT to use
Do NOT use
bash,cat,head,tail,file,open,less,more, or any external command to readfileRef.path.Do NOT read the file manually. This tool is the only allowed way to extract fragments from saved response files.
Parameters
path(required): The absolute file path fromfileRef.pathreturned byinvoke.jsonPath(optional): Logical path such asdata.0,users.3.name, orcompany.departments.engineering.employees.0. Use gjson dotted syntax. Leave empty (or use@this) to target the root value — for a root array this returns its first element.line(optional): 1-based line number to center the fragment on. The tool returnsaroundlines above and below.range(optional): Exact line range asstart-end(for example120-240).around(optional): Number of lines to include aroundline. Default is 20.
Returns
slice.lines: 1-based line range of the returned fragment.slice.value: the extracted JSON value parsed into a structured object.slice.fragment: raw JSON text when the fragment is small enough to include.slice.context:object,array, orvaluedescribing what was extracted.slice.isComplete: true whenvalueis a valid JSON fragment.slice.nextPath/slice.prevPath: suggested adjacent paths for array navigation.slice.nextLine/slice.prevLine: suggested line numbers for line-based navigation.fileRef: only present when the extracted fragment exceeded the size limit and was saved to disk.
Example
response_slice({
"path": "/.../responses/...json",
"jsonPath": "pets.0"
})Then continue with pets.1, pets.2, etc. using slice.nextPath.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| line | No | optional,1-based line number to center the fragment on | |
| path | Yes | required,Absolute path returned in fileRef.path | |
| range | No | optional,Line range as start-end (e.g. 120-240) | |
| around | No | optional,Lines to include around line (default 20) | |
| jsonPath | No | optional,Logical path to the value (e.g. data.3.name) |