Fetch JSONPath MCP
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):
✅ JSONPath extract (efficient):
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.
Add this to your Windsurf MCP config file. See Windsurf MCP docs for more info.
Windsurf Local Server Connection
Development Setup
1. Install Dependencies
2. Start Demo Server (Optional)
3. Run MCP Server
Demo Server Data
The demo server at http://localhost:8080
returns:
Available Tools
get-json
Extract JSON data using JSONPath patterns.
Returns: [1, 2]
get-text
Get raw text content from any URL.
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.
Returns: [[1, 2], [10, 20, 30]]
batch-get-text
Get text content from multiple URLs.
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:
Development
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
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.
Related MCP Servers
- AsecurityAlicenseAqualityEnables extracting data from websites using natural language prompts, allowing users to specify exactly what content they want in plain English and returning structured JSON data.Last updated -16146TypeScriptMIT License
- AsecurityFlicenseAqualityProvides functionality to fetch web content in various formats, including HTML, JSON, plain text, and Markdown with support for custom headers.Last updated -4101,9183TypeScript
- -securityFlicense-qualityProvides functionality to fetch and transform web content in various formats (HTML, JSON, plain text, and Markdown) through simple API calls.Last updated -101,9181TypeScript
- AsecurityAlicenseAqualityA powerful tool for fetching and extracting text content from web pages and APIs, supporting web scraping, REST API requests, and Google Custom Search integration.Last updated -42JavaScriptMIT License