Skip to main content
Glama
sheet2json-mcp

sheet2json-mcp

by tony-allex

sheet2json-mcp

An MCP server that lets an AI agent turn messy spreadsheets into clean, validated JSON, on rails.

A lot of engineering and operations data still lives in hand-maintained Excel and CSV files: bills of materials, sensor logs, order lists. Asking an LLM to "just convert it" works until it quietly guesses a value, drops a row or invents a column. This server keeps the AI useful but constrained: the agent decides which file and which schema; deterministic Python code does the conversion and reports every problem.

"Convert pcb_bom_rev_b.xlsx to JSON"
        │
        ▼
  AI agent ──(MCP)──► list_files → inspect_file → convert_file
                                                  │
                     fixed JSON Schemas ──────────┤
                                                  ▼
                       valid records + row-level error report
                       (JSON file written only if every row is valid)

The rails

Guard rail

Why

Files can only be read from one data folder (path traversal is blocked)

The agent can't wander the file system

Only predefined JSON Schemas can be targeted

Output shape is always the same; the agent can't invent fields

Every rejected value is reported with row, field, value and reason

Nothing is dropped or "fixed" silently

Ambiguous numbers such as 3,3 with . as decimal separator are rejected

No silent 3.3 → 33 mistakes

Duplicate keys (e.g. the same designator twice) are flagged

Catches copy-paste errors in BOMs

Output is written only when all rows are valid

Partial data never reaches downstream systems

Tool responses return a preview (20 records, 50 errors)

Keeps the agent's context small; full data goes to the file

A skill file tells the agent the exact workflow and how to report

Consistent behaviour across conversations

Related MCP server: dvq

What it handles

  • .xlsx, .xlsm (any sheet) and .csv (auto-detects , ; tab | delimiters, UTF-8 or Windows-1252)

  • Messy headers: Part No., MPN and part_number all map to the same field, using aliases defined in the schema

  • Danish formats: decimal comma (72,5), dd-mm-yyyy dates, Danish column names (Værdi, Enhed, Antal)

  • Type conversion to integer, number, boolean, enum (case-insensitive, returned in canonical form), date and date-time

Tools

Tool

What it does

list_schemas

Lists the target schemas, their fields and which are required

list_files

Lists CSV/Excel files in the data folder

inspect_file

Shows sheets, headers, sample rows and which schema fits best

convert_file

Converts and validates; optionally writes the JSON when there are no errors

Included schemas

  • bom: PCB bill of materials (designators, part number, manufacturer, quantity, unit price…)

  • sensor_readings: time-stamped temperature / pressure / flow / humidity readings, e.g. from a district heating substation

Adding a schema means dropping a *.schema.json file (standard JSON Schema 2020-12) into the schema folder. Two extra keys are supported: x-aliases on a property (alternative column names) and x-unique-key on the schema (fields that must be unique per row).

Example

examples/data/pcb_bom_rev_b.xlsx has inconsistent headers and three bad rows. Result of convert_file(path="pcb_bom_rev_b.xlsx", schema="bom") (shortened):

{
  "rows_read": 6, "valid_rows": 3, "invalid_rows": 3,
  "column_mapping": { "designators": "Ref Des", "part_number": "Part No.", "quantity": "Qty", "...": "..." },
  "unmapped_columns": ["Notes"],
  "errors": [
    { "row": 5, "field": "quantity", "value": "one", "message": "'one' is not a number" },
    { "row": 6, "field": "part_number", "message": "'part_number' is a required property" },
    { "row": 7, "field": "designators", "message": "Duplicate of row 3 ({'designators': 'C1'})" }
  ],
  "records_preview": [ { "designators": "R1, R2, R5", "part_number": "RC0603FR-0710KL", "quantity": 3, "unit_price_dkk": 0.12, "...": "..." } ]
}

Install

Requires Python 3.10+.

git clone https://github.com/<tony-allex>/sheet2json-mcp.git
cd sheet2json-mcp
pip install -e ".[dev]"
pytest            # 17 tests, including end-to-end tests through a real MCP client

Use with Claude Code

claude mcp add sheet2json \
  --env SHEET2JSON_DATA_DIR=/path/to/your/spreadsheets \
  --env SHEET2JSON_OUTPUT_DIR=/path/to/output \
  -- sheet2json-mcp

