Back to MCP directory
publicPublicdnsLocal runtime

mcp-excel-reader-server

Excel文件读取服务器,提供多种读取Excel内容的功能

article

README

🚀 Excel 读者服务器

Excel 读者服务器是一个基于模型上下文协议(MCP)的服务器,它为用户提供了读取 Excel(xlsx)文件的实用工具,能帮助用户高效处理 Excel 数据。

🚀 快速开始

Excel 读者服务器是一个强大的工具,可用于读取 Excel 文件。使用前,请确保你的 Python 版本为 3.10 或更高。

✨ 主要特性

  • 可读取 Excel 文件中所有工作表的内容。
  • 支持根据名称读取特定工作表的内容。
  • 支持根据索引读取特定工作表的内容。
  • 以 JSON 格式返回数据,方便处理。
  • 能处理空单元格和进行数据类型转换。

📦 安装指南

需要 Python 3.10 或更高版本。

# 使用 pip
pip install excel-reader-server

# 使用 uv(推荐)
uv pip install excel-reader-server

依赖项

| 属性 | 详情 | |------|------| | 依赖库 | mcp >= 1.2.1;openpyxl >= 3.1.5 |

💻 使用示例

服务器提供了三个主要工具:

基础用法

1. read_excel

读取 Excel 文件中所有工作表的内容。

{
  "file_path": "path/to/your/excel/file.xlsx"
}

2. read_excel_by_sheet_name

根据名称读取特定工作表的内容。如果未提供工作表名称,则读取第一个工作表。

{
  "file_path": "path/to/your/excel/file.xlsx",
  "sheet_name": "Sheet1"  # 可选参数
}

3. read_excel_by_sheet_index

根据索引读取特定工作表的内容。如果未提供索引,则读取第一个工作表(索引为 0)。

{
  "file_path": "path/to/your/excel/file.xlsx",
  "sheet_index": 0  # 可选参数
}

响应格式

服务器以以下 JSON 格式返回数据:

{
  "Sheet1": [
    ["Header1", "Header2", "Header3"],
    ["Value1", "Value2", "Value3"],
    ["Value4", "Value5", "Value6"]
  ]
}
  • 每个工作表以顶级对象中的键表示。
  • 工作表数据是一个数组,其中每个内部数组表示一行。
  • 所有值都转换为字符串。
  • 空单元格表示为空字符串。

📚 详细文档

错误处理

服务器提供清晰的错误消息,针对常见问题包括:

  • 文件未找到
  • 无效的工作表名称
  • 索引超出范围
  • 通用 Excel 文件读取错误

📄 许可证

该项目在 Apache 2 许可证下发布。有关详细信息,请参阅 LICENSE 文件。

贡献

欢迎贡献!请随意提交 Pull Request。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client