Skip to main content

MCP server for querying and modifying JSON, YAML, and TOML configuration files using yq

Project description

mcp-json-yaml-toml

Test Publish PyPI version Python 3.11+

Smart JSON/YAML/TOML tools for MCP agents.

Safely query, modify, validate, and convert JSON, YAML, and TOML files while preserving comments, formatting, and structure. Perfect for working with configuration files, API responses, manifests, and any structured data across multiple formats.


What You Get

This MCP server gives AI agents intelligent tools for configuration management:

  • Multi-format support: Seamlessly work with JSON, YAML, and TOML files using a unified interface
  • Powerful querying: Use yq's jq-compatible expressions to extract and analyze nested data
  • Safe modifications: Validate changes before writing; preserve comments and formatting
  • Format conversion: Automatically convert between JSON, YAML, and TOML with zero data loss
  • Config merging: Intelligently merge base configs with environment-specific overrides
  • Schema validation: Leverage SchemaStore.org catalogs or custom schemas for validation
  • YAML optimization: Automatically generate anchors/aliases for duplicate structures to maintain DRY
  • Cross-platform: Works on Linux, macOS, and Windows with bundled yq binaries

Why It Matters

Configuration management is error-prone when done manually:

  • Editing YAML indentation mistakes break deployments
  • Format conversions introduce subtle bugs
  • Duplicate config sections violate DRY principles
  • Manual schema validation catches problems only in production

With mcp-json-yaml-toml, your AI assistant can:

  • Safely validate and modify configs before pushing to infrastructure
  • Convert legacy configs to modern formats without losing data
  • Detect and fix common configuration problems
  • Ensure consistency across deployment environments

Quick Start

Prerequisites

  • Python 3.11 or higher
  • An MCP client (Claude Desktop, Cursor, VS Code, etc.)

Installation

MCP servers run as external processes and are not installed as libraries. They communicate via stdio with your MCP client.

Claude Code (CLI)

# Basic install
claude mcp add --scope user mcp-json-yaml-toml -- uvx mcp-json-yaml-toml

# With environment variables (e.g., to limit formats)
claude mcp add --scope user mcp-json-yaml-toml -e MCP_CONFIG_FORMATS=json,yaml -- uvx mcp-json-yaml-toml

Updating

When using uvx, clear the cache to get the latest version:

uv cache clean mcp-json-yaml-toml

The next time the MCP server runs, uvx will download the latest version.

Claude Desktop Configuration

  1. Open your Claude Desktop configuration file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Add the server to your mcpServers section:

{
  "mcpServers": {
    "json-yaml-toml": {
      "command": "uvx",
      "args": ["mcp-json-yaml-toml"]
    }
  }
}

This configuration uses uvx to automatically download and run the server in an isolated environment.

  1. Restart Claude Desktop to activate the server.

Try It Now

Here are real examples you can use with Claude Desktop:

Query Configuration Files

  • "What stages are defined in my GitLab CI?" - Returns: build, test, deploy, etc.
  • "Show me the project name from pyproject.toml" - Extracts: mcp-json-yaml-toml
  • "Get all dependencies from package.json" - Lists npm packages with versions

Convert Between Formats

  • "Convert this config.toml to YAML" - Preserves all data in new format
  • "Convert this config.toml to JSON" - Export TOML to JSON format
  • "Convert GitLab CI YAML to JSON for API use" - Enables programmatic access

Note: Conversion to TOML format from JSON/YAML is not supported due to yq limitations. See docs/tools.md for the full conversion matrix.

Validate and Fix

  • "Check if my YAML file is valid" - Validates syntax before deployment
  • "Validate against schema from SchemaStore" - Ensures compliance with specs
  • "Fix YAML indentation issues" - Corrects formatting problems

Advanced Operations

  • "Extract all job names from .gitlab-ci.yml" - Query: .* | select(type == "object") | keys
  • "Merge base config with production overrides" - Deep merges configurations
  • "Show config structure without values" - Returns keys only for overview

Available Tools

The server provides 5 tools: data, data_query, data_schema, data_convert, and data_merge.

See docs/tools.md for parameters, examples, and usage reference.


Configuration

See docs/tools.md for environment variables and configuration options.


Development

Setup

# Clone repository
git clone https://github.com/bitflight-devops/mcp-json-yaml-toml.git
cd mcp-json-yaml-toml

# Install with development dependencies
uv pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

Running Tests

# Run all tests with coverage
uv run pytest

# Run specific test file
uv run pytest packages/mcp_json_yaml_toml/tests/test_server.py

# Run with verbose output
uv run pytest -v

Code Quality

# Format code
uv run ruff format

# Lint code
uv run ruff check --fix

# Type check
uv run mypy packages/

# Run all checks
uv run pre-commit run --all-files

Project Structure

mcp-json-yaml-toml/
├── packages/mcp_json_yaml_toml/  # Main package
│   ├── server.py                 # MCP server implementation
│   ├── yq_wrapper.py             # yq binary wrapper
│   ├── schemas.py                # JSON Schema management
│   ├── yaml_optimizer.py         # YAML anchor/alias optimization
│   ├── toml_utils.py             # TOML file operations
│   ├── config.py                 # Configuration management
│   └── tests/                    # Test suite
├── docs/                         # Documentation
│   ├── tools.md                  # Tool reference
│   ├── clients.md                # Client setup guides
│   ├── module-usage.md           # Module dependencies
│   └── yq-wrapper.md             # yq wrapper usage
├── scripts/                      # Utility scripts
├── fixtures/                     # Test fixtures
├── pyproject.toml                # Project configuration
└── README.md                     # This file

Requirements

  • Python 3.11 or higher
  • Bundled yq binaries (no external installation required)

License

MIT License - see LICENSE file for details


Contributing

Contributions are welcome! Please ensure all tests pass and code quality checks succeed before submitting a pull request.

Acknowledgments

  • Built with FastMCP
  • Uses yq for configuration file processing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_json_yaml_toml-0.1.0.tar.gz (59.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_json_yaml_toml-0.1.0-py3-none-any.whl (66.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_json_yaml_toml-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_json_yaml_toml-0.1.0.tar.gz
  • Upload date:
  • Size: 59.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"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

Hashes for mcp_json_yaml_toml-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe74c0b40502df0c177d69d652bd61d9d5eb77ebb0817f2aabfed4e92893d23e
MD5 8a8c58d0bde3a6ba04722c540a085157
BLAKE2b-256 317d03bd93b40bc8ace9eb3aaff87a20036e091008da81243cb3b4be2d4a3a9e

See more details on using hashes here.

File details

Details for the file mcp_json_yaml_toml-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_json_yaml_toml-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 66.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"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

Hashes for mcp_json_yaml_toml-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02805f84d5a892266a90a3cccb11b41d9992e434a96af1947a6a7da02f600f8e
MD5 90934ced79d25ab187cab600c2ee50a9
BLAKE2b-256 4503184d6f3f9ca5e19ea9fcb51d5a4a00ac9c98ca4c83870ee2fc7e2afff9cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page