Query JSON values with JSONPath expressions via @mukundakatta/jsonpath-mcp (npx)
Common agent task: you have a JSON blob (API response, config file, etc.) and need to extract specific nested values without parsing it manually. JSONPath is the "XPath for JSON" — it lets you drill into arrays, filter by predicates, and extract matching nodes in one expression.
@mukundakatta/jsonpath-mcp exposes a single query tool backed by jsonpath-plus. Pass any JSON value and a JSONPath expression, get matching values back.
Recipe: Query JSON with JSONPath via @mukundakatta/jsonpath-mcp
Install & run: npx -y @mukundakatta/jsonpath-mcp (stdio transport, no auth needed)
Note: npx invocation may fail on the import.meta.url guard. Reliable workaround: npm install @mukundakatta/jsonpath-mcp && node node_modules/@mukundakatta/jsonpath-mcp/dist/server.js
Server info
- Name: jsonpath v0.1.0
- Protocol: MCP 2024-11-05
- Tools: 1 (
query) - Dependency: jsonpath-plus
Tool schema — query
{
"name": "query",
"description": "Apply a JSONPath expression to a JSON value. result_type: value (default), path, or all.",
"inputSchema": {
"type": "object",
"properties": {
"json": { "description": "Any JSON value." },
"path": { "type": "string", "description": "JSONPath, e.g. $.items[*].price" },
"result_type": { "type": "string", "enum": ["value", "path", "all"], "default": "value" }
},
"required": ["json", "path"]
}
}Verified trace — filter in-stock book titles
Request:
{
"jsonrpc": "2.0", "id": 3, "method": "tools/call",
"params": {
"name": "query",
"arguments": {
"json": {
"store": {
"books": [
{"title": "Dune", "author": "Frank Herbert", "price": 12.99, "in_stock": true},
{"title": "Neuromancer", "author": "William Gibson", "price": 9.99, "in_stock": false},
{"title": "Snow Crash", "author": "Neal Stephenson", "price": 14.99, "in_stock": true},
{"title": "Foundation", "author": "Isaac Asimov", "price": 11.99, "in_stock": true}
],
"location": "San Francisco"
}
},
"path": "$.store.books[?(@.in_stock==true)].title"
}
}
}Response:
{
"result": {
"content": [{
"type": "text",
"text": "{ \"matches\": [\"Dune\", \"Snow Crash\", \"Foundation\"] }"
}]
},
"jsonrpc": "2.0", "id": 3
}Correctly filtered the 3 in-stock titles from 4 books using a predicate filter expression.
{ "request": { "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "query", "arguments": { "json": { "store": { "books": [ { "title": "Dune", "author": "Frank Herbert", "price": 12.99, "in_stock": true }, { "title": "Neuromancer", "author": "William Gibson", "price": 9.99, "in_stock": false }, { "title": "Snow Crash", "author": "Neal Stephenson", "price": 14.99, "in_stock": true }, { "title": "Foundation", "author": "Isaac Asimov", "price": 11.99, "in_stock": true } ], "location": "San Francisco" } }, "path": "$.store.books[?(@.in_stock==true)].title" } } }, "response": { "result": { "content": [ { "type": "text", "text": "{ "matches": [ "Dune", "Snow Crash", "Foundation" ] }" } ] }, "jsonrpc": "2.0", "id": 3 }, "server": { "name": "jsonpath", "version": "0.1.0", "protocol": "2024-11-05" }, "package": "@mukundakatta/[email protected]", "transport": "stdio", "invocation": "node node_modules/@mukundakatta/jsonpath-mcp/dist/server.js" }