excel-mcp

excel-mcp

Enables reading and writing Excel workbooks (.xlsx) through MCP. Supports listing sheets, tables, pivot tables, reading cell data, exporting to CSV/text/Markdown, and creating/modifying Excel files.

Category
访问服务器

README

excel-mcp

An MCP (Model Context Protocol) server for reading Excel workbooks (.xlsx). Built with FastMCP and openpyxl.

Features

  • List all sheets in a workbook
  • List all named tables across sheets
  • List all pivot tables with source range info
  • Read raw cell data from any sheet or optional cell range
  • Read structured data (headers + rows) from named Excel tables
  • Export any sheet to CSV, plain-text (delimited), or Markdown — save to file or return inline

Usage with Claude Desktop

No installation required. Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "excel-mcp": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/urjeetpatel/excel_mcp_server",
        "excel-mcp"
      ]
    }
  }
}

uvx will pull the package directly from GitHub and run it in an isolated environment — no pip install or virtual environment setup needed.

Running manually

uvx --from git+https://github.com/urjeetpatel/excel_mcp_server excel-mcp

Tools

All tools accept a file_path parameter — the full path to the .xlsx file.

Tool Description
list_sheets Returns the names of all sheets in the workbook
list_tables Returns all named tables with name, sheet, and cell range
list_pivot_tables Returns all pivot tables with location and source range info
get_sheet_data Returns cell data from a sheet; optionally scoped to a range (e.g. A1:D10)
get_table_data Returns headers and row data from a named Excel table
export_sheet_to_csv Exports a sheet to a CSV file with configurable delimiter; supports inline return
export_sheet_to_text Exports a sheet to a plain-text delimited file; supports inline return
export_sheet_to_markdown Exports a sheet to a padded Markdown table; supports inline return
create_blank_file Creates a new blank Excel file at the given path
add_sheet Adds a new sheet to an existing Excel file
add_data_to_sheet Adds a 2D array of data to a sheet, starting at a specified cell
add_table_to_sheet Adds a table to a sheet over a given cell range
set_cell_value Sets the value of a single cell in a sheet
set_cell_formula Sets a formula in a single cell in a sheet

Write tool details

create_blank_file(file_path)

Creates a new blank Excel file at the specified path.

add_sheet(file_path, sheet_name)

Adds a new sheet to the Excel file. Fails if the sheet already exists.

add_data_to_sheet(file_path, sheet_name, data, start_cell="A1")

Adds a 2D array of data to the specified sheet, starting at the given cell (default A1).

add_table_to_sheet(file_path, sheet_name, table_name, ref)

Adds a table to the specified sheet, covering the given cell range (e.g. "A1:D10").

set_cell_value(file_path, sheet_name, cell, value)

Sets the value of a single cell (e.g. C5) in the specified sheet.

set_cell_formula(file_path, sheet_name, cell, formula)

Sets a formula (e.g. "=SUM(A1:A10)") in a single cell in the specified sheet.

Tool details

list_sheets(file_path)

["Sheet1", "Sheet2"]

list_tables(file_path)

[{ "name": "SalesTable", "sheet": "Sheet1", "ref": "A1:D20" }]

list_pivot_tables(file_path)

[{
  "name": "PivotTable1",
  "sheet": "Summary",
  "ref": "A1:C10",
  "source_sheet": "RawData",
  "source_ref": "A1:F500"
}]

get_sheet_data(file_path, sheet_name, cell_range?)

{
  "sheet": "Sheet1",
  "range": "A1:D10",
  "rows": [["Name", "Age", "City"], ["Alice", 30, "New York"]]
}
  • cell_range is optional. When omitted, the full used range is returned.
  • Range strings are case-insensitive (a1:d10 == A1:D10).

get_table_data(file_path, table_name)

{
  "table": "PeopleTable",
  "sheet": "Sheet1",
  "ref": "A1:C4",
  "headers": ["Name", "Age", "City"],
  "rows": [["Alice", 30, "New York"], ["Bob", 25, "Chicago"]]
}

Export tools

All three export tools share a common pattern:

  • output_path — path to write the output file, or "return inline" to skip writing and return the content directly in the response.
  • cell_range — optional Excel range string (e.g. A1:D10). When omitted, the full used range is exported.

When saving to a file the response contains output_path. When returning inline, output_path is replaced by content.

export_sheet_to_csv(file_path, sheet_name, output_path, delimiter?, cell_range?)

Exports a sheet using Python's csv module (values containing the delimiter or newlines are properly quoted).

delimiter options: "comma" (default), "pipe", "tab".

{ "output_path": "/tmp/data.csv", "sheet": "Sheet1", "range": "A1:C4", "rows_written": 4 }

Inline variant (output_path = "return inline"):

{ "content": "Name,Age,City\r\nAlice,30,New York\r\n...", "sheet": "Sheet1", "range": "A1:C4", "rows_written": 4 }

export_sheet_to_text(file_path, sheet_name, output_path, delimiter?, cell_range?)

Exports a sheet as a plain delimited text file — values are joined with the delimiter with no CSV quoting, making output easy to read or pipe into other tools.

delimiter options: "pipe" (default), "comma", "tab".

{ "output_path": "/tmp/data.txt", "sheet": "Sheet1", "range": "A1:C4", "rows_written": 4 }

Inline variant:

{ "content": "Name|Age|City\nAlice|30|New York\n...", "sheet": "Sheet1", "range": "A1:C4", "rows_written": 4 }

export_sheet_to_markdown(file_path, sheet_name, output_path, cell_range?)

Exports a sheet as a padded Markdown table. The first row is used as the header; a separator line is inserted beneath it. All columns are padded to align.

{ "output_path": "/tmp/data.md", "sheet": "Sheet1", "range": "A1:C4", "rows_written": 4 }

Inline variant:

{ "content": "| Name  | Age | City     |\n| ----- | --- | -------- |\n| Alice | 30  | New York |\n...", "sheet": "Sheet1", "range": "A1:C4", "rows_written": 4 }

Local development

Requires Python >= 3.14 and uv.

git clone https://github.com/urjeetpatel/excel_mcp_server
cd excel_mcp_server
uv sync --group dev

# Run tests
uv run pytest

# Type check
uv run mypy src

Project Structure

src/excel_mcp/
├── __init__.py       # Exposes main() entry point
├── server.py         # FastMCP server and tool registration
├── workbook.py       # Workbook loading helpers
└── tools/
    ├── __init__.py
    ├── read.py       # Read tool implementations
    └── export.py     # Export tool implementations (CSV, text, Markdown)
tests/
├── conftest.py       # pytest fixtures (builds workbooks programmatically)
├── test_read.py      # Tests for read tools
├── test_export.py    # Tests for export tools
└── test_workbook.py  # Tests for workbook helpers

Notes

  • Workbooks are opened in data_only=True mode — formula results are read, not formula strings.
  • Export tools support "return inline" as output_path to return content directly to the agent without touching the filesystem.

License

GPL-3.0-or-later

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选