Excel MCP集成
使用模型上下文协议(MCP)通过自然语言命令创建AI驱动的Excel电子表格。
什么是Excel MCP?
Excel MCP允许大型语言模型通过自然语言创建、操作和分析Excel电子表格。它与人工智能助手集成,将对话请求转换为专业Excel文件。
特性
- Excel创建:从自然语言生成电子表格
- 高级格式化:页眉、颜色、边框、对齐方式
- 图表生成:条形图、折线图、饼图、散点图
- CSV集成:导入/导出CSV文件
- 企业安全:输入验证和路径净化
- 多语言支持:UTF-8支持
快速开始
Docker(推荐)
docker run -d \
--name excel-mcp \
-p 9080:8000 \
-p 9081:8001 \
antuelle78/excel-mcp-integration:latest本地开发
git clone https://github.com/antuelle78/excel-mcp-integration.git
cd excel-mcp-integration
pip install -r requirements.txt
python src/main.pyAPI使用
创建Excel文件
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create_excel_file",
"arguments": {
"filename": "example.xlsx",
"headers": ["Name", "Value"],
"sheet_data": [["Item 1", "100"], ["Item 2", "200"]]
}
}
}'可用工具
create_excel_file-创建具有数据和格式的Excel文件get_excel_info-分析现有Excel文件create_excel_chart-将图表添加到Excel文件format_excel_cells-将格式应用于单元格import_csv_to_excel-将CSV转换为Excelexport_excel_to_csv-将Excel转换为CSV
配置
| 变量 | 默认值 | 描述 |
|---|---|---|
HOST | 0.0.0.0 | 服务器绑定地址 |
PORT | 8000 | MCP服务器端口 |
OUTPUT_DIR | ./output | Excel文件目录 |
MAX_ROWS | 10000 | 每页最大行数 |
MAX_COLS | 100 | 每页最大列数 |
AI集成
打开WebUI集成
Excel MCP通过以下方式与Open WebUI集成:
- 管道功能:专用Excel助手模型
- 定制工具:为任何AI模型添加Excel功能
测试
# Run all tests
python -m pytest tests/ -v
# Run specific test
python -m pytest tests/integration_test.py::test_mcp_workflow -v部署
- 码头工人:
docker run antuelle78/excel-mcp-integration:latest - Docker Compose:
docker compose up -d - Kubernetes:
kubectl apply -f excel-mcp-deployment.yaml
文档
许可证
MIT许可证-请参阅 许可证 了解详情。
✨ 什么是Excel MCP?
Excel MCP 是一个革命性的人工智能驱动系统,允许大型语言模型通过自然语言命令创建、操作和分析Excel电子表格。使用模型上下文协议(MCP),它与AI助手无缝集成,将对话请求转换为专业Excel文件。
“从单词到工作表只需几秒钟!” ⚡
🎭 背后的魔力
想象一下,问你的人工智能助手: *“创建包含产品类别和收入数据的第四季度销售报告”* -并立即收到格式完美的Excel文件!这就是Excel MCP的强大功能。
graph TD
A[👤 User Request] --> B[🤖 AI Assistant]
B --> C[🔧 Excel MCP Tools]
C --> D[📊 Excel File Generation]
D --> E[📁 Download Ready]
E --> F[✅ User Downloads]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
style D fill:#fff3e0
style E fill:#fce4ec
style F fill:#e8f5e8______________________________________________________________________
🎨 令人惊叹的功能
🚀 核心能力
| 功能 | 描述 | 状态 |
|---|---|---|
| 📊 Excel创建 | 从自然语言生成电子表格 | ✅ 活跃的 |
| 🎨 高级格式化 | 标题、颜色、边框、对齐方式 | ✅ 活跃的 |
| 📈 图表生成 | 条形图、折线图、饼图、散点图 | ✅ 活跃的 |
| 🔄 CSV集成 | 无缝导入/导出CSV文件 | ✅ 活跃的 |
| 🔒 企业安全 | 输入验证、路径清理 | ✅ 活跃的 |
| 🌐 多语言 | 全球用户支持UTF-8 | ✅ 活跃的 |
🎯 AI集成
| 集成 | 方法 | 状态 |
|---|---|---|
| 🤖 打开WebUI | 自定义工具和管道功能 | ✅ 生产就绪 |
| 🧠 Llama模特 | 直接MCP协议支持 | ✅ 已测试 |
| 🔌 REST API | 用于自定义集成的HTTP端点 | ✅ 可用 |
| 📡 双向通信 | 实时文件生成更新 | 🚧 计划的 |
🔥 为什么Excel MCP脱颖而出
- ⚡ 迅速的:在几秒钟内创建复杂的电子表格
- 🧠 AI驱动:自然语言到Excel的转换
- 🔒 企业就绪:安全第一的设计和验证
- 🐳 Docker原生:一次指挥部署
- 📱 Web兼容:适用于任何Open WebUI实例
- 🎨 专业输出:可发布的Excel文件
______________________________________________________________________
🖼️ 视觉展示
📊 示例输出示例
📈 Sales Dashboard
Auto-generated charts & formatting
👥 Employee Directory
Professional data organization
📊 Financial Report
Complex calculations & formatting
📅 Project Timeline
Gantt charts & date formatting
______________________________________________________________________
🏗️ 架构概述
graph TB
subgraph "🌐 User Interface"
A[Open-WebUI]
B[Custom AI Assistant]
end
subgraph "🔧 Excel MCP Server"
C[MCP Protocol Handler]
D[Excel Tools Engine]
E[Security Validator]
F[File Generator]
end
subgraph "💾 Data & Storage"
G[Excel Templates]
H[Output Directory]
I[Session Cache]
end
subgraph "🐳 Infrastructure"
J[Docker Container]
K[FastAPI Server]
L[File Server]
end
A --> C
B --> C
C --> D
D --> E
E --> F
F --> H
D --> I
J --> K
J --> L
style A fill:#e3f2fd
style C fill:#f3e5f5
style D fill:#e8f5e8
style J fill:#fff3e0🛠️ 技术栈
| 组件 | 技术 | 目的 |
|---|---|---|
| 🤖 AI模型 | Llama 3.1 8B | 自然语言处理 |
| 🔧 MCP框架 | FastMCP | 协议实现 |
| 📊 Excel引擎 | openpyxl | 电子表格操作 |
| 🌐 Web服务器 | FastAPI | REST API端点 |
| 🐳 容器 | Docker | 部署和隔离 |
| 🔒 安全 | 自定义验证器 | 输入净化 |
______________________________________________________________________
🚀 快速入门指南
⚡ 3分钟后开始!
](https://hub.docker.com/r/antuelle78/excel-mcp-integration) 
🎯 当前状态:生产准备就绪 ✅
| 服务 | 状态 | URL |
|---|---|---|
| 🔧 MCP服务器 | 🟢 跑步 | http://excelgen.e-cancer.fr:31006/mcp |
| 📁 文件服务器 | 🟢 活跃的 | http://10.2.0.150:31007/files/ |
| 🤖 AI集成 | 🟢 已测试 | 开放式WebUI兼容 |
| 🐳 码头工人 | 🟢 部署 | antuelle78/excel-mcp-integration |
| ☸️ Kubernetes | 🟢 准备就绪 | kubectl apply -f excel-mcp-deployment.yaml |
______________________________________________________________________
📦 方法1:Docker(推荐-30秒)
# 🚀 One-command deployment!
docker run -d \
--name excel-mcp \
-p 9080:8000 \
-p 9081:8001 \
antuelle78/excel-mcp-integration:latest
# ✅ Check status
docker ps | grep excel-mcp
# 🎯 Test connection
curl http://excelgen.e-cancer.fr:31006/mcp就是这样!您的Excel MCP服务器现在正在运行! 🎉
______________________________________________________________________
🐳 方法2:Docker编写(完整设置)
# 📄 docker-compose.yml
version: '3.8'
services:
excel-mcp:
image: antuelle78/excel-mcp-integration:latest
container_name: excel-mcp-server
ports:
- "9080:8000" # MCP Server
- "9081:8001" # File Server
volumes:
- ./output:/app/output
environment:
- MAX_ROWS=10000
- MAX_COLS=100
restart: unless-stopped# 🚀 Deploy the stack
docker compose up -d
# 📊 Monitor logs
docker compose logs -f excel-mcp______________________________________________________________________
💻 方法3:地方发展
步骤1:克隆和设置
# 📥 Get the code
git clone https://github.com/antuelle78/excel-mcp-integration.git
cd excel-mcp-integration
# 🐍 Create virtual environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 📦 Install dependencies
pip install -r requirements.txt步骤2:启动服务
# Terminal 1: Start MCP Server
python src/main.py
# Terminal 2: Start File Server (optional)
python -m http.server 8001 -d output/
# 🎯 Server ready at: http://localhost:8000/mcp______________________________________________________________________
🔗 集成测试
服务器运行后,使用以下curl命令进行测试:
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{
"jsonrpc": "2.0",
"id": "test",
"method": "tools/call",
"params": {
"name": "create_excel_file",
"arguments": {
"filename": "hello_world.xlsx",
"headers": ["Message", "Status"],
"sheet_data": [["Hello", "Success"], ["World", "Ready"]]
}
}
}'预期响应:
{
"jsonrpc": "2.0",
"id": "test",
"result": {
"content": [{
"type": "text",
"text": "Successfully created Excel file: output/hello_world.xlsx"
}]
}
}______________________________________________________________________
⚙️ 配置和定制
🔧 环境变量
| 变量 | 默认值 | 描述 | 示例 |
|---|---|---|---|
HOST | 0.0.0.0 | 服务器绑定地址 | 127.0.0.1 |
PORT | 8000 | MCP服务器端口 | 9080 |
FILE_SERVER_PORT | 8001 | 文件服务器端口 | 9081 |
OUTPUT_DIR | ./output | Excel文件目录 | /app/output |
MAX_ROWS | 10000 | 每页最大行数 | 50000 |
MAX_COLS | 100 | 每页最大列数 | 200 |
MAX_FILENAME_LENGTH | 255 | 最大文件名长度 | 100 |
🎨 高级配置
# 🚀 Production-ready configuration
export HOST=0.0.0.0
export PORT=9080
export FILE_SERVER_PORT=9081
export OUTPUT_DIR=/app/output
export MAX_ROWS=50000
export MAX_COLS=500
# 🔒 Security settings
export ALLOWED_EXTENSIONS=".xlsx,.xls"
export MAX_FILE_SIZE=10485760 # 10MB
# 📊 Performance tuning
export WORKER_COUNT=4
export TIMEOUT=300______________________________________________________________________
🔌 API 参考
🛠️ 可用的MCP工具
| 工具 | 描述 | 状态 |
|---|---|---|
create_excel_file | 创建具有数据和格式的Excel文件 | ✅ 活跃的 |
get_excel_info | 分析现有Excel文件 | ✅ 活跃的 |
create_excel_chart | 将图表添加到Excel文件 | ✅ 活跃的 |
format_excel_cells | 将格式应用于单元格 | ✅ 活跃的 |
import_csv_to_excel | 将CSV转换为Excel | ✅ 活跃的 |
export_excel_to_csv | 将Excel转换为CSV | ✅ 活跃的 |
📝 create_excel_file -明星球员
从简单的数据结构创建专业Excel文件
📊 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
filename | string | ✅ | Excel文件名(.xlsx自动附加) |
headers | 列表\[str\] | ✅ | 列标题数组 |
sheet_data | 列表\[列表\] | ✅ | 二维数据数组(行×列) |
sheet_name | string | ❌ | 工作表名称(默认值:“Sheet1”) |
formatting 字典❌ | 造型选项 |
🎯 现场示例
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create_excel_file",
"arguments": {
"filename": "employee_roster.xlsx",
"headers": ["Name", "Department", "Salary", "Start Date"],
"sheet_data": [
["Alice Johnson", "Engineering", "$85,000", "2023-01-15"],
["Bob Smith", "Marketing", "$72,000", "2023-03-01"],
["Carol Davis", "Sales", "$68,000", "2023-02-10"]
],
"sheet_name": "Employee Directory",
"formatting": {
"header_bold": true,
"header_background": "4472C4",
"alternate_row_colors": true
}
}
}
}🎉 结果: 具有格式化标题、交替行颜色和正确数据类型的专业Excel文件!
______________________________________________________________________
🎨 高级格式化选项
| 格式选项 | 值 | 描述 |
|---|---|---|
header_bold | true/false | 粗体列标题 |
header_background | 十六进制颜色 | 标题背景颜色 |
alternate_row_colors | true/false | 斑马条纹 |
font_size | 数字 | 单元格字体大小 |
alignment | left/center/right | 文本对齐方式 |
border | true/false | 单元格边框 |
number_format | Excel格式 | 数字格式 |
🌈 颜色示例
4472C4-专业蓝2E75B6-企业蓝9C27B0-紫色口音4CAF50-成功绿色FF9800-橙色警告
______________________________________________________________________
📊 图表生成工具
🎯 创建excel图表
将您的数据转化为视觉洞察!
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create_excel_chart",
"arguments": {
"filename": "sales_data.xlsx",
"chart_type": "bar",
"data_range": "A1:C13",
"title": "Monthly Sales Performance",
"sheet_name": "Sales"
}
}
}📈 支持的图表类型
| 类型 | 描述 | 最适合 |
|---|---|---|
bar | 竖线 | 比较 |
line | 连接点 | 随时间变化的趋势 |
pie | 圆形分段 | 比例 |
scatter | X-Y点 | 相关性 |
area | 填充面积 | 随时间变化的体积 |
______________________________________________________________________
🤖 AI集成-将Excel带入生活!
🎭 打开WebUI集成
 
