JSON MCP is a server designed to elegantly filter and generate JSON schemas for AI applications. Using tools like quicktype, it converts JSON samples to TypeScript definitions and allows for precise data extraction, ensuring only the essential information is integrated into LLM contexts.
The JSON MCP Filter serves as a powerful Model Context Protocol (MCP) server designed for effective JSON schema generation and data filtering. Utilizing the quicktype library, the project converts JSON samples into TypeScript type definitions and offers practical tools to filter JSON data, ensuring users can focus only on the relevant information for their Large Language Model (LLM) context.
Generates TypeScript type definitions from JSON files.
Parameters:
filePath: The path to the JSON file for analysis.Example:
{"name": "John", "age": 30, "city": "New York"}
This command produces TypeScript interfaces with the appropriate typing.
Allows for the extraction of specific fields from JSON data through a defined shape.
Parameters:
filePath: The path to the JSON file to filter.shape: A shape object that specifies which fields to extract.Shape Examples:
// Extract single field
{"name": true}
// Extract multiple fields
{"name": true, "age": true}
// Extract nested fields
{"user": {"name": true, "email": true}}
// Extract from arrays (applies to each item)
{"users": {"name": true, "age": true}}
The JSON MCP Filter includes several scripts to facilitate development:
npm run build: Compiles TypeScript and prepares the server for execution.npm run start: Launches the compiled server.npm run inspect: Runs the server with an MCP inspector for debugging purposes.npx tsc --noEmit: Performs type checking without generating output files.To test the server interactively, use the MCP inspector:
npm run inspect
src/
index.ts # Main server implementation with tools
test/
test.json # Sample JSON file for testing
build/ # Compiled TypeScript output
Robust error handling mechanisms are embedded within the server to manage various issues, including:
This strategic approach ensures a smooth user experience while leveraging the capabilities of the JSON MCP Filter.
No comments yet.
Sign in to be the first to comment.