Data Query Plugin¶
The data_query plugin provides a tool to query JSON and YAML data using
JSONPath expressions. It accepts either a file on disk
or an inline content string, and returns all matched values together with their count.
Tools¶
query_json_data_file¶
Evaluates a JSONPath expression against a JSON or YAML data source.
Arguments:
file_path(string, optional): Path to a JSON or YAML file on disk. The format is auto-detected from the file extension (.json,.yaml,.yml). Mutually exclusive withcontent.content(string, optional): Raw JSON or YAML content string. Mutually exclusive withfile_path. Requiresformatto be set explicitly.format(string, optional): Data format —"json"or"yaml". Required whencontentis used. Whenfile_pathis used, inferred from the extension unless overridden.jsonpath_expression(string, required): JSONPath expression to evaluate (e.g.$.servers[*].host).
Exactly one of file_path or content must be supplied.
Return value:
On failure:
Features:
- JSONPath support: Full JSONPath syntax via
jsonpath-ng, including recursive descent (..), wildcards ([*]), array slices, and filter expressions ([?(@.key=='value')]). - Dual input modes: Query a file by path or pass content directly as a string — useful for querying data already held in memory by an agent.
- Auto format detection: Derives the parse format from
.json,.yaml, or.ymlextensions so callers rarely need to setformatexplicitly. .aiignorecompliance: Refuses to read files matched by.aiignorerules.- No size limit: Suitable for large configuration or data files.
Examples¶
Query a JSON file¶
Given config.json:
{
"servers": [
{"host": "api.example.com", "env": "prod"},
{"host": "staging.example.com", "env": "staging"},
{"host": "db.example.com", "env": "prod"}
]
}
Retrieve all hostnames:
{
"status": "ok",
"results": ["api.example.com", "staging.example.com", "db.example.com"],
"count": 3
}
Filter expression on a YAML file¶
Given services.yaml:
servers:
- host: api.example.com
env: prod
- host: staging.example.com
env: staging
- host: db.example.com
env: prod
Retrieve only production hosts: