Spreadsheet MCP

MCP server for spreadsheet analysis and editing. Slim, token-efficient tool surface designed for LLM agents.
Why?
Dumping a 50,000-row spreadsheet into an LLM context is expensive and usually unnecessary. Most spreadsheet tasks need surgical access: find a region, profile its structure, read a filtered slice. This server exposes tools that let agents discover → profile → extract without burning tokens on cells they don't need.
- Full support:
.xlsx(viaumya-spreadsheet) - Discovery only:
.xls,.xlsb(enumerated, not parsed)
Architecture

- LRU cache keeps recently-accessed workbooks in memory (configurable capacity)
- Lazy sheet metrics computed once per sheet, reused across tools
- Region detection runs once and caches bounds for
sheet_overview,find_value,read_table,table_profile
Tool Surface
| Tool | Purpose |
|---|---|
list_workbooks, list_sheets |
Discover targets and get sheet summaries |
workbook_summary |
Region counts/kinds, named ranges, suggested entry points |
sheet_overview |
Detected regions (bounds/id/kind/confidence), narrative, key ranges |
find_value |
Value/label-mode lookup with region/table scoping, neighbors, row context |
read_table |
Structured read (range/region/table/named range), headers, filters, sampling |
table_profile |
Lightweight column profiling with samples and inferred types |
range_values |
Minimal range fetch for spot checks |
sheet_page |
Fallback pagination; supports compact/values_only |
formula_trace |
Precedents/dependents with paging |
Write & Recalc Support
Write tools allow "what-if" analysis: fork a workbook, edit cells, recalculate formulas via LibreOffice, and diff the results.
Enabling Write Tools
Always use the :full Docker image for write/recalc features:
The Docker image includes LibreOffice with pre-configured macros required for reliable recalculation. Running outside Docker requires manual LibreOffice setup (macro trust, headless config) and is not recommended.
Write Tools
| Tool | Purpose |
|---|---|
create_fork |
Create a temporary editable copy for "what-if" analysis |
edit_batch |
Apply values or formulas to cells in a fork |
recalculate |
Trigger LibreOffice to update formula results |
get_changeset |
Diff the fork against the original (cells, tables, named ranges) |
get_edits |
List all edits applied to a fork |
list_forks |
List all active forks |
save_fork |
Save fork to a new path (or overwrite original with --allow-overwrite) |
discard_fork |
Delete the temporary fork |
See docs/RECALC.md for architecture details.
Example
Request: Profile a detected region
Response:
The agent now knows column types, cardinality, and value distributions—without reading 1,247 rows.
Recommended Agent Workflow

list_workbooks→list_sheets→workbook_summaryfor orientationsheet_overviewto getdetected_regions(ids/bounds/kind/confidence)table_profile→read_tablewithregion_id, smalllimit, andsample_mode(distributedpreferred)- Use
find_value(label mode) orrange_valuesfor targeted pulls - Reserve
sheet_pagefor unknown layouts or calculator inspection; prefercompact/values_only - Keep payloads small; page/filter rather than full-sheet reads
Region Detection

Spreadsheets often contain multiple logical tables, parameter blocks, and output areas on a single sheet. The server detects these automatically:
- Gutter detection — Scans for empty rows/columns that separate content blocks
- Recursive splitting — Subdivides large areas along detected gutters
- Border trimming — Removes sparse edges to tighten bounds
- Header detection — Identifies header rows (including multi-row merged headers)
- Classification — Labels each region:
data,parameters,outputs,calculator,metadata - Confidence scoring — Higher scores for well-structured regions with clear headers
Regions are cached per sheet. Tools like read_table accept a region_id to scope reads without manually specifying ranges.
Quick Start
Docker (Recommended)
Two image variants are published:
| Image | Size | Write/Recalc |
|---|---|---|
ghcr.io/psu3d0/spreadsheet-mcp:latest |
~15MB | No |
ghcr.io/psu3d0/spreadsheet-mcp:full |
~800MB | Yes (includes LibreOffice) |
# Read-only (slim image)
# With write/recalc support (full image)
Cargo Install
# Read-only
Note: For write/recalc features, use the :full Docker image instead of cargo install. The Docker image includes LibreOffice with required macro configuration.
Build from Source
Default transport: HTTP streaming at 127.0.0.1:8079. Endpoint: POST /mcp.
Use --transport stdio for CLI pipelines.
MCP Client Configuration
Claude Code / Claude Desktop
Add to ~/.claude.json or project .mcp.json:
Read-only (slim image):
With write/recalc (full image):
Binary (no Docker):
Cursor / VS Code
Read-only (slim image):
With write/recalc (full image):
Binary (no Docker):
HTTP Mode
Connect via POST http://localhost:8079/mcp.
Local Development
To test local changes without rebuilding Docker:
Then point your MCP client to the binary:
Configuration
| Flag | Env | Description |
|---|---|---|
--workspace-root <DIR> |
SPREADSHEET_MCP_WORKSPACE |
Workspace root to scan (default: cwd) |
--cache-capacity <N> |
SPREADSHEET_MCP_CACHE_CAPACITY |
Workbook cache size (default: 5) |
--extensions <list> |
SPREADSHEET_MCP_EXTENSIONS |
Allowed extensions (default: xlsx,xls,xlsb) |
--workbook <FILE> |
SPREADSHEET_MCP_WORKBOOK |
Single-workbook mode |
--enabled-tools <list> |
SPREADSHEET_MCP_ENABLED_TOOLS |
Whitelist exposed tools |
--transport <http|stdio> |
SPREADSHEET_MCP_TRANSPORT |
Transport selection (default: http) |
--http-bind <ADDR> |
SPREADSHEET_MCP_HTTP_BIND |
Bind address (default: 127.0.0.1:8079) |
--recalc-enabled |
SPREADSHEET_MCP_RECALC_ENABLED |
Enable write/recalc tools (default: false) |
--max-concurrent-recalcs <N> |
SPREADSHEET_MCP_MAX_CONCURRENT_RECALCS |
Parallel recalc limit (default: 2) |
--allow-overwrite |
SPREADSHEET_MCP_ALLOW_OVERWRITE |
Allow save_fork to overwrite original files (default: false) |
Performance
- LRU workbook cache — Recently opened workbooks stay in memory; oldest evicted when capacity exceeded
- Lazy metrics — Sheet metrics computed on first access, cached for subsequent calls
- Region caching — Detection runs once per sheet;
region_idlookups are O(1) - Sampling modes —
distributedsampling reads evenly across rows without loading everything - Compact formats —
values_onlyandcompactoutput modes reduce response size
Testing
Covers: region detection, region-scoped tools, read_table edge cases (merged headers, filters, large sheets), workbook summary.
Local MCP Testing
To test local changes with an MCP client (Claude Code, Cursor, etc.), use the helper script that rebuilds the Docker image on each invocation:
Set WORKSPACE_ROOT to override the default test directory:
WORKSPACE_ROOT=/path/to/workbooks
This ensures you're always testing against your latest code changes without manual image rebuilds.
Behavior & Limits
- Read-only by default; write/recalc features require
--recalc-enabledor the:fullimage - XLSX supported for write;
.xls/.xlsbare read-only - Bounded in-memory cache honors
cache_capacity - Prefer region-scoped reads and sampling for token/latency efficiency