mcp-json-query mcp

v1.0.0 · MCP Tool · registry.pascalai.org

Query and extract data from JSON using JSONPath ($..store.book[*].author) or JMESPath (store.book[].author) expressions. Use this to navigate complex API responses, filter arrays, or reshape JSON data without writing custom parsing code.

Input Parameters

ParameterTypeDescription
jsonrequired object | array | string JSON data to query. Can be a parsed object/array or a raw JSON string.
queryrequired string JSONPath or JMESPath expression to evaluate against the input data.
dialectoptional string Query language: "jsonpath" or "jmespath". Default: "jsonpath".
flattenoptional boolean Flatten nested arrays in the result into a single level. Default: false.

Output Fields

FieldTypeDescription
result any Query result. May be a value, array, or object depending on the expression.
count integer Number of matches when the result is an array. 1 for scalar results.
query string The query expression that was evaluated (echoed from input).
dialect string The query dialect used: "jsonpath" or "jmespath".

Quick Reference

JSONPath

$.store.book[*].authorAll authors in the book array
$.store.book[?(@.price < 10)]Books where price is less than 10
$..titleAll title values at any depth (recursive)
$.items[0:3]First 3 items (slice notation)
$.users[?(@.active == true)].emailEmails of all active users

JMESPath

store.book[].authorAll authors in the book array
store.book[?price < `10`]Books where price is less than 10
users[?active].emailEmails of active users
sort_by(items, &price)Items sorted ascending by price

Examples

// JSONPath — extract active user emails
{
  "json": {
    "users": [
      { "name": "Ana",  "email": "ana@x.com",  "active": true },
      { "name": "Luis", "email": "luis@x.com", "active": false }
    ]
  },
  "query": "$.users[?(@.active == true)].email"
}
// Output
{
  "result": ["ana@x.com"],
  "count": 1,
  "query": "$.users[?(@.active == true)].email",
  "dialect": "jsonpath"
}

// JMESPath — sort products by price, return names only
{
  "json": { "products": [ {"name":"B","price":20}, {"name":"A","price":5} ] },
  "query": "sort_by(products, &price)[].name",
  "dialect": "jmespath"
}
// Output
{
  "result": ["A", "B"],
  "count": 2
}

Install & Discovery

Install

ppm install mcp-json-query

Get JSON Schema

GET /v1/packages/mcp-json-query/1.0.0/schema

Discover by keyword

GET /v1/mcp/discover?q=json+query+jsonpath
Discovery hint: Use this tool whenever an agent receives a large JSON payload (from an HTTP API, database response, or file) and needs to extract specific fields, filter arrays by condition, or reshape the structure without custom code.

PascalAI Usage

uses toolslib;

var JQ   := LoadTool('mcp-json-query');
var HTTP := LoadTool('mcp-http-request');

// Fetch products from API then query in-stock IDs
var Resp := HTTP.Call(JsonObj(['url', 'https://api.example.com/products']));
var Ids  := JQ.Call(JsonObj([
  'json',  Resp['body_json'],
  'query', '$.products[?(@.stock > 0)].id'
]));
Writeln('In-stock product IDs: ' + Ids['count']);