OpenSCAD模型协议服务

OpenSCAD模型协议服务是一个为AI助手提供创建和操作3D CAD模型功能的服务器,支持渲染、预览、验证和获取OpenSCAD信息。

  • by dkpoulsen
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 dkpoulsen/openscad-mcp

使用说明

OpenSCAD MCP服务器

OpenSCAD的模型上下文协议(MCP)服务器使AI助手能够创建和操作3D CAD模型。

特性

  • 渲染:将OpenSCAD代码编译为3D网格格式(STL、OFF、AMF、3MF、CSG)
  • 预览:使用相机控件生成2D预览(PNG、SVG、DXF、PDF)
  • 验证:检查OpenSCAD语法而不生成输出
  • 信息:获取OpenSCAD安装信息

先决条件

  • Node.js 18或更高版本
  • OpenSCAD 安装在您的系统上

安装

通过npm(推荐)

npm install -g openscad-mcp

源自源头

# Clone the repository
git clone https://github.com/dkpoulsen/openscad-mcp.git
cd openscad-mcp

# Install dependencies and build
npm install
npm run build

使用Claude Desktop

添加到您的Claude Desktop配置中:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

视窗: %APPDATA%\Claude\claude_desktop_config.json

Linux: ~/.config/Claude/claude_desktop_config.json

使用npx(安装npm后)

{
  "mcpServers": {
    "openscad": {
      "command": "npx",
      "args": ["-y", "openscad-mcp"]
    }
  }
}

使用本地构建

{
  "mcpServers": {
    "openscad": {
      "command": "node",
      "args": ["/path/to/openscad-mcp/dist/index.js"]
    }
  }
}

工具

渲染

将OpenSCAD代码编译为3D网格格式。

参数:

  • scad (字符串,必填):要编译的OpenSCAD代码
  • format (字符串,默认值:“stl”):输出格式- stl, off, amf, 3mf,或 csg
  • parameters (object,可选):要传递的变量-D标志
  • exportFormat (字符串,可选):用于STL- asciistl 或 binstl
  • hardwarnings (boolean,默认值:true):将警告视为错误

预览

生成二维预览或矢量导出。

参数:

  • scad (字符串,必填):要预览的OpenSCAD代码
  • format (字符串,默认值:“png”):输出格式- png, svg, dxf,或 pdf
  • width (数字,默认值:800):图像宽度(像素)
  • height (数字,默认值:600):图像高度(像素)
  • camera (字符串,可选):摄像头位置
  • colorscheme (字符串,默认值:“Cornfield”):配色方案
  • projection (字符串,默认值:“透视图”): ortho 或 perspective
  • autocenter (boolean,默认值:true):将设计居中
  • viewall (boolean,默认值:true):在视图中适应整个设计
  • render (boolean,默认值:false):使用完整的CGAL渲染

验证

验证OpenSCAD语法。

参数:

  • scad (字符串,必填):要验证的OpenSCAD代码
  • parameters (对象,可选):要定义的变量

信息

获取OpenSCAD安装信息。

AI助手使用示例

User: Create a simple 10x10x10 cube in OpenSCAD and render it to STL

AI: I'll create a cube and render it for you.

[Uses render tool with:]
scad: cube([10, 10, 10]);
format: stl

配色方案

PNG导出的可用配色方案:

  • 玉米田(默认)
  • 金属的
  • 日落
  • 斯达耐
  • 黎明前
  • 自然
  • 日光宝石
  • 夜行宝石
  • 深海
  • 日光化
  • 明天
  • 明晚
  • ClearSky
  • 单调

许可证

麻省理工学院