Skip to main content
Glama
kyle-nelson-berkeley

onshape-mcp

onshape-mcp

MCP 服务器,通过 Claude Code 驱动 OnShape CAD:参数化建模(草图、拉伸、旋转、圆角、阵列)、FeatureScript 查询,以及 STL 导出/验证——均通过 OnShape REST API 完成。

一次性配置

uv sync --no-editable
uv run --no-editable onshape-mcp setup    # writes ~/.config/onshape-mcp/.env (chmod 600); no-op if it exists
uv run --no-editable onshape-mcp doctor   # auth smoke test against the live API (4 calls)

为什么处处使用 --no-editable macOS 会异步地将 .venv 下的文件标记为 hidden 标志,而 Python ≥3.13.8 会跳过隐藏的 .pth 文件——因此,可编辑安装在同步后的几分钟内会静默地停止导入。非可编辑安装不使用 .pth,所以不受影响。

Related MCP server: MCP 3D Printer Server

凭据

API 密钥来自 https://dev-portal.onshape.com/keys(一个访问密钥与一个机密密钥配对)。凭据存放在 ~/.config/onshape-mcp/.env 中,由 onshape-mcp setup 创建,权限为 600(仅属主可读/写)——绝不放在项目文件夹中,绝不提交,绝不打印。变量名参见 .env.example;如果环境变量和文件同时存在,则进程环境变量(ONSHAPE_ACCESS_KEY / ONSHAPE_SECRET_KEY)优先于文件。

按项目注册

如果你希望该服务器可用的 CAD 项目文件夹中(将 /path/to/onshape-mcp 替换为你克隆此仓库的位置):

/path/to/onshape-mcp/install.sh

或等效地:

claude mcp add --scope project onshape -- \
  uv run --quiet --no-editable --project /path/to/onshape-mcp onshape-mcp

也可以手动在项目的 .mcp.json 中注册:

{
  "mcpServers": {
    "onshape": {
      "command": "uv",
      "args": ["run", "--quiet", "--no-editable", "--project", "/path/to/onshape-mcp", "onshape-mcp"]
    }
  }
}

--project,不是 --directory:服务器会解析此仓库的 venv,但保留调用方的当前工作目录。文件路径工具参数应始终使用绝对路径。)

项目级服务器在首次交互式会话中会显示 "Pending approval"——按提示批准即可。

用法速查表(供使用工具的 LLM 参考)

典型构建流程

create_document (parentId = folder id)   -> documentId, workspaceId, partStudioElementId
import_cad (ABSOLUTE path to .zip/STEP)  -> foreign CAD into an existing workspace [async, +quota]
set_variable (optional, e.g. wall_thk)   -> use "#wall_thk" in later expressions
create_sketch (plane {"default":"TOP"})  -> featureId            [one closed profile per sketch]
extrude (sketchFeatureId, NEW, depth)    -> base solid
create_sketch + extrude REMOVE THROUGH_ALL                       [holes: skip native hole feature]
find_entities (EDGE, radiusBetween)      -> transient ids for fillet/chamfer
fillet_or_chamfer (entityIds)            -> check featureStatus == OK after EVERY feature
pattern / revolve / boolean_parts as needed
export_stl (ABSOLUTE path)               -> compare_stl(candidate, reference)  [mesh: 3D-print, verify]
export_step (ABSOLUTE path)              -> editable STEP B-rep solid           [CAD/prototyping; async, +quota]

铁律

  1. 瞬态 ID 会在任何修改之后失效。 始终在最终的这些 ID 的工具调用之前先调用 find_entities。特征 ID(来自 create_sketch/extrude/...)是稳定的——在可接受的地方优先使用它们(拉伸区域、阵列源、布尔实体)。

  2. 单位:工具参数和输出默认为英寸(使用 units 参数更改)。尺寸字符串原样传递:"1.53 in""25 mm""#wall_thk * 2"。角度使用度。eval_featurescript 的原始结果是米/弧度。

  3. featureStatus 是实体生成反馈循环:OK 即可继续;ERROR 表示特征已添加但失败——通过 update_featuredelete_feature 修复参数并重试。每次建模调用后均检查它。

  4. extrude REMOVE 会从 studio 中的全部实体(defaultScope)中减去, 除非是你有意而为,否则每个 studio 保持一个实体。

  5. 每个草图只保留一个闭合轮廓,这样拉伸区域的选择就不会有歧义。

  6. 文件路径必须是绝对路径(服务器的当前工作目录不是项目的)。

  7. 要节约:每年约 2,500 次 API 调用。不要轮询,不要无谓地重复列取;analyze_stl/compare_stl 不消耗调用。

配额警告

OnShape EDU/免费账户有年度 API 配额(约 2,500 次调用/用户/年);配额用完会返回 402,退避无法解决。该服务器在 ~/.config/onshape-mcp/call_log 中维护一个持久的调用计数器,并将累计总数记录到 stderr。在 OnShape 中,可在 My Account → Developer 下监控使用情况。

开发

uv run --no-editable pytest          # offline tests (no API calls, no credentials needed)
uv run --no-editable onshape-mcp doctor

许可证

MIT —— 参见 LICENSE

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    A
    quality
    D
    maintenance
    Enables programmatic CAD modeling with Onshape's REST API, offering 45 tools for parametric sketches, feature management, assemblies, analysis, variables, and exports.
    45
    126
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables users to connect Claude with various 3D printer management systems, allowing tasks like printer status monitoring, file management, print job control, and STL file manipulation.
    103
    GPL 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables Claude to create 3D-printable CAD models using build123d, with tools for modeling, modification, analysis, and publishing to platforms like Thingiverse and GitHub.
    11
    Creative Commons Attribution Non Commercial No Derivatives 4.0 International

View all related MCP servers

Related MCP Connectors

  • WHOOP recovery, strain, sleep and workouts in Claude via official WHOOP OAuth. Free, open source.

  • Read, edit, publish, and preview your pepita websites from Claude.

  • Connect Claude to Fathom meeting recordings, transcripts, and summaries

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kyle-nelson-berkeley/onshape-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server