e

excel-mcp-server

communication

7.6k 查看 · 2026-07-07 更新

Excel MCP Server Logo

PyPI version Total Downloads License: MIT smithery badge Install MCP Server

一个模型上下文协议(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 历史

Star History Chart

许可证

MIT 许可证 - 详情请参见 LICENSE

工具列表

  • apply_formula: Apply Excel formula to cell. Excel formula will write to cell with verification.

  • validate_formula_syntax: Validate Excel formula syntax without applying it.

  • format_range: Apply formatting to a range of cells.

  • read_data_from_excel: 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).

  • write_data_to_excel: 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"

  • create_workbook: Create new Excel workbook.

  • create_worksheet: Create new worksheet in workbook.

  • create_chart: Create chart in worksheet.

  • create_pivot_table: Create pivot table in worksheet.

  • create_table: Creates a native Excel table from a specified range of data.

  • copy_worksheet: Copy worksheet within workbook.

  • delete_worksheet: Delete worksheet from workbook.

  • rename_worksheet: Rename worksheet in workbook.

  • get_workbook_metadata: Get metadata about workbook including sheets, ranges, etc.

  • merge_cells: Merge a range of cells.

  • unmerge_cells: Unmerge a range of cells.

  • get_merged_cells: Get merged cells in a worksheet.

  • copy_range: Copy a range of cells to another location.

  • delete_range: Delete a range of cells and shift remaining cells.

  • validate_excel_range: Validate if a range exists and is properly formatted.

  • get_data_validation_info: 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

  • insert_rows: Insert one or more rows starting at the specified row.

  • insert_columns: Insert one or more columns starting at the specified column.

  • delete_sheet_rows: Delete one or more rows starting at the specified row.

  • delete_sheet_columns: Delete one or more columns starting at the specified column.

服务配置

[{'mcpServers': {'excel': {'args': ['excel-mcp-server', 'stdio'], 'command': 'uvx'}}}]

来源