mcp-xlsx-server
Integrates with GitHub Copilot to allow reading and writing Excel files, including listing sheets, reading data in JSON or array format, creating files, adding sheets, and updating cells.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-xlsx-server list sheets in monthly_report.xlsx"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-xlsx-server
基于 SheetJS (xlsx) 的 Excel 文件读写 MCP 服务。
功能
提供 5 个 MCP 工具:
工具 | 功能 |
| 列出 xlsx 文件中所有 sheet 名称和行列数 |
| 读取指定 sheet 数据,支持 JSON/二维数组格式和范围选择 |
| 从 JSON 数据创建新的 xlsx 文件 |
| 向已有 xlsx 文件添加新 sheet |
| 更新指定单元格值 |
Related MCP server: MCP Excel Server
安装
npm install -g mcp-xlsx-server或直接运行:
npx mcp-xlsx-server配置
在 Claude Code 中
编辑 claude.json,使用 mcpServers 字段:
{
"mcpServers": {
"xlsx": {
"command": "npx",
"args": ["mcp-xlsx-server"]
}
}
}在 VS Code (GitHub Copilot) 中
编辑 .vscode/mcp.json 或全局 mcp.json,使用 servers 字段(不是 mcpServers):
{
"servers": {
"xlsx": {
"type": "stdio",
"command": "npx",
"args": ["mcp-xlsx-server"]
}
}
}文件位置:
工作区级别:
.vscode/mcp.json全局:
%APPDATA%\Code\User\mcp.json
在 Cline / Roo Code (VS Code 扩展) 中
编辑 cline.json 或 mcp.json,使用 mcpServers 字段:
{
"mcpServers": {
"xlsx": {
"command": "npx",
"args": ["-y", "mcp-xlsx-server"]
}
}
}在 Cursor 中
编辑 .cursor/mcp.json,使用 mcpServers 字段:
{
"mcpServers": {
"xlsx": {
"command": "npx",
"args": ["mcp-xlsx-server"]
}
}
}工具详解
xlsx_list_sheets
列出 xlsx 文件中所有 sheet。
参数:
file_path(string, 必填): xlsx 文件路径
xlsx_read
读取指定 sheet 的数据。
参数:
file_path(string, 必填): xlsx 文件路径sheet(string|number, 必填): sheet 名称或索引 (从 0 开始)format(string, 默认 "json"): "json" 返回对象数组, "array" 返回二维数组range(string, 可选): 单元格范围,如"A1:C10"
xlsx_create
从 JSON 数据创建新的 xlsx 文件。
参数:
file_path(string, 必填): 输出路径data(string, 必填): JSON 数据字符串sheet_name(string, 默认 "Sheet1"): sheet 名称overwrite(boolean, 默认 false): 是否覆盖已有文件
xlsx_add_sheet
向已有 xlsx 文件添加新 sheet。
参数:
file_path(string, 必填): 已存在的 xlsx 文件路径data(string, 必填): JSON 数据字符串sheet_name(string, 必填): 新 sheet 名称
xlsx_update_cells
更新指定单元格。
参数:
file_path(string, 必填): xlsx 文件路径sheet(string|number, 必填): sheet 名称或索引cells(string, 必填): JSON 对象,如{"A1": "值", "B2": 123}
本地开发
# 克隆仓库
git clone https://github.com/lubo3395/mcp-xlsx-server.git
cd mcp-xlsx-server
# 安装依赖
npm install
# 开发模式 (热重载)
npm run dev
# 构建
npm run build
# 运行
npm start
# MCP Inspector 测试
npx @modelcontextprotocol/inspector node dist/index.jsLicense
MIT
Available Tools
5 toolsxlsx_add_sheet添加 Sheet 到 ExcelADestructive
向已有的 xlsx 文件中添加新的 sheet。
参数:
file_path (string, 必填): 已存在的 xlsx 文件路径
data (string, 必填): JSON 数据字符串 (同 xlsx_create 的 data 参数)
sheet_name (string, 必填): 新 sheet 名称 (不能与已有 sheet 重名)
返回:
file_path: 文件路径
sheet_name: 新 sheet 名称
rows: 数据行数
cols: 数据列数
sheets: 更新后的所有 sheet 名称列表
示例:
"往 test.xlsx 添加一个名为 成绩表 的 sheet" -> { file_path: "test.xlsx", data: '[{"姓名":"张三","成绩":90}]', sheet_name: "成绩表" }
错误处理:
Sheet 名称已存在: "Sheet "名称" 已存在。可用 ..."
文件不存在: "文件不存在: ..."
Inputs: file_path (required), data (required), sheet_name (required).
xlsx_create创建 Excel 文件ADestructive
从 JSON 数据创建新的 xlsx 文件。
参数:
file_path (string, 必填): 输出 xlsx 文件路径
data (string, 必填): JSON 数据字符串
对象数组格式: [{"姓名": "张三", "年龄": 30}, {"姓名": "李四", "年龄": 25}]
二维数组格式: [["姓名", "年龄"], ["张三", 30], ["李四", 25]]
sheet_name (string, 默认 "Sheet1"): sheet 名称
overwrite (boolean, 默认 false): 文件已存在时是否覆盖
返回:
file_path: 输出文件路径
sheet_name: sheet 名称
rows: 总行数
cols: 总列数
示例:
"创建 test.xlsx,包含 [{name:'张三',age:30},{name:'李四',age:25}]" -> { file_path: "test.xlsx", data: '[{"name":"张三","age":30},{"name":"李四","age":25}]' }
"覆盖已有文件" -> { file_path: "test.xlsx", data: "...", overwrite: true }
错误处理:
文件已存在且未设置 overwrite: "文件已存在: ..."
输出目录不存在: "输出目录不存在: ..."
数据格式无效: "数据格式无效: ..."
Inputs: file_path (required), data (required), sheet_name, overwrite.
xlsx_list_sheets列出 Excel SheetARead-onlyIdempotent
列出 xlsx 文件中所有 sheet 的名称、行数和列数。
参数:
file_path (string, 必填): xlsx 文件路径
返回:
file_path: 文件路径
sheets: Sheet 信息数组
name: Sheet 名称
rows: 行数
cols: 列数
示例:
"读取 test.xlsx 有哪些 sheet" -> { file_path: "test.xlsx" }
错误处理:
文件不存在: "文件不存在: <路径>"
不是 xlsx 文件: "不支持的文件格式: <路径>"
Inputs: file_path (required).
xlsx_read读取 Excel Sheet 数据ARead-onlyIdempotent
读取 xlsx 文件中指定 sheet 的数据,支持 JSON 对象数组和二维数组两种格式。
参数:
file_path (string, 必填): xlsx 文件路径
sheet (string|number, 必填): sheet 名称或索引 (从 0 开始)
format (string, 默认 "json"): 输出格式
"json": 返回对象数组 (第一行为表头)
"array": 返回二维数组
range (string, 可选): 单元格范围,如 "A1:C10"
header_row (number, 默认 0): 表头行号,仅 json 格式有效
返回:
sheet: 读取的 sheet 名称
rows: 数据行数
cols: 数据列数
data: 表格数据
format: 数据格式
示例:
"读取 test.xlsx 的 Sheet1" -> { file_path: "test.xlsx", sheet: "Sheet1" }
"读取 test.xlsx 第一个 sheet 的 A1 到 C10 范围" -> { file_path: "test.xlsx", sheet: 0, range: "A1:C10" }
"以二维数组格式读取" -> { file_path: "test.xlsx", sheet: "Sheet1", format: "array" }
错误处理:
sheet 不存在: "Sheet "名称" 不存在。可用的 sheet: ..."
sheet 索引无效: "Sheet 索引无效: ..."
文件不存在: "文件不存在: <路径>"
Inputs: file_path (required), sheet (required), format, range, +1 more.
xlsx_update_cells更新 Excel 单元格ADestructive
更新 xlsx 文件中指定 sheet 的单元格值。
参数:
file_path (string, 必填): xlsx 文件路径
sheet (string|number, 必填): sheet 名称或索引 (从 0 开始)
cells (string, 必填): 要更新的单元格,JSON 对象格式: {"A1": "值", "B2": 123, "C3": true}
返回:
file_path: 文件路径
sheet: 更新的 sheet
updated: 更新单元格数量
示例:
"把 test.xlsx 的 Sheet1 中 A1 改成 Hello" -> { file_path: "test.xlsx", sheet: "Sheet1", cells: '{"A1": "Hello"}' }
"批量修改多个单元格" -> { file_path: "test.xlsx", sheet: 0, cells: '{"A1": "标题", "B1": "值"}' }
错误处理:
cells 格式无效: "cells 格式无效: ..."
单元格引用无效: "单元格引用无效: ..."
sheet 不存在: "Sheet ... 不存在"
Inputs: file_path (required), sheet (required), cells (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clear and distinct purpose: creating, adding sheets, listing, reading, and updating cells. No overlap in functionality.
All tools follow a consistent 'xlsx_verb_noun' pattern (e.g., xlsx_add_sheet, xlsx_create). The naming is uniform and predictable.
With 5 tools, the server is well-scoped. Each tool covers a necessary operation for xlsx file manipulation without redundancy or excess.
The tool set covers core CRUD-like operations (create, read, update, add sheets, list sheets). Minor gaps like deleting sheets or rows exist, but the surface is sufficient for common tasks.
Maintenance
Related MCP Connectors
The Excel engine for AI agents: read, check and edit Excel models over MCP.
MCP server for Financial Modeling Prep API with 250+ financial data tools
Excel analytics: inspect, query (JSON rows), charts, and JSON-to-xlsx workbook writing.
Hosted Google Sheets MCP server, with each action switched on or off per account.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol (MCP) server that provides tools for reading Excel (xlsx) files, enabling extraction of data from entire workbooks or specific sheets with results returned in structured JSON format.36Apache 2.0
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI agents to automate Excel file operations including workbook creation, worksheet management, and data manipulation. It provides a standardized interface for reading, writing, merging, and filtering cell ranges within Excel documents.4-
- AlicenseNot gradedqualityDmaintenanceMCP server for reading and writing .xls (Excel 97-2003) files, enabling data manipulation, sheet listing, and metadata retrieval.MIT
- AlicenseAqualityCmaintenanceMCP server for reading and inspecting local Excel files (.xlsx, .xlsm, .xls, .xlsb, .ods) with tools for inspecting metadata, reading ranges, and profiling structure.3MIT