Skip to main content
Glama
sheets-mcp

sheets-mcp

Want Claude, Cursor or any MCP agent to answer questions about your spreadsheets without uploading them or risking edits? Start here. sheets-mcp loads local CSV and XLSX files into an in-memory SQLite database and gives the agent three read-only tools: list, describe, query.

sheets-mcp

Read-only SQL over local CSV and XLSX files for AI agents. One small MCP server, zero required dependencies.

CI License: MIT Python 3.10+

Real output: a CSV (orders) joined with a sheet from an XLSX workbook (catalog_products). The prompt line is shortened; the full query is in Quick start.


Why

Agents are good at SQL and bad at reading 10,000 spreadsheet rows pasted into a chat. Pointing them at a real database means credentials and write access. sheets-mcp sits in between: your files stay on your machine, get loaded into a throwaway in-memory database on start, and the agent can only run SELECT.

Related MCP server: csvql

Features

  • πŸ“‚ Point at files or folders: .csv, .tsv, .txt, .xlsx, .xlsm; each CSV becomes a table, each XLSX sheet becomes workbook_sheet

  • πŸ”’ Read-only by construction: in-memory copy, SQLite authorizer allows only SELECT/read/function actions, one statement per call, row cap and time limit

  • 🧠 Agent-friendly schema: snake_case column names (original names kept), inferred INTEGER/REAL/TEXT types, leading-zero codes kept as text

  • πŸ” describe_table returns nulls, distinct counts, min/max and sample rows, so the agent writes the right query first time

  • 🧾 Messy CSV tolerant: delimiter sniffing (, ; tab |), UTF-8 with BOM or cp1252, ragged rows, duplicate or empty headers

  • πŸ–₯️ CLI too: tables and query commands to see exactly what the agent sees

  • πŸͺΆ No required dependencies (openpyxl only for XLSX); MCP stdio protocol implemented in ~100 lines

Quick start

pip install "sheets-mcp[xlsx] @ git+https://github.com/purkat0301-sys/sheets-mcp"
sheets-mcp tables ./my-data
sheets-mcp query ./my-data --sql "SELECT p.category, COUNT(*) AS orders, SUM(o.qty) AS units, ROUND(SUM(o.qty * o.unit_price), 2) AS revenue FROM orders o JOIN catalog_products p USING (sku) GROUP BY 1 ORDER BY revenue DESC"

Then add it to your MCP client (Claude Desktop, Cursor, VS Code, ...), as in examples/mcp.json:

{ "mcpServers": { "sheets": { "command": "sheets-mcp", "args": ["/path/to/my-data"] } } }

The server answers the standard MCP handshake. Checked with mcp-preflight in CI:

How it works

flowchart LR
    F[CSV / XLSX files] -->|sniff, decode, infer types| DB[(in-memory SQLite)]
    A[AI agent] -->|tools/call| S[sheets-mcp]
    S --> T1[list_tables]
    S --> T2[describe_table]
    S --> T3[query]
    T3 -->|authorizer: SELECT only<br/>row cap, timeout| DB
    DB --> S --> A

Tool

Input

Returns

list_tables

none

table names, source file / sheet, row counts, columns

describe_table

table, sample_rows

column types, nulls, distinct, min, max, sample rows

query

sql, limit

columns, rows, row_count, truncated

Anything other than a read is refused:

Compared with the inspiration

The idea comes from the reference SQLite MCP server (now archived), which works on a SQLite database file. sheets-mcp is a new implementation focused on spreadsheets and safety.

sheets-mcp

Reference SQLite server

Works directly on CSV / XLSX

βœ…

❌ needs a .db file

Read queries

βœ… query

βœ… read_query

Write / create table tools

❌ by design

βœ… write_query, create_table

Enforcement

SQLite authorizer + in-memory copy

see project

Column stats in describe

βœ…

see project

Row cap and query timeout

βœ…

see project

Required runtime dependencies

none (openpyxl for XLSX)

mcp SDK

Maintained

βœ…

archived

FAQ

Does it change my files? No. Files are read once at start into memory; nothing is written back.

Do edits to the files show up? Restart the server (your MCP client usually has a restart button). Live reload is on the roadmap.

How big can files be? Everything is held in memory. Tens of MB load in seconds; for multi-GB data use a real database.

Dates? XLSX dates become ISO text (2026-09-01), so date(), strftime() and string comparison work.

Limitations

  • Type inference is per column and simple (integer, real, text); dates are stored as text.

  • Formulas in XLSX are read as their cached values (data_only); a file never opened in Excel may have empty formula cells.

  • Not on PyPI yet; install from GitHub.

Roadmap

See ROADMAP.md: file watching and reload, Parquet/JSON, --table renames, per-column date detection.

By the same author: mcp-preflight (check MCP configs and probe servers) Β· csv-rescue (repair broken CSV exports) Β· pdf-tables-mcp (invoice PDFs to data for agents)

Contributing

Issues and pull requests are welcome. pip install -e '.[dev]' && pytest. Security-relevant changes (anything touching the authorizer) need a test in test_writes_and_tricks_are_rejected.

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Lets AI agents query local SQLite database files read-only using Node's built-in sqlite module, providing tools for listing tables, describing schemas, and running SQL queries.
      3
      7 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to run SQL analytics directly on CSV files in place via MCP, avoiding imports and token-heavy data pasting. It provides read-only querying, schema inspection, and file listing while keeping data local.
      32
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to inspect database schemas and run strictly read-only SQL queries with guardrails against destructive statements, multi-statement chaining, and unbounded scans. Supports SQLite natively and PostgreSQL optionally.
      4
      30 PyPI
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to explore and query SQLite databases through read-only, sandboxed tools for listing tables, describing schemas, fetching DDL, and running a single capped SELECT statement. Also supports plain-English questions that are converted to SQL and routed through the same sandbox.
      4
      MIT