MCP server for querying and modifying JSON, YAML, and TOML files using yq
Project description
mcp-json-yaml-toml
A token-efficient, schema-aware MCP server for safely reading and modifying JSON, YAML, and TOML files
Getting Started • CLI Usage • Available Tools • Development
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.
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: Validate before writing; preserve comments and formatting.
- Multi-format: JSON, YAML, and TOML through a unified interface.
- Constraint validation: LMQL-powered validation for guided generation.
- Local-First: All processing happens locally. No data ever leaves your machine.
- Transparent JIT Assets: The server will auto-download the
yqbinary if missing. When an AI agent uses validation tools, the server automatically fetches and caches missing JSON schemas from SchemaStore.org.
[!NOTE]
JSONC Support: Files with
.jsoncextension (JSON with Comments) are fully supported for reading, querying, and schema validation. However, write operations will strip comments due to JSON 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-toml
Claude Code (CLI)
claude mcp add --scope user mcp-json-yaml-toml -- uvx mcp-json-yaml-toml
Other MCP Clients
Add this to your client's MCP configuration:
{
"mcpServers": {
"json-yaml-toml": {
"command": "uvx",
"args": ["mcp-json-yaml-toml"]
}
}
}
[!TIP] See docs/clients.md for detailed setup guides for Cursor, VS Code, and more.
LMQL & Guided Generation
This server provides native support for LMQL (Language Model Query Language) to enable "Guided Generation". This allows AI agents to validate their thoughts and proposed actions incrementally, ensuring that every path expression or configuration value they generate is syntactically correct before it's even executed.
- 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.
[!TIP] See the Deep Dive: LMQL Constraints for a full list of available constraints and detailed usage examples.
Available Tools
The server provides 7 core tools for data manipulation:
| Tool | Description |
|---|---|
data |
Get, set, or delete values at specific paths |
data_query |
Run advanced yq/jq expressions for transformations |
data_schema |
Validate files against JSON schemas (SchemaStore.org) |
data_convert |
Convert between JSON, YAML, and TOML formats |
data_merge |
Deep merge structured data files |
constraint_validate |
Validate inputs against LMQL constraints |
constraint_list |
List available generation constraints |
[!NOTE] Conversion TO TOML is currently not supported. See docs/tools.md for details.
Development
Setup
git clone https://github.com/bitflight-devops/mcp-json-yaml-toml.git
cd mcp-json-yaml-toml
uv sync
Testing
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=packages/mcp_json_yaml_toml
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:
# Recommended: Verify only touched files
uv run prek run --files <file edited>
[!IMPORTANT] Avoid
--all-filesduring 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_json_yaml_toml-0.6.0.tar.gz.
File metadata
- Download URL: mcp_json_yaml_toml-0.6.0.tar.gz
- Upload date:
- Size: 86.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74e8c1606f99ef2a9fbfe8575a21a476374c3daec09a9ce7e36558e52040dc92
|
|
| MD5 |
fbd95ce2aec440c322870c9ac89bd1ec
|
|
| BLAKE2b-256 |
1ebeb82eb0ede2718fbde4673eb0540e83eefb4292b72982277142ec790077eb
|
File details
Details for the file mcp_json_yaml_toml-0.6.0-py3-none-any.whl.
File metadata
- Download URL: mcp_json_yaml_toml-0.6.0-py3-none-any.whl
- Upload date:
- Size: 94.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36abfe9056a323af367ec328f31e2cf99962f88fca94739af943231660560554
|
|
| MD5 |
87d0e837844372c8ee453a6a9f4c6c0d
|
|
| BLAKE2b-256 |
29d629e1d4affdf7ffa3ba4579378c0176c05278fecf9f67976c8be615fe2427
|