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.6.tar.gz (61.2 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.6-py3-none-any.whl (67.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

Hashes for mcp_json_yaml_toml-0.1.6.tar.gz
Algorithm Hash digest
SHA256 f98994280ca3457ef20f8bd945ae70150709046cf482d75ca81d7a21c08c6820
MD5 34ebe3966a4fc506787c9210ee63a551
BLAKE2b-256 9bbb280a5ff73e302b22e7bd23cc4e579c75e3acad0ba590521f5c51cd658820

See more details on using hashes here.

File details

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

File metadata

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

Hashes for mcp_json_yaml_toml-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 810908645e19ab64b46351feb91f416626574b4ca7fba414a638490a73c10b96
MD5 21e79351c87080b893f45e713d6bc376
BLAKE2b-256 48e92c21c0450e1e7881f55a3976ecfd53473032ab5254be1dba3da156b691f7

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