Fetch JSONPath MCP

Fetch JSONPath MCP

Enables efficient extraction of specific data from JSON APIs using JSONPath patterns, reducing token usage by up to 99% compared to fetching entire responses. Supports single and batch operations for both JSON extraction and raw text retrieval from URLs.

Category
Visit Server

README

Fetch JSONPath MCP

PyPI Downloads 简体中文

A Model Context Protocol (MCP) server that provides tools for fetching and extracting JSON data from URLs using JSONPath patterns.

🎯 Why Use This?

Reduce LLM Token Usage & Hallucination - Instead of fetching entire JSON responses and wasting tokens, extract only the data you need.

Traditional Fetch vs JSONPath Extract

❌ Traditional fetch (wasteful):

// API returns 2000+ tokens
{
  "data": [
    {
      "id": 1,
      "name": "Alice",
      "email": "alice@example.com", 
      "avatar": "https://...",
      "profile": {
        "bio": "Long bio text...",
        "settings": {...},
        "preferences": {...},
        "metadata": {...}
      },
      "posts": [...],
      "followers": [...],
      "created_at": "2023-01-01",
      "updated_at": "2024-01-01"
    },
    // ... 50 more users
  ],
  "pagination": {...},
  "meta": {...}
}

✅ JSONPath extract (efficient):

// Only 10 tokens - exactly what you need!
["Alice", "Bob", "Charlie"]

Using pattern: data[*].name saves 99% tokens and eliminates model hallucination from irrelevant data.

Installation

For most IDEs, use the uvx tool to run the server.

{
  "mcpServers": {
    "fetch-jsonpath-mcp": {
      "command": "uvx",
      "args": [
        "fetch-jsonpath-mcp"
      ]
    }
  }
}

<details> <summary><b>Install in Claude Code</b></summary>

claude mcp add fetch-jsonpath-mcp -- uvx fetch-jsonpath-mcp

</details>

<details> <summary><b>Install in Cursor</b></summary>

{
  "mcpServers": {
    "fetch-jsonpath-mcp": {
      "command": "uvx",
      "args": ["fetch-jsonpath-mcp"]
    }
  }
}

</details>

<details> <summary><b>Install in Windsurf</b></summary>

Add this to your Windsurf MCP config file. See Windsurf MCP docs for more info.

Windsurf Local Server Connection

{
  "mcpServers": {
    "fetch-jsonpath-mcp": {
      "command": "uvx",
      "args": ["fetch-jsonpath-mcp"]
    }
  }
}

</details>

<details> <summary><b>Install in VS Code</b></summary>

"mcp": {
  "servers": {
    "fetch-jsonpath-mcp": {
      "type": "stdio",
      "command": "uvx",
      "args": ["fetch-jsonpath-mcp"]
    }
  }
}

</details>

Development Setup

1. Install Dependencies

uv sync

2. Start Demo Server (Optional)

# Install demo server dependencies
uv add fastapi uvicorn

# Start demo server on port 8080
uv run demo-server

3. Run MCP Server

uv run fetch-jsonpath-mcp

Demo Server Data

The demo server at http://localhost:8080 returns:

{
  "foo": [{"baz": 1, "qux": "a"}, {"baz": 2, "qux": "b"}],
  "bar": {
    "items": [10, 20, 30], 
    "config": {"enabled": true, "name": "example"}
  },
  "metadata": {"version": "1.0.0"}
}

Available Tools

get-json

Extract JSON data using JSONPath patterns.

{
  "name": "get-json",
  "arguments": {
    "url": "http://localhost:8080",
    "pattern": "foo[*].baz"
  }
}

Returns: [1, 2]

get-text

Get raw text content from any URL.

{
  "name": "get-text",
  "arguments": {
    "url": "http://localhost:8080"
  }
}

Returns: {"foo": [{"baz": 1, "qux": "a"}, {"baz": 2, "qux": "b"}], "bar": {"items": [10, 20, 30], "config": {"enabled": true, "name": "example"}}, "metadata": {"version": "1.0.0"}}

batch-get-json

Process multiple URLs with different JSONPath patterns.

{
  "name": "batch-get-json",
  "arguments": {
    "requests": [
      {"url": "http://localhost:8080", "pattern": "foo[*].baz"},
      {"url": "http://localhost:8080", "pattern": "bar.items[*]"}
    ]
  }
}

Returns: [[1, 2], [10, 20, 30]]

batch-get-text

Get text content from multiple URLs.

{
  "name": "batch-get-text",
  "arguments": {
    "urls": ["http://localhost:8080", "http://localhost:8080"]
  }
}

Returns: ["JSON content...", "JSON content..."]

JSONPath Examples

This project uses jsonpath-ng for JSONPath implementation.

Pattern Result Description
foo[*].baz [1, 2] Get all baz values
bar.items[*] [10, 20, 30] Get all items
metadata.version ["1.0.0"] Get version

For complete JSONPath syntax reference, see the jsonpath-ng documentation.

🚀 Performance Benefits

  • Token Efficiency: Extract only needed data, not entire JSON responses
  • Faster Processing: Smaller payloads = faster LLM responses
  • Reduced Hallucination: Less irrelevant data = more accurate outputs
  • Cost Savings: Fewer tokens = lower API costs
  • Better Focus: Clean data helps models stay on task

Configuration

Set environment variables:

export JSONRPC_MCP_TIMEOUT=30
export JSONRPC_MCP_HEADERS='{"Authorization": "Bearer token"}'
export JSONRPC_MCP_PROXY="http://proxy.example.com:8080"

Development

# Run tests
pytest

# Check code quality
ruff check --fix

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured