mcp-json-yaml-toml
The mcp-json-yaml-toml server provides a token-efficient, schema-aware interface for safely reading, modifying, and validating JSON, YAML, TOML, and JSONC files — all processed locally.
Query structured data (
data_query): Extract, filter, or transform data using yq expressions (e.g.,.name,.items[]) without modifying the file. Supports pagination and custom output formats.Get, set, or delete values (
data): Read/write operations on specific paths using dot-separated key paths. Can retrieve full data, just keys/structure, or schema info. Write operations modify the file on disk.Schema management & validation (
data_schema): Validate files against JSON schemas (from SchemaStore.org or custom sources), associate/disassociate files with schemas, add custom catalogs, and auto-discover schemas via directives, in-file keys, or IDE configs.Convert between formats (
data_convert): Transform files between JSON, YAML, and TOML, returning converted content or writing to an output file. Note: conversion to TOML has limitations for complex structures.Deep merge files (
data_merge): Merge two structured data files where the overlay file's values override the base, with configurable output format and optional file destination.Constraint validation (
constraint_validate/constraint_list): Validate values against LMQL-style constraints (e.g.,YQ_PATH,CONFIG_FORMAT,KEY_PATH,JSON_VALUE) to guide generation and improve reliability.
Formatting and comments are preserved during modifications (except JSONC writes, which strip comments). All processing is local — no data leaves the machine.
Provides token-efficient tools for reading, querying, modifying, and validating TOML files with schema awareness and syntax validation, preventing format errors.
Provides token-efficient tools for reading, querying, modifying, and validating YAML files with schema awareness, preserving comments and formatting while preventing indentation errors.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-json-yaml-toml validate my package.json file against npm schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Stop AI coding tools from breaking your data files. No more grep guesswork, hallucinated fields, or non-schema-compliant data added to files. This MCP server gives AI assistants a strict, round-trip safe interface for working with structured data.
The Problem
AI coding tools often destroy structured data files:
They grep through huge json, yaml, and toml files (like json logs, or AI transcript files) and guess at keys.
They hallucinate fields that never existed.
They use sed and regex that leave files in invalid states.
They break YAML indentation and TOML syntax.
They can't validate changes before writing.
Related MCP server: MCP Filesystem Agent v3
The Solution
mcp-json-yaml-toml provides AI assistants with proper tools for structured data:
Token-efficient: Extract exactly what you need without loading entire files.
Schema validation: Enforce correctness using SchemaStore.org or custom schemas.
Safe modifications: Enforced validation on write; preserve comments and formatting.
Multi-format: JSON, YAML, and TOML through a unified interface.
Directive-based detection: Support for
# yaml-language-server,#:schema, and$schemakeys in all formats.Constraint-based guided generation: Native LMQL support for proactive validation of partial inputs.
Local-First: All processing happens locally. No data ever leaves your machine.
Transparent JIT Assets: The server auto-downloads
yqif missing and fetches missing schemas from SchemaStore.org for local caching.
JSONC Support: Files with .jsonc extension (JSON with Comments) are fully supported for reading, querying, and schema validation. However, write operations will strip comments due to library limitations.
Getting Started
Prerequisites
Python ≥ 3.11 installed.
An MCP-compatible client (Claude Code, Cursor, Windsurf, Gemini 2.0, n8n, etc.).
Installation
The server uses uvx for automatic dependency management and zero-config execution.
AI Agents & CLI Tools
uvx mcp-json-yaml-tomlClaude Code (CLI)
claude mcp add --scope user mcp-json-yaml-toml -- uvx mcp-json-yaml-tomlOther MCP Clients
Add this to your client's MCP configuration:
{
"mcpServers": {
"json-yaml-toml": {
"command": "uvx",
"args": ["mcp-json-yaml-toml"]
}
}
}Seedocs/clients.md for detailed setup guides for Cursor, VS Code, and more.
Schema Discovery & Recognition
The server automatically identifies the correct JSON schema for your files using multiple strategies:
Directives: Recognizes
# yaml-language-server: $schema=...and#:schema ...directives.In-File Keys: Detects
$schemakeys in JSON and YAML (also supports quoted"$schema"in TOML).Local IDE Config: Discovers schemas from VS Code/Cursor extension settings and caches.
SchemaStore.org: Performs glob-based auto-detection against thousands of known formats.
Manual Association: Use the
data_schematool to bind a file to a specific schema URL or name.
LMQL & Guided Generation
This server provides native support for LMQL (Language Model Query Language) to enable Guided Generation. This allows AI agents to validate partial inputs (e.g., path expressions) incrementally before execution.
Incremental Validation: Check partial inputs (e.g.,
.data.us) and get the remaining pattern needed.Improved Reliability: Eliminate syntax errors by guiding the LLM toward valid tool inputs.
Rich Feedback: Get suggestions and detailed error messages for common mistakes.
See theDeep Dive: LMQL Constraints for detailed usage examples.
Available Tools
Tool | Description |
| Get, set, or delete values at specific paths |
| Advanced yq/jq expressions for transformations |
| Manage schemas and validate files |
| Convert between JSON, YAML, and TOML |
| Deep merge structured data files |
| Validate inputs against LMQL constraints |
| List available generation constraints |
ConversionTO TOML is not supported due to yq's internal encoder limitations for complex structures.
Development
Setup
git clone https://github.com/bitflight-devops/mcp-json-yaml-toml.git
cd mcp-json-yaml-toml
uv syncTesting
ash
Run all tests (coverage included)
uv run pytest
### Code Quality
The project uses `prek` (a Rust-based pre-commit tool) for unified linting and formatting. AI Agents MUST use the scoped verification command:
```bash
# Recommended: Verify only touched files
uv run prek run --files <file edited>Avoid--all-files during feature development to keep PR diffs clean and preserve git history.
Project Structure
mcp-json-yaml-toml/
├── packages/mcp_json_yaml_toml/ # Core logic
│ ├── server.py # MCP implementation
│ ├── yq_wrapper.py # Binary management
│ ├── schemas.py # Schema validation
├── .github/ # CI/CD and assets
├── docs/ # Documentation
└── pyproject.toml # Project config# Run all tests (coverage included)
uv run pytestCode Quality
The project uses prek (a Rust-based pre-commit tool) for unified linting and formatting. AI Agents MUST use the scoped verification command:
# Recommended: Verify only touched files
uv run prek run --files <file edited>Avoid--all-files during feature development to keep PR diffs clean and preserve git history.
Project Structure
graph TD
Repo[mcp-json-yaml-toml]
Repo --> Packages[packages/mcp_json_yaml_toml]
Repo --> Github[.github]
Repo --> Docs[docs]
Repo --> Config[pyproject.toml]
subgraph "Core Logic"
Packages --> Server[server.py<br/>MCP Server & Tools]
Packages --> Schemas[schemas.py<br/>Schema Validation]
Packages --> Constraints[lmql_constraints.py<br/>LMQL Constraints]
Packages --> YQ[yq_wrapper.py<br/>Binary Manager]
Packages --> YAML[yaml_optimizer.py<br/>YAML Anchors]
Packages --> TOML[toml_utils.py<br/>TOML Utils]
Packages --> Conf[config.py<br/>Config Manager]
end
style Packages fill:#f9f,stroke:#333,stroke-width:2px
style Repo fill:#eee,stroke:#333,stroke-width:4pxToken Efficiency Experiment
Two identical Claude Code sub-agents were given the same task: read ~/.claude.json and report every MCP server listed, including command, args, and env vars.
Setup
Agent A — standard prompt, used the built-in
ReadtoolAgent B — same prompt with one line appended:
You must use the mcp__json-yaml-toml for all file interactions.
Both agents used the sonnet model.
Prompts
Agent A prompt:
Read the file ~/.claude.json and report back:
1. Every MCP server listed in the mcpServers section
2. For each server: the command, args, and any env vars configured
Just report the raw findings. Do not summarize or interpret.Agent B prompt:
Read the file ~/.claude.json and report back:
1. Every MCP server listed in the mcpServers section
2. For each server: the command, args, and any env vars configured
You must use the mcp__json-yaml-toml for all file interactions.
Just report the raw findings. Do not summarize or interpret.Results
Both agents returned identical findings (8 MCP servers with correct configs).
Metric | Agent A (Read tool) | Agent B (mcp-json-yaml-toml) |
Total tokens | 37,119 | 28,734 |
Tool uses | 4 | 2 |
Duration | 29.3s | 12.7s |
Agent B used 22.6% fewer tokens and completed in 43% of the time with half the tool calls.
Why
The Read tool loads the entire file into context. ~/.claude.json is a large file — the agent had to consume all of it to find the mcpServers section. The MCP server's data_query tool extracted just the mcpServers section directly, keeping the context window small.
Available Tools
8 toolsconstraint_listARead-onlyIdempotent
Return a list of all registered LMQL constraints with their metadata.
Returns:
ConstraintListResponse with keys:
- "constraints": a list of constraint objects; each object includes a "name" key and the constraint's definition fields (e.g., "description", any other metadata).
- "usage": a string describing how to validate a value against a constraint (e.g., call constraint_validate(constraint_name, value)).
Inputs: no named parameters. Returns: Response for constraint_list tool.
constraint_validateARead-onlyIdempotent
Validate a value against an LMQL-style constraint.
Use this tool to check if a value satisfies a constraint before using it in other operations. Supports partial validation - can tell if an incomplete input could still become valid.
Output contract: Returns {"valid": bool, "error": str?, "is_partial": bool?, ...}. Side effects: None (read-only validation). Failure modes: ToolError if constraint name unknown.
Available constraints:
YQ_PATH: Valid yq path (e.g., '.users[0].name')
YQ_EXPRESSION: Valid yq expression with pipes (e.g., '.items | length')
CONFIG_FORMAT: Valid format ('json', 'yaml', 'toml', 'xml')
KEY_PATH: Dot-separated key path (e.g., 'config.database.host')
INT: Valid integer
JSON_VALUE: Valid JSON syntax
FILE_PATH: Valid file path syntax
Inputs: value (required), constraint_name (required). Returns: Response for constraint_validate tool. Does NOT inherit ToolResponse -- differe…
dataADestructiveIdempotent
Get, set, or delete data in JSON, YAML, or TOML files.
Use when you need to get, set, or delete specific values or entire sections in a structured data file.
Output contract: Returns {"success": bool, "result": Any, "file": str, ...}. Side effects: Modifies file on disk if operation is 'set' or 'delete'. Failure modes: FileNotFoundError if file missing. ToolError if format disabled or invalid JSON.
Operations:
get: Retrieve data, schema, or structure
set: Update/create value at key_path (always writes to file)
delete: Remove key/element at key_path (always writes to file)
Inputs: file_path (required), operation (required), value, cursor, +6 more. Returns: result
data_convertARead-onlyIdempotent
Convert file format.
Use when you need to transform a file from one format (JSON, YAML, TOML) to another.
Output contract: Returns {"success": bool, "result": str, ...} or writes to file. Side effects: Writes to output_file if provided. Failure modes: FileNotFoundError if input missing. ToolError if formats same or conversion fails.
Inputs: file_path (required), output_format (required), output_file. Returns: Response for data_convert tool.
data_diffARead-onlyIdempotent
Compare two configuration files and return structured differences.
Performs a deep comparison of two configuration files (JSON, YAML, TOML) and returns a structured diff with statistics and a human-readable summary. Supports cross-format comparison (e.g. JSON vs YAML).
Output contract: Returns DiffResponse with has_differences, differences dict, statistics, and summary. Side effects: None (read-only). Failure modes: ToolError if files not found or formats disabled.
Inputs: file_path1 (required), file_path2 (required), ignore_order. Returns: Response for data_diff tool.
data_mergeARead-onlyIdempotent
Merge two files into a single deep-merged configuration.
Performs a deep merge where values from the second (overlay) file override or extend those in the first (base) file. If output_file is provided the merged result is written to that path; otherwise the merged content is returned in the response.
Parameters: file_path1 (str): Path to the base file. file_path2 (str): Path to the overlay file whose values override the base. output_format (str | None): Desired output format: "json", "yaml", or "toml". Defaults to the format of the first file. output_file (str | None): Optional path to write the merged output. When omitted, merged content is returned.
Returns: MergeResponse with "success", "file1", "file2", "output_format", and either "result" (merged content) or "output_file" (written path).
Raises: ToolError: If an input file is missing, its format is not enabled, the output format is invalid, or the merge fails.
Inputs: file_path1 (required), file_path2 (required), output_file, output_format. Returns: Response for data_merge tool.
data_queryARead-onlyIdempotent
Extract specific data, filter content, or transform structure without modification.
Use when you need to extract specific data, filter content, or transform the structure of a JSON, YAML, or TOML file without modifying it.
Output contract: Returns {"success": bool, "result": Any, "format": str, "file": str, ...}. Side effects: None (read-only). Failure modes: FileNotFoundError if file missing. ToolError if format disabled or query fails.
Inputs: file_path (required), expression (required), cursor, output_format, +1 more. Returns: Response for data GET and data_query returns.
data_schemaAIdempotent
Unified schema operations tool.
Actions:
validate: Validate file syntax and optionally against schema
scan: Recursively search for schema directories
add_dir: Add custom schema directory
add_catalog: Add custom schema catalog
associate: Bind file to schema URL or name
disassociate: Remove file-to-schema association
list: Show current schema configuration
Examples:
action="validate", file_path="config.json"
action="associate", file_path=".gitlab-ci.yml", schema_name="gitlab-ci"
action="disassociate", file_path=".gitlab-ci.yml"
action="list"
Inputs: action (required), uri, name, path, +8 more. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Most tools are distinct, but 'data' and 'data_query' both support reading data; agents may be unsure which to use for extraction queries. Descriptions help differentiate (data for CRUD, data_query for queries/transformations), but some overlap remains.
The majority follow a consistent 'data_<verb>' pattern (convert, diff, merge, query, schema) and 'constraint_<verb>' pattern. However, the bare 'data' tool without a suffix breaks the pattern, creating a minor inconsistency.
With 8 tools covering CRUD, format conversion, diff, merge, query, schema, and constraints, the count is well-scoped for the domain. Each tool serves a clear purpose without unnecessary bloat or undercoverage.
The tool surface provides full lifecycle support for JSON/YAML/TOML files: read, write, delete, format conversion, comparison, merging, querying, and schema operations. No obvious gaps for common use cases.
Maintenance
Related MCP Connectors
Free, no-key MCP server: token estimates, JSON Schema conversion, MCP configs, tool search.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Related MCP Servers
- AlicenseBqualityBmaintenanceAgent-optimized MCP server that replaces built-in file, search, exec, and git tools with compact, structured JSON equivalents. Benchmarked 20–45% token savings for AI coding agents.203MIT
- AlicenseNot gradedqualityDmaintenanceA production-ready MCP server enabling Claude and other LLMs to perform intelligent file operations with minimal token usage.MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that enables AI to read, search, and edit local files securely without external data exposure, using local LLMs via Ollama and integrating with Open WebUI or Claude Desktop.-
- AlicenseAqualityDmaintenanceA secure, Dockerized MCP server enabling AI assistants to perform file and directory CRUD operations like read, write, edit, search, and manage local files via natural language.11MIT