excel-mcp-server
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"excel": {
"args": [
"excel-mcp-server",
"stdio"
],
"command": "uvx"
}
}
}
可用工具 (25 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
apply_formula 4 个参数 需填 4 项
Apply Excel formula to cell. Excel formula will write to cell with verification.
必填参数:filepath、sheet_name、cell、formula
validate_formula_syntax 4 个参数 需填 4 项
Validate Excel formula syntax without applying it.
必填参数:filepath、sheet_name、cell、formula
format_range 18 个参数 需填 3 项
Apply formatting to a range of cells.
必填参数:filepath、sheet_name、start_cell
read_data_from_excel 5 个参数 需填 2 项
Read data from Excel worksheet with cell metadata including validation rules. Args: filepath: Path to Excel file sheet_name: Name of worksheet start_cell: Starting cell (default A1) end_cell: Ending cell (optional, auto-expands if not provided) preview_only: Whether to return preview only Returns: JSON string containing structured cell data with validation metadata. Each cell includes: address, value, row, column, and validation info (if any).
必填参数:filepath、sheet_name
write_data_to_excel 4 个参数 需填 3 项
Write data to Excel worksheet. Excel formula will write to cell without any verification. PARAMETERS: filepath: Path to Excel file sheet_name: Name of worksheet to write to data: List of lists containing data to write to the worksheet, sublists are assumed to be rows start_cell: Cell to start writing to, default is "A1"
必填参数:filepath、sheet_name、data
create_workbook 1 个参数 需填 1 项
Create new Excel workbook.
必填参数:filepath
create_worksheet 2 个参数 需填 2 项
Create new worksheet in workbook.
必填参数:filepath、sheet_name
create_chart 8 个参数 需填 5 项
Create chart in worksheet.
必填参数:filepath、sheet_name、data_range、chart_type、target_cell
create_pivot_table 7 个参数 需填 5 项
Create pivot table in worksheet.
必填参数:filepath、sheet_name、data_range、rows、values
create_table 5 个参数 需填 3 项
Creates a native Excel table from a specified range of data.
必填参数:filepath、sheet_name、data_range
copy_worksheet 3 个参数 需填 3 项
Copy worksheet within workbook.
必填参数:filepath、source_sheet、target_sheet
delete_worksheet 2 个参数 需填 2 项
Delete worksheet from workbook.
必填参数:filepath、sheet_name
rename_worksheet 3 个参数 需填 3 项
Rename worksheet in workbook.
必填参数:filepath、old_name、new_name
get_workbook_metadata 2 个参数 需填 1 项
Get metadata about workbook including sheets, ranges, etc.
必填参数:filepath
merge_cells 4 个参数 需填 4 项
Merge a range of cells.
必填参数:filepath、sheet_name、start_cell、end_cell
unmerge_cells 4 个参数 需填 4 项
Unmerge a range of cells.
必填参数:filepath、sheet_name、start_cell、end_cell
get_merged_cells 2 个参数 需填 2 项
Get merged cells in a worksheet.
必填参数:filepath、sheet_name
copy_range 6 个参数 需填 5 项
Copy a range of cells to another location.
必填参数:filepath、sheet_name、source_start、source_end、target_start
delete_range 5 个参数 需填 4 项
Delete a range of cells and shift remaining cells.
必填参数:filepath、sheet_name、start_cell、end_cell
validate_excel_range 4 个参数 需填 3 项
Validate if a range exists and is properly formatted.
必填参数:filepath、sheet_name、start_cell
get_data_validation_info 2 个参数 需填 2 项
Get all data validation rules in a worksheet. This tool helps identify which cell ranges have validation rules and what types of validation are applied. Args: filepath: Path to Excel file sheet_name: Name of worksheet Returns: JSON string containing all validation rules in the worksheet
必填参数:filepath、sheet_name
insert_rows 4 个参数 需填 3 项
Insert one or more rows starting at the specified row.
必填参数:filepath、sheet_name、start_row
insert_columns 4 个参数 需填 3 项
Insert one or more columns starting at the specified column.
必填参数:filepath、sheet_name、start_col
delete_sheet_rows 4 个参数 需填 3 项
Delete one or more rows starting at the specified row.
必填参数:filepath、sheet_name、start_row
delete_sheet_columns 4 个参数 需填 3 项
Delete one or more columns starting at the specified column.
必填参数:filepath、sheet_name、start_col
服务介绍
一个模型上下文协议(MCP)服务器,允许您在无需安装Microsoft Excel的情况下操作Excel文件。使用您的AI代理创建、读取和修改Excel工作簿。
功能
- 📊 Excel 操作: 创建、读取、更新工作簿和工作表
- 📈 数据处理: 公式、格式、图表、数据透视表和Excel表格
- 🔍 数据验证: 内置范围、公式和数据完整性的验证
- 🎨 格式化: 字体样式、颜色、边框、对齐方式和条件格式
- 📋 表格操作: 创建并管理具有自定义样式的Excel表格
- 📊 图表创建: 生成各种图表类型(折线图、条形图、饼图、散点图等)
- 🔄 数据透视表: 创建用于数据分析的动态数据透视表
- 🔧 工作表管理: 轻松复制、重命名和删除工作表
- 🔌 三重传输支持: stdio、SSE(已弃用)和可流式HTTP
- 🌐 远程与本地: 既可以在本地运行,也可以作为远程服务运行
使用方法
服务器支持三种传输方法:
1. Stdio 传输(用于本地使用)
bash
uvx excel-mcp-server stdio
json
{
"mcpServers": {
"excel": {
"command": "uvx",
"args": ["excel-mcp-server", "stdio"]
}
}
}
2. SSE 传输(服务器发送事件 - 已弃用)
bash
uvx excel-mcp-server sse
SSE 传输连接:
json
{
"mcpServers": {
"excel": {
"url": "http://localhost:8000/sse",
}
}
}
3. 可流式 HTTP 传输(推荐用于远程连接)
bash
uvx excel-mcp-server streamable-http
可流式 HTTP 传输连接:
json
{
"mcpServers": {
"excel": {
"url": "http://localhost:8000/mcp",
}
}
}
环境变量与文件路径处理
SSE 和可流式 HTTP 传输
当使用 SSE 或可流式 HTTP 协议 运行服务器时,必须在服务器端设置 EXCEL_FILES_PATH 环境变量。此变量告诉服务器在哪里读写Excel文件。
- 如果未设置,默认为
./excel_files。
您还可以设置 FASTMCP_PORT 环境变量来控制服务器监听的端口(如果未设置,默认为 8017)。
-
示例(Windows PowerShell):
powershell
$env:EXCEL_FILES_PATH="E:\MyExcelFiles"
$env:FASTMCP_PORT="8007"
uvx excel-mcp-server streamable-http -
示例(Linux/macOS):
bash
EXCEL_FILES_PATH=/path/to/excel_files FASTMCP_PORT=8007 uvx excel-mcp-server streamable-http
Stdio 传输
当使用 stdio 协议 时,每次工具调用都会提供文件路径,因此不需要在服务器上设置 EXCEL_FILES_PATH。服务器将使用客户端发送的路径进行每次操作。
可用工具
服务器提供了全面的Excel操作工具集。请参阅 TOOLS.md 获取所有可用工具的完整文档。
Star 历史
许可证
MIT 许可证 - 详情请参见 LICENSE。