Copy skills/sheet2json/ into your skills folder (e.g. .claude/skills/) so the agent follows the workflow.

Use with Claude Desktop (or any MCP client)

{
  "mcpServers": {
    "sheet2json": {
      "command": "sheet2json-mcp",
      "env": {
        "SHEET2JSON_DATA_DIR": "/path/to/your/spreadsheets",
        "SHEET2JSON_OUTPUT_DIR": "/path/to/output"
      }
    }
  }
}

Environment variable

Default

Meaning

SHEET2JSON_DATA_DIR

./data

The only folder files can be read from

SHEET2JSON_OUTPUT_DIR

./output

Where validated JSON is written

SHEET2JSON_SCHEMA_DIR

built-in schemas/

Folder with *.schema.json files

Try it on the examples by pointing SHEET2JSON_DATA_DIR at examples/data (regenerate them with python examples/make_examples.py).

Project layout

src/sheet2json/core.py      conversion logic (no MCP dependency, easy to test and reuse)
src/sheet2json/server.py    MCP tools: a thin layer over core.py
src/sheet2json/schemas/     JSON Schemas (the "rails")
skills/sheet2json/SKILL.md  instructions for the AI agent
tests/                      unit tests + end-to-end MCP tests

Ideas for next steps

  • A write_to_database tool (e.g. MongoDB or Azure Cosmos DB) behind the same validation

  • Deploy over streamable HTTP in a container (Azure Container Apps) so a team can share one server

  • A schema for component data that checks part numbers against a supplier API

Available Tools

4 tools
convert_fileA

Convert a spreadsheet into JSON records that match one of the predefined schemas.

Every row is either converted and validated, or listed in errors with its row number and reason. Rows are never silently dropped or corrected.

Args: path: File path relative to the data folder. schema: Name of the target schema (see list_schemas). sheet: Excel sheet name. Defaults to the first sheet. decimal_separator: "." (1,234.5) or "," (1.234,5 - common in Danish files). write_output: Save the result as JSON in the output folder. Only allowed when there are no errors, so partial data never ends up downstream.

Inputs: path (required), schema (required), sheet, write_output, +1 more. Returns: object

inspect_fileA
Read-only

Show the sheets, column headers and first rows of a file, and which schemas fit it best.

Args: path: File path relative to the data folder, as returned by list_files. sheet: Excel sheet name. Defaults to the first sheet. Ignored for CSV. sample_rows: Number of example rows to return (1-20).

Inputs: path (required), sheet, sample_rows. Returns: object

list_filesA
Read-only

List the CSV and Excel files available in the data folder.

Inputs: no named parameters. Returns: object

list_schemasA
Read-only

List the target schemas data can be converted into, with their fields and which are required.

Inputs: no named parameters. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool maps to a distinct step in the workflow: listing schemas, listing files, inspecting a file, and converting. There is no overlap in purpose, and the natural pipeline order makes selection unambiguous.

    Naming Consistency5/5

    All four tools follow a consistent snake_case verb_noun pattern (list_schemas, list_files, inspect_file, convert_file). The convention is predictable and easy to reason about.

    Tool Count4/5

    Four tools is a tight, focused surface that matches the bounded spreadsheet-to-JSON scope. It sits at the minimal end, with arguably room for a small output-retrieval tool, but nothing feels padded.

    Completeness4/5

    The core discover-inspect-convert lifecycle is fully covered, including validation and error reporting. The main gap is that converted output written via write_output cannot be listed or read back with any provided tool, leaving a minor dead end.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables LLMs to automatically generate Excel files with custom structures, advanced formatting, multiple sheets, formulas, and charts from JSON schemas, with support for both local and remote deployment.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes data validation as tools so an AI agent can check whether data is actually correct before using it, scoring CSV files with per-row problem details, catching impossible dates, inferring schemas, and generating readable reports.
      13 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Every live trading feed is a table: today it serves your CSV, Parquet and JSON files to AI agents as SQL tables (Apache DataFusion), with joins across files, schema and column statistics.
      1
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to deterministically profile, clean, normalize, and validate tabular data, including locale-aware numbers, dates, text encoding, IDs, and CSV/XLSX/JSON inputs, while flagging ambiguous values instead of guessing.
      6
      33 PyPI
      Business Source 1.1