excel-mcp-server

excel-mcp-server

An MCP server that lets LLMs explore Excel workbooks by reading cells, ranges, and evaluating formulas with live computed values via HyperFormula.

Category
访问服务器

README

excel-mcp-server

Local Model Context Protocol (MCP) server that lets LLMs explore Excel workbooks. It combines:

  • ExcelJS — parses .xlsx / .xlsm files (values, formulas, rich text, hyperlinks, dates).
  • HyperFormula — an in-memory spreadsheet engine that re-evaluates every formula, so tools return the computed result rather than the value cached in the file.

The server speaks MCP over stdio, so it works with any MCP-compatible client: VS Code, Claude Desktop, Cursor, and custom agents.

License: GPL-3.0-or-later. HyperFormula is dual-licensed (GPL-3.0 or commercial); see NOTICE for details.


Intended use

This repository is a personal, educational proof-of-concept. Please read this section before reusing the code.

Do not:

  • Bundle this project inside a commercial software product.
  • Deploy this project as part of a paid SaaS offering.
  • Redistribute this project (or its binaries) under any license other than GPL-3.0-or-later.
  • Use this project as a substitute for a properly licensed HyperFormula commercial integration.

Why the caveat? HyperFormula (see the Credits section below) is dual-licensed. This project uses the open-source GPL-3.0 tier by passing licenseKey: 'gpl-v3' at engine construction. If you plan to embed HyperFormula in commercial or closed-source software, you must obtain a commercial license directly from Handsontable and use your commercial license key. Doing so is a requirement of HyperFormula's dual-licensing model, not a limitation of this repository.

Everything else in this repository (ExcelJS, MCP SDK, Zod, TypeScript, etc.) is MIT / Apache-2.0 licensed and free to reuse under those terms.

If your use case is purely personal exploration, learning, or open-source contribution back to a GPL-3.0-or-later project, you are welcome to use, fork, and modify this code freely.


How this was built

This repository was scaffolded and iterated on with the help of an AI coding assistant (Anthropic's Claude, via GitHub Copilot's agent mode in VS Code). The design decisions, dependency choices, licensing posture, and architectural trade-offs were driven by the author; the assistant contributed code generation, test scaffolding, and documentation drafting under human review. All committed code has been read and vetted by a human before landing.


Features

The server exposes 10 read-only tools that cover the common "explore this spreadsheet" workflow:

Tool Purpose
open_workbook Load a local .xlsx/.xlsm file and get back a workbookId.
list_workbooks List all workbooks currently loaded in the session.
list_sheets Enumerate sheets with row/column counts.
get_sheet_summary Dimensions, header row heuristic, per-column type inference, sample.
read_range Read a rectangular A1 range with computed values and optional formulas.
get_cell Value + formula + cell type + number format for a single cell.
evaluate_formula Evaluate an arbitrary Excel formula against the loaded workbook.
find_in_workbook Substring / regex search across all sheets (values and formulas).
get_workbook_stats Aggregate counts (non-empty, formulas, errors) per sheet and overall.
close_workbook Release memory held by a workbook.

