Excel数据处理服务器

一个用于读取和写入Microsoft Excel数据的模型上下文协议(MCP)服务器,支持多种Excel文件格式和操作。

  • by fbeelm
  • Go
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 fbeawels/excel-mcp-server

使用说明

Excel MCP服务器

读取和写入MS Excel数据的模型上下文协议(MCP)服务器。

特性

  • 从MS Excel文件读取文本值
  • 将文本值写入MS Excel文件
  • 从MS Excel文件读取公式
  • 将公式写入MS Excel文件
  • 从MS Excel文件捕获屏幕图像(仅限Windows)

有关更多详细信息,请参阅 工具 部分。

需求

  • Node.js 20.x或更高版本

支持的文件格式

  • xlsx(Excel书籍)
  • xlsm(支持Excel宏的书籍)
  • xltx(Excel模板)
  • xltm(启用Excel宏的模板)

安装

通过NPM安装

通过将以下配置添加到mcp服务器配置中,可以自动安装excelmcp服务器。

使用stdio传输(默认)

对于Windows:

{
    "mcpServers": {
        "excel": {
            "command": "cmd",
            "args": ["/c", "npx", "--yes", "@fbeawels/excel-mcp-server"],
            "env": {
                "EXCEL_MCP_PAGING_CELLS_LIMIT": "4000"
            }
        }
    }
}

对于其他平台:

{
    "mcpServers": {
        "excel": {
            "command": "npx",
            "args": ["--yes", "@fbeawels/excel-mcp-server"],
            "env": {
                "EXCEL_MCP_PAGING_CELLS_LIMIT": "4000"
            }
        }
    }
}

使用SSE传输

对于Windows:

{
    "mcpServers": {
        "excel": {
            "command": "cmd",
            "args": ["/c", "npx", "--yes", "@fbeawels/excel-mcp-server"],
            "env": {
                "EXCEL_MCP_PAGING_CELLS_LIMIT": "4000",
                "EXCEL_MCP_TRANSPORT": "sse",
                "EXCEL_MCP_HOST": "0.0.0.0",
                "EXCEL_MCP_PORT": "8000"
            }
        }
    }
}

对于其他平台:

{
    "mcpServers": {
        "excel": {
            "command": "npx",
            "args": ["--yes", "@fbeawels/excel-mcp-server"],
            "env": {
                "EXCEL_MCP_PAGING_CELLS_LIMIT": "4000",
                "EXCEL_MCP_TRANSPORT": "sse",
                "EXCEL_MCP_HOST": "0.0.0.0",
                "EXCEL_MCP_PORT": "8000"
            }
        }
    }
}

使用SSE传输时,服务器将启动具有以下端点的HTTP服务器:

  • /sse -用于从服务器接收事件的SSE端点
  • /command -用于向服务器发送命令的POST端点
  • /status -用于检查服务器状态的GET端点

通过Smithery安装

通过以下方式自动安装Excel MCP Server for Claude Desktop 史密瑟里:

npx -y @smithery/cli install @fbeawels/excel-mcp-server --client claude

Tools

read_sheet_names

列出Excel文件中的所有工作表名称。

论据:

  • fileAbsolutePath
    • Excel文件的绝对路径

read_sheet_data

从带分页的Excel表中读取数据。

论据:

  • fileAbsolutePath
    • Excel文件的绝对路径
  • sheetName
    • Excel文件中的工作表名称
  • range
    • Excel工作表中要读取的单元格范围(例如“A1:C10”)。[默认值:第一个分页范围]
  • knownPagingRanges
    • 已读取的分页范围列表

read_sheet_formula

从带分页的Excel表中读取公式。

论据:

  • fileAbsolutePath
    • Excel文件的绝对路径
  • sheetName
    • Excel文件中的工作表名称
  • range
    • Excel工作表中要读取的单元格范围(例如“A1:C10”)。[默认值:第一个分页范围]
  • knownPagingRanges
    • 已读取的分页范围列表

read_sheet_image

[仅限Windows] 从带有分页的Excel工作表中以图像形式读取数据。

论据:

  • fileAbsolutePath
    • Excel文件的绝对路径
  • sheetName
    • Excel文件中的工作表名称
  • range
    • Excel工作表中要读取的单元格范围(例如“A1:C10”)。[默认值:第一个分页范围]
  • knownPagingRanges
    • 已读取的分页范围列表

write_sheet_data

将数据写入Excel工作表。

论据:

  • fileAbsolutePath
    • Excel文件的绝对路径
  • sheetName
    • Excel文件中的工作表名称
  • range
    • Excel工作表中要读取的单元格范围(例如“A1:C10”)。
  • data
    • 要写入Excel工作表的数据

write_sheet_formula

将公式写入Excel工作表。

论据:

  • fileAbsolutePath
    • Excel文件的绝对路径
  • sheetName
    • Excel文件中的工作表名称
  • range
    • Excel工作表中要读取的单元格范围(例如“A1:C10”)。
  • formulas
    • 要写入Excel工作表的公式(例如,“=A1+B1”)

Configuration

命令行参数

以下命令行参数可用:

--transport <type>   Transport type (stdio or sse)
--host <address>     Host address to listen on for SSE transport (default: all interfaces)
--port <number>      Port for SSE transport (default: 8000)

示例用法:

npx @fbeawels/excel-mcp-server --transport sse --host 0.0.0.0 --port 8000

环境变量

您还可以通过以下环境变量更改MCP服务器行为:

EXCEL_MCP_PAGING_CELLS_LIMIT

在单个分页操作中要读取的最大单元格数。
[默认值:4000]

EXCEL_MCP_TRANSPORT

用于通信的传输机制。
可能值: stdio, sse
[默认值:stdio]

EXCEL_MCP_HOST

使用SSE传输时要绑定的主机地址。
[默认值:“”](所有接口)

EXCEL_MCP_PORT

使用SSE传输时HTTP服务器使用的端口。
[默认值:8000]

许可证

版权所有(c)2025弗兰克·贝斯纳德

excelmcp服务器在 MIT许可证