| Crates.io | excel_mcp_rust |
| lib.rs | excel_mcp_rust |
| version | 0.0.1 |
| created_at | 2026-01-12 05:35:33.986085+00 |
| updated_at | 2026-01-12 05:35:33.986085+00 |
| description | A Model Context Protocol (MCP) server for Excel file manipulation using calamine and rust_xlsxwriter |
| homepage | |
| repository | https://gitee.com/awol2010ex/excel_mcp_rust |
| max_upload_size | |
| id | 2037040 |
| size | 289,181 |
一个基于 Rust 的 Model Context Protocol (MCP) 服务器,用于 Excel 文件的创建、读取、更新和删除操作。
cargo build --release
cargo run --release
服务器将在默认端口启动,监听 JSON-RPC 请求。
{
"jsonrpc": "2.0",
"method": "create_workbook",
"params": {
"name": "MyWorkbook"
},
"id": 1
}
{
"jsonrpc": "2.0",
"method": "create_worksheet",
"params": {
"workbook_id": "workbook_uuid",
"name": "Sheet1"
},
"id": 2
}
{
"jsonrpc": "2.0",
"method": "set_cell_value",
"params": {
"workbook_id": "workbook_uuid",
"worksheet_name": "Sheet1",
"cell_reference": "A1",
"value": "Hello Excel!"
},
"id": 3
}
{
"jsonrpc": "2.0",
"method": "set_cell_formula",
"params": {
"workbook_id": "workbook_uuid",
"worksheet_name": "Sheet1",
"cell_reference": "A2",
"formula": "=SUM(B1:C1)"
},
"id": 4
}
{
"jsonrpc": "2.0",
"method": "create_cell_style",
"params": {
"workbook_id": "workbook_uuid",
"style_name": "MyStyle",
"font": {
"name": "Arial",
"size": 12,
"bold": true,
"color": "#FF0000"
},
"background_color": "#FFFF00",
"alignment": {
"horizontal": "center",
"vertical": "center"
}
},
"id": 5
}
{
"jsonrpc": "2.0",
"method": "apply_cell_style",
"params": {
"workbook_id": "workbook_uuid",
"worksheet_name": "Sheet1",
"cell_reference": "A1",
"style_id": "style_uuid"
},
"id": 6
}
{
"jsonrpc": "2.0",
"method": "set_range_values",
"params": {
"workbook_id": "workbook_uuid",
"worksheet_name": "Sheet1",
"start_cell": "A1",
"end_cell": "C3",
"values": [
["Name", "Age", "City"],
["Alice", 25, "New York"],
["Bob", 30, "London"]
]
},
"id": 7
}
excel_mcp_rust/
├── src/
│ ├── core.rs # ExcelServer 核心实现
│ ├── handlers.rs # JSON-RPC 请求处理器
│ ├── main.rs # 服务器入口点
│ ├── lib.rs # 库导出
│ └── tools/ # 功能模块
│ ├── mod.rs # 模块定义
│ ├── workbook.rs # 工作簿操作
│ ├── worksheet.rs # 工作表操作
│ ├── cell.rs # 单元格操作
│ ├── style.rs # 样式管理
│ ├── formula.rs # 公式处理
│ └── management.rs # 管理工具
├── tests/
│ └── integration_tests.rs # 集成测试
├── Cargo.toml # 项目配置
└── README.md # 项目文档
使用 Arc<Mutex<ExcelServer>> 确保多线程环境下的安全访问。
完善的错误处理机制,所有操作返回 Result<Value, String>。
输入参数验证,确保数据完整性和有效性。
支持多种范围表示方式:
完整的样式支持:
worksheet_id 和 worksheet_name 两种参数格式cell_reference 和 cell_address 两种参数格式首先确保项目已正确构建:
cd e:\workspace_rust\excel_mcp_rust
cargo build --release
在 Trae 的 settings.json 文件中添加 MCP 服务器配置:
{
"mcpServers": {
"excel": {
"command": "e:\\workspace_rust\\excel_mcp_rust\\target\\release\\excel_mcp_rust.exe"
}
}
}
command: Excel MCP 服务器可执行文件路径
args: 启动参数(可选)
env: 环境变量(可选)
disabled: 是否禁用此服务器
timeout: 超时时间(毫秒)
配置完成后,在 Trae 中可以使用自然语言操作 Excel:
如果服务器无法连接:
cargo build --release 成功完成excel_mcp_rust.exe 验证能否启动项目包含全面的测试套件:
# 运行所有测试
cargo test
# 运行特定测试
cargo test test_workbook_creation
# 带输出运行测试
cargo test -- --nocapture
✅ 已完成: 所有核心功能实现和测试通过
所有依赖项使用精确版本锁定,确保构建一致性:
欢迎提交 Issue 和 Pull Request 来改进这个项目。
Apache-2.0 License
awol2005ex awol2005ex@163.com