🏠 📇 - Query and extract only the needed parts of JSON files to keep LLM context small
JSON MCP Filter
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A powerful Model Context Protocol (MCP) server that provides JSON schema generation and filtering tools for local files and remote HTTP/HTTPS endpoints. Built with quicktype for robust TypeScript type generation.
**Perfect for**: Filtering large JSON files and API responses to extract only relevant data for LLM context, while maintaining type safety.
✨ Key Features
- 🔄 **Schema Generation** - Convert JSON to TypeScript interfaces using quicktype
- 🎯 **Smart Filtering** - Extract specific fields with shape-based filtering
- 🌐 **Remote Support** - Works with HTTP/HTTPS URLs and API endpoints
- 📦 **Auto Chunking** - Handles large datasets with automatic 400KB chunking
- 🛡️ **Size Protection** - Built-in 50MB limit with memory safety
- ⚡ **MCP Ready** - Seamless integration with Claude Desktop and Claude Code
- 🚨 **Smart Errors** - Clear, actionable error messages with debugging info
🛠️ Available Tools
json_schema
Generates TypeScript interfaces from JSON data.
**Parameters:**
- filePath: Local file path or HTTP/HTTPS URL
**Example:**
json_filter
Extracts specific fields using shape-based filtering with automatic chunking for large datasets.
**Parameters:**
- filePath: Local file path or HTTP/HTTPS URL
- shape: Object defining which fields to extract
- chunkIndex (optional): Chunk index for large datasets (0-based)
**Auto-Chunking:**
- ≤400KB: Returns all data
- >400KB: Auto-chunks with metadata
json_dry_run
Analyzes data size and provides chunking recommendations before filtering.
**Parameters:**
- filePath: Local file path or HTTP/HTTPS URL
- shape: Object defining what to analyze
**Returns:** Size breakdown and chunk recommendations
📋 Usage Examples
Basic Filtering
Shape Patterns
Large Dataset Workflow
🔒 Security Notice
**Remote Data Fetching**: This tool fetches data from HTTP/HTTPS URLs. Users are responsible for:
✅ **Safe Practices:**
- Verify URLs point to legitimate endpoints
- Use trusted, public APIs only
- Respect API rate limits and terms of service
- Review data sources before processing
❌ **Maintainers Not Responsible For:**
- External URL content
- Privacy implications of remote requests
- Third-party API abuse or violations
💡 **Recommendation**: Only use trusted, public data sources.
🚀 Quick Start
Option 1: NPX (Recommended)
Option 2: Global Install
Option 3: From Source
⚙️ MCP Integration
Claude Desktop
Add to your configuration file:
Claude Code
Or add manually:
- **Name**: json-mcp-filter
- **Command**: npx
- **Args**: ["-y", "json-mcp-filter@latest"]
🔧 Development
Commands
Testing
📁 Project Structure
🚨 Error Handling
Comprehensive Coverage
- **Local Files**: Not found, permissions, invalid JSON
- **Remote URLs**: Network failures, auth errors (401/403), server errors (500+)
- **Content Size**: Auto-reject >50MB with clear messages
- **Format Detection**: Smart detection of HTML/XML with guidance
- **Rate Limiting**: 429 responses with retry instructions