A Model Context Protocol (MCP) server for reading and querying local JSON files with extended syntax. This tool enables LLMs to perform complex data manipulations directly on local JSON datasets.
- Local File Support: Read any local JSON file.
- Extended JSONPath: Support for standard JSONPath plus:
- Sorting:
.sort(field),.sort(-field) - Aggregation:
.sum(field),.avg(field),.min(field),.max(field) - Numeric:
.math(+10),.round(),.abs(), etc. - String:
.contains(),.startsWith(),.toLowerCase(), etc. - Date:
.format('YYYY-MM-DD'),.isToday() - Array:
.distinct(),.reverse(),[start:end]
- Sorting:
- Filtering: Powerful filtering tool for array data.
# Install globally
npm install -g .
# Or run with npx
npx mcp-json-reader --root /path/to/dataThe server supports an optional base directory for resolving relative paths.
- Command Line:
--root <base_path>(Optional) - Environment Variable:
MCP_JSON_ROOT(Optional)
If neither is provided, the server defaults to the Current Working Directory (CWD) of the process. This is useful for IDEs like VSCode or Cursor, where the root path can be set per-workspace.
- Caching: The server implements an in-memory cache for parsed JSON objects. Subsequent queries on the same file are extremely fast as they skip the read and parse steps.
- Cache Validation: It automatically detects file changes using modification timestamps and invalidates the cache when necessary.
Query a local JSON file using standard JSONPath with custom extensions for data manipulation.
- Arguments:
path(string): Absolute path or path relative to the configured root directory.jsonPath(string): JSONPath expression (e.g.,$.store.book[*].author). Supports extensions like.sort(),.sum(),.math(), etc.
Extract and filter elements from an array within a local JSON file using advanced logic.
- Arguments:
path(string): Absolute path or path relative to the configured root directory.jsonPath(string): JSONPath to the array to filter (e.g.,$.store.book).condition(string): Filter condition (e.g.,@.price > 10or@.title.contains('Lord')).
{
"path": "./data.json",
"jsonPath": "$.items.sort(-price)[0:5]"
}{
"path": "./sales.json",
"jsonPath": "$.transactions.sum(amount)"
}{
"path": "./users.json",
"jsonPath": "$.users",
"condition": "@.email.endsWith('@gmail.com')"
}Add this to your claude_desktop_config.json:
{
"mcpServers": {
"json-reader": {
"command": "npx",
"args": ["-y", "mcp-json-reader", "--root", "/absolute/path/to/your/json/data"],
"env": {
"MCP_JSON_ROOT": "/optional/env/path"
}
}
}
}npm install
npm run build
npm testMIT