Skip to main content

A Model Context Protocol server providing Excel reading and writing functionality

Project description

MCP Excel Server

一个基于 Model Context Protocol (MCP) 的 Excel 处理服务器,提供以下功能:

  1. 获取 Excel 工作簿信息

    • 读取所有工作表名称
    • 获取每个工作表的表头
    • 获取数据范围信息
  2. 读取 Excel 数据

    • 支持按范围读取数据
    • 支持读取公式
  3. 写入 Excel 数据

    • 支持按范围写入数据
    • 支持写入公式

安装

pip install baiyx-mcp-server-excel

使用方法

启动服务器:

baiyx-mcp-server-excel

功能说明

1. 获取工作簿信息

get_workbook_info(file_path: str) -> WorkbookInfo

返回工作簿中所有工作表的信息,包括表名、表头和数据范围。

2. 读取数据

read_sheet_data(file_path: str, sheet_name: str, range: Optional[str] = None) -> ExcelData

从指定工作表读取数据,可以指定读取范围(例如:"A1:C10")。

3. 读取公式

read_sheet_formula(file_path: str, sheet_name: str, range: Optional[str] = None) -> ExcelFormula

从指定工作表读取公式,可以指定读取范围。

4. 写入数据

write_sheet_data(file_path: str, sheet_name: str, range: str, data: List[List[Any]]) -> bool

向指定工作表写入数据,需要指定写入范围。

5. 写入公式

write_sheet_formula(file_path: str, sheet_name: str, range: str, formulas: List[str]) -> bool

向指定工作表写入公式,需要指定写入范围。

示例

# 获取工作簿信息
workbook_info = get_workbook_info("example.xlsx")
print(f"Found {len(workbook_info.sheets)} sheets")

# 读取数据
data = read_sheet_data("example.xlsx", "Sheet1", "A1:C10")
print(f"Read {len(data.data)} rows")

# 写入数据
success = write_sheet_data("example.xlsx", "Sheet1", "A1", [[1, 2, 3], [4, 5, 6]])
print(f"Write {'successful' if success else 'failed'}")

依赖

  • Python >= 3.10
  • mcp >= 1.6.0
  • pandas >= 2.0.0
  • openpyxl >= 3.1.2

许可证

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baiyx_mcp_server_excel-0.1.3.tar.gz (43.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

baiyx_mcp_server_excel-0.1.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file baiyx_mcp_server_excel-0.1.3.tar.gz.

File metadata

  • Download URL: baiyx_mcp_server_excel-0.1.3.tar.gz
  • Upload date:
  • Size: 43.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for baiyx_mcp_server_excel-0.1.3.tar.gz
Algorithm Hash digest
SHA256 84ff1c619cd813bf5cc3945d3cb54d41e1fd59ba9e46b0033f68405eeb50724f
MD5 93fe31bcde8060ccce2f0ca32aeef359
BLAKE2b-256 4109e67538e4f352bd8184c37332a082d0ebd4365dd9fcd5b9717c3581cf1c20

See more details on using hashes here.

File details

Details for the file baiyx_mcp_server_excel-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for baiyx_mcp_server_excel-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f24c532c47b345cac5ef7a955fa5902d496feecbcf185415943524499df6e241
MD5 d009652561e7034cf7650b17f7f7644c
BLAKE2b-256 ab5621343dfceae34add787cc128ff36f252828d70e3e45b290f57652297182f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page