JSON Manipulation MCP server

Provides a JSON manipulation interface using JSONPath syntax for querying, transforming, and analyzing structured data across diverse datasets.
Back to servers
Setup instructions
Provider
gongrzhe
Release date
Dec 24, 2024
Language
TypeScript
Package
Stats
4.8K downloads
67 stars

The JSON MCP Server is a Model Context Protocol implementation that allows Large Language Models to interact with JSON data. It provides standardized tools for querying and manipulating JSON using JSONPath syntax with extended operations, enabling powerful data extraction and transformation capabilities.

Installation

You can run the JSON MCP Server in several ways:

Using npx (Recommended)

Run the server directly with npx without installation:

npx @gongrzhe/[email protected]

Global Installation

Install the package globally and then run it:

# Install globally
npm install -g @gongrzhe/[email protected]

# Run the server
server-json-mcp

Available Tools

The server provides two main tools for interacting with JSON data:

Query Tool

The query tool allows you to extract data using JSONPath expressions with extended operations.

Input parameters:

  • url (string): URL of the JSON data source
  • jsonPath (string): JSONPath expression with optional operations

Filter Tool

The filter tool lets you filter JSON data based on specified conditions.

Input parameters:

  • url (string): URL of the JSON data source
  • jsonPath (string): Base JSONPath expression
  • condition (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])

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)

Integration 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]"
    ]
  }
}

If you have the package installed, you can use the node command directly:

{
  "json": {
    "command": "node",
    "args": [
      "path/to/build/index.js"
    ]
  }
}

Usage Tips

  • All JSONPath expressions must 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 (+, -, *, /)

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "json" '{"command":"npx","args":["@gongrzhe/[email protected]"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "json": {
            "command": "npx",
            "args": [
                "@gongrzhe/[email protected]"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "json": {
            "command": "npx",
            "args": [
                "@gongrzhe/[email protected]"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later