MCP Excel 读取器服务器
一个模型上下文协议(MCP)服务器,提供读取Excel(xlsx)文件的工具,能够从整个工作簿或特定工作表中提取数据,并以结构化的JSON格式返回结果。
可用工具 (3 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
read_excel 1 个参数 需填 1 项
Read content from Excel (xlsx) files
必填参数:file_path
read_excel_by_sheet_name 2 个参数 需填 1 项
Read content from a specific sheet by name in Excel (xlsx) files. Reads first sheet if sheet_name not provided.
必填参数:file_path
read_excel_by_sheet_index 2 个参数 需填 1 项
Read content from a specific sheet by index in Excel (xlsx) files. Reads first sheet (index 0) if sheet_index not provided.
必填参数:file_path
服务介绍
Excel Reader Server
一个提供读取 Excel (xlsx) 文件工具的 Model Context Protocol (MCP) 服务器。
功能
- 从 Excel 文件的所有工作表中读取内容
- 按名称从特定的工作表中读取内容
- 按索引从特定的工作表中读取内容
- 以 JSON 格式返回数据
- 处理空单元格和数据类型转换
安装
需要 Python 3.10 或更高版本。
# Using pip
pip install excel-reader-server
# Using uv (recommended)
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" # optional
}
3. read_excel_by_sheet_index
按索引从特定的工作表中读取内容。如果未提供索引,则读取第一个工作表(索引 0)。
{
"file_path": "path/to/your/excel/file.xlsx",
"sheet_index": 0 # optional
}
响应格式
服务器以以下 JSON 格式返回数据:
{
"Sheet1": [
["Header1", "Header2", "Header3"],
["Value1", "Value2", "Value3"],
["Value4", "Value5", "Value6"]
]
}
- 每个工作表作为顶级对象中的一个键表示
- 工作表数据是一个数组的数组,其中每个内部数组代表一行
- 所有值都被转换为字符串
- 空单元格被表示为空字符串
错误处理
服务器为常见问题提供了明确的错误消息:
- 文件未找到
- 无效的工作表名称
- 索引超出范围
- 一般的 Excel 文件读取错误
许可证
该项目在 Apache 2 许可证下发布。请参阅 LICENSE 文件获取详细信息。
贡献
欢迎贡献!请随时提交 Pull Request。