JSON Model Context Protocol
What is JSON Model Context Protocol
The JSON MCP Server is an implementation designed for querying and manipulating JSON data using the JSON Model Context Protocol. It provides a structured way for LLMs (Large Language Models) to interact seamlessly with JSON data through a collection of standardized tools.
Use cases
This server can be utilized in various scenarios such as data retrieval, analysis, and transformation in applications that require JSON handling. It is particularly useful for backend services, data pipelines, and applications that need to process JSON data dynamically based on user queries.
How to use
Users can install the server via npx for a specific version or globally using npm. After installation, the server can be run using the command ‘server-json-mcp’. Additionally, it can be configured for use with Claude Desktop by adding the appropriate command and arguments to the application’s configuration file.
Key features
The server offers a range of tools including ‘query’ for fetching JSON data with JSONPath syntax and ‘filter’ for applying conditions to filter JSON objects. Supported operations include array slicing, sorting, distinct value extraction, string manipulations, numeric calculations, date formatting, and aggregation functions.
Where to use
The JSON MCP Server can be integrated into web applications, APIs, and desktop applications that manage JSON data. It is especially beneficial in data-driven environments where dynamic querying and processing of JSON structures are necessary to provide insights or user-specific data interactions.
Overview
What is JSON Model Context Protocol
The JSON MCP Server is an implementation designed for querying and manipulating JSON data using the JSON Model Context Protocol. It provides a structured way for LLMs (Large Language Models) to interact seamlessly with JSON data through a collection of standardized tools.
Use cases
This server can be utilized in various scenarios such as data retrieval, analysis, and transformation in applications that require JSON handling. It is particularly useful for backend services, data pipelines, and applications that need to process JSON data dynamically based on user queries.
How to use
Users can install the server via npx for a specific version or globally using npm. After installation, the server can be run using the command ‘server-json-mcp’. Additionally, it can be configured for use with Claude Desktop by adding the appropriate command and arguments to the application’s configuration file.
Key features
The server offers a range of tools including ‘query’ for fetching JSON data with JSONPath syntax and ‘filter’ for applying conditions to filter JSON objects. Supported operations include array slicing, sorting, distinct value extraction, string manipulations, numeric calculations, date formatting, and aggregation functions.
Where to use
The JSON MCP Server can be integrated into web applications, APIs, and desktop applications that manage JSON data. It is especially beneficial in data-driven environments where dynamic querying and processing of JSON structures are necessary to provide insights or user-specific data interactions.
Content
JSON MCP Server (@gongrzhe/[email protected])
A JSON Model Context Protocol (MCP) server implementation for querying and manipulating JSON data. This server enables LLMs to interact with JSON data through a set of standardized tools.
Installation & Usage
# Using npx with specific version (recommended)
npx @gongrzhe/[email protected]
# Install specific version globally
npm install -g @gongrzhe/[email protected]
# Run after global installation
server-json-mcp
Components
Tools
-
query
- Query JSON data using JSONPath syntax with extended operations
- Input:
url
(string): URL of the JSON data sourcejsonPath
(string): JSONPath expression with optional operations
-
filter
- Filter JSON data using conditions
- Input:
url
(string): URL of the JSON data sourcejsonPath
(string): Base JSONPath expressioncondition
(string): Filter condition
Supported Operations
Array Operations
- Slicing:
$[0:5]
,$[-3:]
,$[1:4]
- Sorting:
$.sort(price)
,$.sort(-price)
- Distinct:
$.distinct()
- Transformations:
- Map:
$.map(fieldName)
- Flatten:
$.flatten()
- Union:
$.union([1,2,3])
- Intersection:
$.intersection([1,2,3])
- Map:
String Operations
- Case:
$.toLowerCase()
,$.toUpperCase()
- Tests:
$.startsWith('test')
,$.endsWith('test')
- Search:
$.contains('test')
,$.matches('pattern')
Numeric Operations
- Math:
$.math(+10)
,$.pow2()
- Rounding:
$.round()
,$.floor()
,$.ceil()
- Functions:
$.abs()
,$.sqrt()
Date Operations
- Format:
$.format('YYYY-MM-DD')
- Check:
$.isToday()
- Modify:
$.add(1, 'days')
Aggregation Operations
- Group:
$.groupBy(category)
- Stats:
$.sum(price)
,$.avg(price)
,$.min(price)
,$.max(price)
Configuration
Usage with Claude Desktop
To use this server with the Claude Desktop app, add the following configuration to your claude_desktop_config.json
:
{
"json": {
"command": "npx",
"args": [
"@gongrzhe/[email protected]"
]
}
}
Alternatively, you can use the node command directly if you have the package installed:
{
"json": {
"command": "node",
"args": [
"path/to/build/index.js"
]
}
}
Development
Building from Source
- Clone the repository
- Install dependencies:
npm install
- Build the project:
npm run build
Notes
- All JSONPath expressions start with
$
representing the root object - Array indices are zero-based
- String values in operations should be wrapped in quotes
- Date operations support ‘days’, ‘months’, and ‘years’ units
- Numeric operations support basic arithmetic operators (+, -, *, /)
License
MIT