OCP查看器MCP服务器

一个MCP(模型上下文协议)服务器,用于从OCP CAD查看器捕获屏幕截图,使AI助手能够“看到”3D CAD模型。

  • by dmilad
  • Python
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 dmilad/ocp-viewer-mcp

使用说明

OCP查看器MCP服务器

MCP(模型上下文协议)服务器,用于从 OCP CAD查看器,允许AI助手像 光标 “查看”您的3D CAD模型。

它做什么

使用CAD工具时,例如 CadQuery 或 建筑123d,您可以使用以下命令在OCP CAD查看器中显示模型 show()此MCP服务器允许您请求AI助手捕获当前显示的内容,从而实现视觉反馈和AI辅助的CAD开发。

工作流程示例:

  1. 您正在使用CadQuery在Jupyter笔记本中设计一个零件
  2. 你跑 show(my_part) 在OCP查看器中显示它
  3. 你问AI: “捕获当前视图-此几何图形看起来正确吗?”
  4. AI捕捉屏幕截图,并可以直观地分析3D模型

安装

pip install ocp-viewer-mcp

要求:

配置

光标

添加到您的 ~/.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"]
    }
  }
}

用法

  1. 打开 游标或VS代码中的CadQuery/Build123d项目
  2. 开始 OCP CAD查看器(Cmd+Shift+P→ “OCP CAD查看器:打开查看器”)
  3. 显示 模型使用 show(your_model) 在笔记本或脚本中
  4. 问 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

贡献

欢迎投稿!请先打开一个问题,讨论您想更改的内容。

许可证

麻省理工学院

相关项目