Microsoft Office MCP服务器
此存储库包含模型上下文协议(MCP)服务器,用于通过人工智能辅助与Microsoft Office应用程序进行交互。当前支持的应用程序:
- PowerPoint:创建和操作演示文稿
- Excel:与工作簿和电子表格交互
两台服务器都使用 pywin32 用于COM自动化,允许与正在运行的Office应用程序直接交互。
先决条件
- Windows操作系统
- 已安装Microsoft Office(PowerPoint和/或Excel)
- Python 3.7+
pywin32包裹
安装
- 克隆存储库:
git clone https://github.com/jenstangen1/mcp-pptx.git
cd mcp-pptx- 使用安装依赖项
uv:
uv pip install pywin32- 跑吧
pywin32具有管理员权限的安装后脚本:
python C:\path\to\your\env\Scripts\pywin32_postinstall.py -install与克劳德建立关系
要将这些MCP服务器与Claude集成,请将以下配置添加到您的Claude Desktop应用程序设置中:
{
"mcpServers": {
"powerpoint_mcp_win32": {
"command": "uv",
"args": [
"run",
"mcp_powerpoint_server_win32.py"
],
"cwd": "C:\\path\\to\\your\\workspace"
},
"excel_mcp_win32": {
"command": "uv",
"args": [
"run",
"mcp_excel_server_win32.py"
],
"cwd": "C:\\path\\to\\your\\workspace"
}
}
}注:更换 C:\\path\\to\\your\\workspace 使用您的实际工作空间路径。
PowerPoint MCP服务器
PowerPoint服务器为人工智能模型提供了一个全面的API,以与PowerPoint演示文稿交互,支持高级格式、财务图表和数据集成。
特性
展示管理
- 创建和修改PowerPoint演示文稿
- 添加、删除和修改幻灯片
- 从工作区保存和加载演示文稿
- 模板管理系统
元素操作
- 对幻灯片元素(文本、形状、图像、图表)进行细粒度控制
- 先进的形状创建和造型
- 元素定位和分组
- 形状之间的连接线
金融一体化
- 创建财务图表(折线图、条形图、柱状图、饼图、瀑布图等)
- 生成比较表
- 支持各种财务指标:
- 收入 - EBITDA - 利润 - 资产 - 股权 - 增长率 - 边距
- 目前使用伪数据,计划为挪威公司数据集成Proff API
- 可通过API定制来适应其他金融数据提供商
样式和格式
- 富文本格式
- 形状样式(填充、渐变、轮廓)
- 图表定制
- 背景颜色和效果
注意:您可能需要修改目录路径以匹配您的安装位置。
可用的MCP工具
展示管理
list_presentations:列出工作区中的所有PowerPoint文件upload_presentation:将新演示文稿上载到工作区save_presentation:保存当前演示文稿
滑动操作
add_slide:在演示文稿中添加新幻灯片delete_slide:从演示文稿中删除幻灯片get_slide_count:获取演示文稿中的幻灯片总数analyze_slide:分析幻灯片的内容set_background_color:设置幻灯片的背景颜色
元素操作
add_text:向幻灯片添加文本add_shape:向幻灯片添加形状edit_element:编辑元素的属性style_element:将样式应用于元素connect_shapes:使用连接器连接两个形状find_element:根据标准查找幻灯片上的元素
金融工具
get_company_financials:获取公司的财务数据(目前返回虚拟数据)create_financial_chart:在幻灯片上创建财务图表create_comparison_table:为公司创建比较表
注: 金融工具目前使用虚拟数据。未来的版本计划与Proff API集成,以自动获取挪威公司的数据。用户可以修改代码以连接到本地或首选的金融数据提供商。
模板操作
list_templates:列出所有可用模板apply_template:将模板应用于演示文稿create_slide_from_template:从模板创建新幻灯片save_as_template:将幻灯片另存为模板
调试工具
debug_element_mappings:调试工具,用于检查幻灯片的元素映射
用法
与克劳德互动
在Claude Desktop应用程序中配置MCP服务器后,您可以通过自然语言命令与PowerPoint和Excel进行交互。以下是一些示例:
PowerPoint示例
You: Create a new slide with a title "Market Analysis" and add a bar chart showing revenue growth.
Claude: I'll help you create that slide with the title and chart. I'll:
1. Add a new slide
2. Add the title text
3. Create a revenue chart
[Claude will then use the MCP tools in sequence:
- add_slide
- add_text
- create_financial_chart]
You: Make the title bigger and change its color to blue.
Claude: I'll modify the title's formatting.
[Claude will use:
- find_element (to locate the title)
- edit_element (to update the formatting)]
You: Add a comparison table below the chart comparing three companies.
Claude: I'll add a comparison table below the existing chart.
[Claude will use:
- create_comparison_table]Excel示例
You: Open the Q4 report and show me the revenue numbers from cells B2 to B5.
Claude: I'll help you retrieve those revenue figures.
[Claude will use:
- list_open_workbooks (to find the workbook)
- get_range_values (to read the specified cells)]
You: Calculate the sum of these numbers and put it in cell B6.
Claude: I'll calculate the sum and write it to B6.
[Claude will use:
- get_range_values (to get the numbers)
- set_cell_value (to write the sum)]
You: Create a new sheet called "Summary" and copy these values there.
Claude: I'll create a new sheet and copy the data.
[Claude will use:
- add_worksheet
- get_range_values (from source)
- set_range_values (to destination)]运作原理
- 自然语言理解
- 克劳德解释你的请求,并将其分解为具体的行动 - 它从之前的交互中理解上下文 - 它可以处理复杂的多步骤操作
- 工具选择
- Claude会自动为每个任务选择合适的MCP工具 - 它可以将多个工具连接在一起进行复杂的操作 - 它处理错误情况并提供反馈
- 上下文管理
- Claude维护了以下内容的上下文: - 当前打开的文件 - 最近的行动 - 选定元素 - 用户偏好
- 错误处理
- 如果操作失败,Claude将: - 解释出了什么问题 - 建议替代方案 - 帮助解决常见问题
最佳实践
- 具体
- 相关时提及幻灯片编号 - 在Excel中指定精确的单元格范围 - 清楚地描述所需的格式
- 复杂操作
- 将复杂的请求分解为步骤 - 确认中间结果 - 根据需要要求调整
- 故障排除
- 确保PowerPoint/Excel正在运行 - 检查文件权限 - 验证COM自动化是否正常工作 - 如果需要,运行pywin32_postinstall.py
示例工作流
创建财务演示文稿
You: Create a new presentation about Q4 financial results.
Claude: I'll create a new presentation with a title slide.
You: Add revenue charts for the last 4 quarters.
Claude: I'll create a new slide with a chart showing quarterly revenue.
You: Now add a comparison with our competitors.
Claude: I'll add a comparison table with key metrics for you and competitors.分析Excel数据
You: Show me all sheets in the Q4 analysis workbook.
Claude: I'll list all worksheets in that workbook.
You: Find the highest revenue value in column B.
Claude: I'll scan column B and find the maximum value.
You: Create a summary of the top 5 values.
Claude: I'll create a new sheet with the top 5 revenue figures.目录结构
pptx-mcp/
├── mcp_powerpoint_server.py # Main server implementation
├── requirements.txt # Python dependencies
├── presentations/ # Workspace for presentations
│ └── templates/ # Template storage
└── README.md # This file依赖项
- python-pptx:PowerPoint文件操作
- 枕头:图像处理
- numpy:数值运算
- MCP SDK:模型上下文协议实现
贡献
欢迎投稿!请随时提交拉取请求。
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
Excel MCP服务器
Excel服务器提供了通过AI辅助与Excel工作簿、工作表和单元格数据交互的工具。
特性
工作簿管理
- 连接到正在运行的Excel实例
- 列出打开的工作簿
- 以各种格式(.xlsx、.xlsm、.xlsb、.xls)保存工作簿
工作表操作
- 在工作簿中列出工作表
- 添加新工作表
- 按名称或索引访问工作表
单元和靶场操作
- 读取和写入单个单元格值
- 获取和设置单元格范围的值
- 处理各种数据类型(文本、数字、日期、货币)
- 日期和货币值的自动类型转换
可用的MCP工具
工作簿管理
list_open_workbooks:列出当前打开的所有Excel工作簿save_workbook:使用可选格式选择将工作簿保存到磁盘
工作表操作
list_worksheets:列出工作簿中的所有工作表add_worksheet:向工作簿中添加新工作表get_worksheet:按名称或索引获取工作表
单元和靶场操作
get_cell_value:读取单个单元格的值set_cell_value:设置单个单元格的值get_range_values:从一系列单元格中读取值set_range_values:为一系列单元格设置值
备注
- 这两台服务器都需要安装Windows及其各自的Microsoft Office应用程序
- 服务器与 *跑步* 应用程序的实例
- COM自动化需要正确的初始化;如果遇到与COM相关的错误,请运行安装后脚本
- 为了更好地进行持续处理,请考虑使用
makepy生成Office常量