将您的AI助手转变为Excel专家! ✨
🚀 集成方法
🎯 方法1:AI管道功能(推荐)
把你的AI变成一个专门的Excel助手!
# 🤖 Your AI becomes an Excel expert
User: "Create a sales report for Q4 with charts"
Assistant: "I'll create a professional Excel file with your Q4 sales data and charts."
# 📊 Result: Perfectly formatted Excel file with charts!特征:
- 🎭 自定义AI角色:Open WebUI中的“Excel助手”模型
- 🗣️ 自然语言:对话式Excel创建
- 🧠 智能识别:自动检测电子表格请求
- ⚡ 即时结果:文件在几秒钟内准备就绪
设置: 📖 完整的管道设置指南
______________________________________________________________________
🔧 方法2:自定义工具集成
为任何AI模型添加Excel超能力
// 🛠️ Configure in Open-WebUI Admin Panel
{
"name": "Excel Creator",
"description": "Create professional Excel spreadsheets",
"tools": ["create_excel_file", "create_excel_chart"]
}特征:
- 🎛️ 管理面板配置:轻松设置web界面
- 🔗 多模型支持:适用于任何法学硕士
- 📋 预构建模板:即用型配置
- 🎨 自定义品牌:适应您的需求
设置: 📖 手动设置指南
______________________________________________________________________
💬 真实用户对话
👨💼 业务用户场景
User: "I need a budget spreadsheet for next quarter with categories for marketing, sales, and operations"
Assistant: "I'll create a comprehensive budget spreadsheet with proper formatting and calculations."
[AI processes request through Excel MCP]
Result: "✅ Budget spreadsheet created! Download: budget_q1_2024.xlsx"
- Professional formatting with headers
- Auto-calculations for totals
- Color-coded categories
- Ready for executive review👩💻 开发人员场景
User: "Generate a test data spreadsheet with 100 rows of user information"
Assistant: "Creating a comprehensive test dataset with realistic user information."
[AI generates structured data through Excel MCP]
Result: "✅ Test data spreadsheet ready! Download: test_users.xlsx"
- 100 rows of realistic data
- Proper data types and validation
- Exportable for testing frameworks
- Includes edge cases and variations📊 分析师场景
User: "Create a dashboard spreadsheet showing KPI trends with charts"
Assistant: "I'll build a professional KPI dashboard with multiple chart types."
[AI creates advanced Excel with charts]
Result: "✅ KPI Dashboard created! Download: kpi_dashboard.xlsx"
- Multiple chart types (bar, line, pie)
- Trend analysis calculations
- Professional styling
- Interactive filters______________________________________________________________________
🎯 支持的AI模型
| 模型 | 状态 | 集成 |
|---|---|---|
| 🦙 Llama 3.1 | ✅ 已测试 | 原生MCP支持 |
| 🦙 拉玛3 | ✅ 兼容 | 完全协议支持 |
| 🤖 GPT-4 | ✅ 兼容 | 工具调用支持 |
| 🎭 克劳德 | ✅ 兼容 | 函数调用 |
| 🔄 双子座 | ✅ 兼容 | 工具集成 |
| 🌟 任何MCP | ✅ 兼容 | 符合协议 |
______________________________________________________________________
🌟 用户评价
💬 用户在说什么
“这改变了我处理数据的方式!我不再花几个小时在Excel中,而是描述我需要什么,并立即获得专业的电子表格。” — *Sarah Chen,数据分析师*
“图表生成令人难以置信。我的报告一夜之间从基本表格变成了专业仪表板!” — *Mike Rodriguez,销售经理*
“作为一名开发人员,将其集成到我们的工作流程中是无缝的。API很干净,Docker部署也很完美。” — *Alex Kumar,软件工程师*
“我的团队从Excel新手到创建复杂的报告。人工智能指导让每个人都能立即高效工作。” — *詹妮弗·沃尔什,团队负责人*
______________________________________________________________________
🧪 测试和质量保证
🧪 综合测试套件
 
