OCP查看器MCP服务器
](https://badge.fury.io/py/ocp-viewer-mcp) 
它做什么
工作流程示例:
- 您正在使用CadQuery在Jupyter笔记本中设计一个零件
- 你跑
show(my_part)在OCP查看器中显示它 - 你问AI: *“捕获当前视图-此几何图形看起来正确吗?”*
- AI捕捉屏幕截图,并可以直观地分析3D模型
安装
pip install ocp-viewer-mcp要求:
- Python 3.10+
- OCP CAD查看器 VS代码/光标扩展名
- ocp vscode Python包(用于
show()功能)
配置
光标
添加到您的 ~/.cursor/mcp.json:
{
"mcpServers": {
"ocp-viewer": {
"command": "python",
"args": ["-m", "ocp_viewer_mcp.server"]
}
}
}如果你使用的是虚拟环境(推荐),请指定完整的Python路径:
{
"mcpServers": {
"ocp-viewer": {
"command": "/path/to/your/venv/bin/python",
"args": ["-m", "ocp_viewer_mcp.server"]
}
}
}克劳德桌面
添加到您的Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"ocp-viewer": {
"command": "python",
"args": ["-m", "ocp_viewer_mcp.server"]
}
}
}用法
- 打开 游标或VS代码中的CadQuery/Build123d项目
- 开始 OCP CAD查看器(Cmd+Shift+P→ “OCP CAD查看器:打开查看器”)
- 显示 模型使用
show(your_model)在笔记本或脚本中 - 问 AI捕捉视图:
- “捕获当前OCP视图” - “让我看看模型是什么样子的” - “截取CAD查看器的屏幕截图”
工具参考
capture_ocp_screenshot
捕获OCP CAD查看器的屏幕截图。
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
port | integer | 3939 | 运行OCP查看器的端口 |
wait_ms | integer | 1000 | 等待渲染的毫秒数 |
退货: 以base64编码图像的PNG屏幕截图。
故障排除
“无法连接到OCP查看器”
- 确保OCP CAD查看器在VS代码/光标中打开
- 检查查看器后端是否正在运行(在终端中查找“查看器后端已启动”)
- 验证端口(默认为3939)
“ocp_vcode未安装”
MCP服务器需要 ocp-vscode 安装在同一Python环境中:
pip install ocp-vscode屏幕截图未捕获
- 确保显示模型(运行
show(something)第一) - 尝试增加
wait_ms如果模型很复杂
发展
# Clone the repo
git clone https://github.com/dmilad/ocp-viewer-mcp.git
cd ocp-viewer-mcp
# Install with Poetry
poetry install
# Run locally
poetry run python -m ocp_viewer_mcp.server贡献
欢迎投稿!请先打开一个问题,讨论您想更改的内容。
许可证
相关项目
- OCP CAD查看器 -此MCP服务器集成的VS Code扩展
- CadQuery -Python参数化CAD脚本
- 建筑123d -使用构建器模式的Python CAD脚本
- 主控程序 -模型上下文协议规范