Highlights:

  • Formulas are re-evaluated by HyperFormula — you always see the live computed value, never a stale cached one.
  • Handles cross-sheet references (=SUM(Data!C2:C5)), named expressions defined in the file, and standard Excel error types (#DIV/0!, #N/A, …).
  • Safe by default: read-only, size- and cell-count-capped, and an optional allow-list restricts which directories can be opened.
  • No writes, no network calls, no telemetry.

Install & run

Prerequisites: Node.js ≥ 18.17 (Node 20+ recommended).

git clone https://github.com/manil2020/excel_mcp_server.git
cd excel_mcp_server
npm install
npm run build
npm test        # runs the vitest suite

# Start the server on stdio (this is what MCP clients do automatically)
node dist/index.js

For local development without a build step:

npm run dev

Wiring the server into MCP clients

VS Code (GitHub Copilot Chat MCP)

Add the server to your workspace or user MCP config. A minimal .vscode/mcp.json:

{
  "servers": {
    "excel": {
      "command": "node",
      "args": ["/absolute/path/to/excel_mcp_server/dist/index.js"],
      "env": {
        "EXCEL_MCP_LOG_LEVEL": "info"
      }
    }
  }
}

See examples/vscode-mcp.json for a ready-to-copy version.

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or the equivalent on Windows / Linux:

{
  "mcpServers": {
    "excel": {
      "command": "node",
      "args": ["/absolute/path/to/excel_mcp_server/dist/index.js"]
    }
  }
}

See examples/claude-desktop-config.json.

Any other MCP client

Point the client at node /absolute/path/to/dist/index.js with the environment variables described below. The server uses stdio, the standard MCP local transport.


Configuration

All configuration is via environment variables. Defaults are safe for a laptop workload.

Variable Default Description
EXCEL_MCP_MAX_FILE_MB 100 Reject workbooks larger than this many megabytes.
EXCEL_MCP_MAX_WORKBOOKS 8 Maximum number of workbooks kept in memory concurrently.
EXCEL_MCP_ALLOWED_ROOTS (unset) Colon-separated absolute paths. If set, only files under one of these roots may be opened.
EXCEL_MCP_LOG_LEVEL info debug / info / warn / error. Logs go to stderr as JSON lines.

Example workflow (LLM-side)

open_workbook(path="/data/orders.xlsx")
→ { workbookId: "wb_a1b2c3d4", sheets: [ ... ] }

get_sheet_summary(workbookId, sheet="Orders")
→ headers: ["order_id", "customer", "amount", "region"], columnTypes: [ ... ]

find_in_workbook(workbookId, query="EMEA")
→ hits: [ { sheet: "Orders", cell: "D42", value: "EMEA" }, ... ]

evaluate_formula(workbookId, formula="=SUMIFS(Orders!C:C, Orders!D:D, \"EMEA\")")
→ { result: 12345.67 }

close_workbook(workbookId)

Architecture

  • src/index.ts – Bin entry: creates the server and connects a StdioServerTransport.
  • src/server.ts – Constructs McpServer, wires all tools, exports createServer() for tests.
  • src/workbook/loader.ts – Reads the file with ExcelJS, converts each cell into HyperFormula-friendly primitives (formulas kept as =… strings, dates converted to Excel serial numbers, rich text flattened), then calls HyperFormula.buildFromSheets.
  • src/workbook/manager.ts – Registry of open workbooks keyed by opaque wb_* handles, with per-process limits and graceful shutdown.
  • src/tools/*.ts – One file per MCP tool. Each registers itself with the shared McpServer and delegates to the workbook manager.

See docs/ARCHITECTURE.md for a diagram and the full data flow.


Development

npm run dev          # tsx watch (single run)
npm run typecheck    # tsc --noEmit
npm run lint         # eslint
npm run format       # prettier --write
npm test             # vitest run
npm run test:watch   # vitest watch

Directory layout:

excel_mcp_server/
├── src/
│   ├── index.ts              # #!/usr/bin/env node entry
│   ├── server.ts             # MCP server factory
│   ├── workbook/             # ExcelJS + HyperFormula bridge
│   ├── tools/                # One file per MCP tool
│   └── util/                 # Address helpers, errors, logger, path safety
├── tests/
│   ├── fixtures/             # Programmatic xlsx generation
│   ├── loader.test.ts        # Workbook layer
│   └── tools.test.ts         # Full MCP round-trip (in-memory transport)
├── docs/
│   ├── ARCHITECTURE.md
│   └── USAGE.md
├── examples/
│   ├── vscode-mcp.json
│   └── claude-desktop-config.json
├── LICENSE                   # GPL-3.0
└── NOTICE                    # Third-party licensing

Licensing summary

This project uses HyperFormula, which is dual-licensed under GPL-3.0 or a commercial license from Handsontable. Because this project links against HyperFormula, the combined work is distributed as GPL-3.0-or-later. See NOTICE for full detail and instructions for commercial reuse.

The other runtime dependencies (ExcelJS, @modelcontextprotocol/sdk, zod) are MIT-licensed and compatible with GPL-3.0.


Credits & acknowledgements

This project would not exist without the following open-source libraries and the maintainers who built them. If you find this project useful, please star and support the upstream projects — they did the hard work.

Runtime dependencies

Project Maintainer(s) License Homepage
HyperFormula Handsontable Sp. z o.o. (Poland) GPL-3.0 / Commercial hyperformula.handsontable.com · source
ExcelJS Guyon Roche and contributors MIT github.com/exceljs/exceljs
@modelcontextprotocol/sdk Anthropic PBC and the MCP community MIT github.com/modelcontextprotocol/typescript-sdk
zod Colin McDonnell (@colinhacks) and contributors MIT zod.dev

Development dependencies

Project Maintainer(s) License
TypeScript Microsoft Apache-2.0
Vitest Anthony Fu (@antfu) and contributors MIT
tsx Hiroki Osame (@privatenumber) MIT
ESLint OpenJS Foundation / ESLint team MIT
Prettier Prettier team MIT
Node.js OpenJS Foundation MIT

Protocol

The Model Context Protocol specification is developed and stewarded by Anthropic and the wider MCP community at modelcontextprotocol.io. The protocol design work makes servers like this one possible.

Sample data

  • The samples/financial-sample.xlsx fixture (used for local testing only, gitignored) is Microsoft's public Power BI Financial Sample workbook, freely distributed by Microsoft for learning purposes: download link.
  • All other files in samples/ are synthesised locally by scripts/generate-samples.ts and contain no real personal or commercial data.

If any maintainer name or attribution detail here is missing or wrong, please open an issue — corrections are welcome and I want the credit right.


Roadmap

  • Optional write tools (set_cell, save_workbook) behind an opt-in --allow-writes flag.
  • Streaming for very large ranges via read_range pagination.
  • CSV / .xls legacy format support.
  • Prompt / resource providers exposing the workbook as MCP Resources.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选