JSON过滤器
STDIOJSON模式生成和智能过滤MCP服务器
JSON模式生成和智能过滤MCP服务器
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.
json_schemaGenerates TypeScript interfaces from JSON data.
Parameters:
filePath: Local file path or HTTP/HTTPS URLExample:
// Input JSON {"name": "John", "age": 30, "city": "New York"} // Generated TypeScript export interface GeneratedType { name: string; age: number; city: string; }
json_filterExtracts specific fields using shape-based filtering with automatic chunking for large datasets.
Parameters:
filePath: Local file path or HTTP/HTTPS URLshape: Object defining which fields to extractchunkIndex (optional): Chunk index for large datasets (0-based)Auto-Chunking:
400KB: Auto-chunks with metadata
json_dry_runAnalyzes data size and provides chunking recommendations before filtering.
Parameters:
filePath: Local file path or HTTP/HTTPS URLshape: Object defining what to analyzeReturns: Size breakdown and chunk recommendations
// Simple field extraction json_filter({ filePath: "https://api.example.com/users", shape: {"name": true, "email": true} })
// Single field {"name": true} // Nested objects {"user": {"name": true, "email": true}} // Arrays (applies to each item) {"users": {"name": true, "age": true}} // Complex nested { "results": { "profile": {"name": true, "location": {"city": true}} } }
// 1. Check size first json_dry_run({filePath: "./large.json", shape: {"users": {"id": true}}}) // → "Recommended chunks: 6" // 2. Get chunks json_filter({filePath: "./large.json", shape: {"users": {"id": true}}}) // → Chunk 0 + metadata json_filter({filePath: "./large.json", shape: {"users": {"id": true}}, chunkIndex: 1}) // → Chunk 1 + metadata
Remote Data Fetching: This tool fetches data from HTTP/HTTPS URLs. Users are responsible for:
✅ Safe Practices:
❌ Maintainers Not Responsible For:
💡 Recommendation: Only use trusted, public data sources.
# No installation required npx json-mcp-filter@latest
npm install -g json-mcp-filter@latest json-mcp-server
git clone <repository-url> cd json-mcp-filter npm install npm run build
Add to your configuration file:
{ "mcpServers": { "json-mcp-filter": { "command": "npx", "args": ["-y", "json-mcp-filter@latest"] } } }
# Add via CLI claude mcp add json-mcp-filter npx -y json-mcp-filter@latest
Or add manually:
json-mcp-filternpx["-y", "json-mcp-filter@latest"]npm run build # Compile TypeScript npm run start # Run compiled server npm run inspect # Debug with MCP inspector npx tsc --noEmit # Type check only
npm run inspect # Interactive testing interface
src/
├── index.ts                    # Main server + tools
├── strategies/                 # Data ingestion strategies
│   ├── JsonIngestionStrategy.ts  # Abstract interface
│   ├── LocalFileStrategy.ts      # Local file access
│   └── HttpJsonStrategy.ts       # HTTP/HTTPS fetching
├── context/
│   └── JsonIngestionContext.ts   # Strategy management
└── types/
    └── JsonIngestion.ts          # Type definitions
All errors include actionable debugging information.
| File Size | Processing Time | 
|---|---|
| < 100 KB | < 10ms | 
| 1-10 MB | 100ms - 1s | 
| 10-50 MB | 1s - 5s | 
| > 50 MB | Blocked | 
json_dry_run first for large filesjson_filter before schema generationhttp://localhost during developmentLLM Integration:
json_filter extracts relevant fieldsjson_schema generates types for safety