涵盖所有功能的23个不同测试场景!
🎯 测试类别
| 类别 | 测试 | 状态 |
|---|---|---|
| 📊 基础Excel | 文件创建、数据类型、格式 | ✅ 100%通过 |
| 📈 图表 | 条形图、折线图、饼图、散点图 | ✅ 100%通过 |
| 🔄 CSV集成 | 导入/导出功能 | ✅ 100%通过 |
| 🔒 安全 | 输入验证、路径遍历 | ✅ 100%通过 |
| 🌐 API | REST端点,错误处理 | ✅ 100%通过 |
| 🤖 AI集成 | 打开WebUI,调用工具 | ✅ 100%通过 |
🚀 快速测试命令
# 🧪 Run all tests
python -m pytest tests/ -v
# 🔍 Test specific functionality
python tests/test_core.py # Core Excel features
python tests/test_mcp.py # MCP protocol
python tests/test_openwebui.py # AI integration
# 🌐 Test API endpoints
curl -X POST http://localhost:9080/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list"}'
# 📊 Test file generation
curl -X POST http://localhost:9080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create_excel_file",
"arguments": {
"filename": "test.xlsx",
"headers": ["Test"],
"sheet_data": [["Success"]]
}
}
}'______________________________________________________________________
📊 绩效和基准
⚡ 速度基准
| 操作 | 时间 | 状态 |
|---|---|---|
| 简单电子表格(10行) | \ B[Create Feature Branch] |
B --> C[Make Changes] C --> D[Add Tests] D --> E[Update Documentation] E --> F[Commit Changes] F --> G[Push Branch] G --> H[Open Pull Request] H --> I[Code Review] I --> J[Merge to Main]
### 🎯 **添加新功能**
1. **定义** 工具在 `src/main.py`
1. **添加** 验证和错误处理
1. **创建** 综合测试
1. **更新** 文档
1. **测试** 具有多种AI模型
______________________________________________________________________
## 📄 **许可证和法律**
[](https://opensource.org/licenses/MIT)
**该项目根据麻省理工学院许可证获得许可**
**版权所有©2024 Excel MCP集成**
*特此免费授予任何获得本软件和相关文档文件(“软件”)副本的人不受限制地处理软件的权限,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利。..*
[📖 **完整许可证文本**](https://github.com/antuelle78/excel-mcp-integration/blob/main/LICENSE)
______________________________________________________________________
## 📞 **支持与社区**
### 🆘 **需要帮助?**
](https://github.com/antuelle78/excel-mcp-integration/issues)
[](https://github.com/antuelle78/excel-mcp-integration/discussions)
**获得支持的方法:**
1. **📖 检查** 这 [文档](https://github.com/antuelle78/excel-mcp-integration/tree/main/docs) 第一
1. **🔍 搜索** 现有的 [问题](https://github.com/antuelle78/excel-mcp-integration/issues)
1. **💬 开始** 一 [讨论](https://github.com/antuelle78/excel-mcp-integration/discussions)
1. **🐛 报告** 具有详细复制步骤的错误
### 📊 **项目统计**
______________________________________________________________________
## 🎉 **准备好改变你的工作流程了吗?**
**加入AI驱动的Excel创建革命!** 🚀
[](#-quick-start-guide)
](https://hub.docker.com/r/antuelle78/excel-mcp-integration)
](https://github.com/antuelle78/excel-mcp-integration)
______________________________________________________________________
**由...制作❤️ Excel MCP社区**
*将自然语言转换为专业电子表格,一次一个AI请求。*