solidcraft

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SolidCraft

SolidCraft

Operate SolidCraft (an open-source parametric CAD app in Rust: desktop, web, headless CLI, MCP) through its structured automation interface. Preserve the user's requested modelling workflow and target design.
通过结构化自动化接口操作 SolidCraft(一个用 Rust 编写的开源参数化 CAD 应用,支持桌面端、Web 端、无头 CLI 和 MCP)。遵循用户指定的建模工作流和目标设计。

Protocol reference

协议参考

Read the relevant sections of references/control-protocol.md before constructing calls, and references/mcp.md for the MCP tool surface. These are downloaded upstream docs, captured from upstream
main
on 2026-11-02 for SolidCraft 0.30.x; upstream lives at github.com/tangency-labs/solidcraft (
docs/
). Relative links inside them (e.g.
render-jobs.md
,
scripts.md
) resolve against
https://github.com/tangency-labs/solidcraft/blob/main/docs/
;
render-jobs.md
and
scripts.md
are also in
references/
. The protocol lists methods, not individual modelling commands: discover those at runtime instead of inventing command IDs or parameters.
构建调用前,请阅读 references/control-protocol.md 的相关章节,并阅读 references/mcp.md 以了解 MCP 工具接口。这些是从上游下载的文档,捕获自 2026-11-02 的上游
main
分支,对应 SolidCraft 0.30.x;上游仓库位于 github.com/tangency-labs/solidcraft(
docs/
)。其中的相对链接(例如
render-jobs.md
、
scripts.md
)基于 https://github.com/tangency-labs/solidcraft/blob/main/docs/ 解析;
render-jobs.md
和
scripts.md
也位于
references/
中。该协议列出的是方法,而不是单独的建模命令:应在运行时发现这些命令,不要臆造命令 ID 或参数。

Locate the executables

定位可执行文件

solidcraft
and
solidcraft-cli
are usually not on
PATH
even when the app is installed. Discover them, never guess a path:
  1. PATH:
    command -v solidcraft solidcraft-cli
    (POSIX) or
    where solidcraft solidcraft-cli
    (Windows).
  2. macOS:
    mdfind -name SolidCraft.app
    ; the binaries are
    /Applications/SolidCraft.app/Contents/MacOS/SolidCraft
    and
    .../solidcraft-cli
    (both ship in the same bundle).
  3. Linux: the AppImage,
    /snap/bin/solidcraft
    , or the shortcut's target.
  4. Nothing to install to drive it. The control port is plain line-delimited JSON over loopback TCP;
    scripts/sc.py
    is a small dependency-free wrapper, and any language that opens a socket works.
    solidcraft-cli
    is only needed for the MCP bridge and headless runs.
即使应用已安装,
solidcraft
和
solidcraft-cli
通常也不在
PATH
中。请务必先发现其位置,不要猜测路径:
  1. PATH:
    command -v solidcraft solidcraft-cli
    (POSIX)或
    where solidcraft solidcraft-cli
    (Windows)。
  2. macOS:
    mdfind -name SolidCraft.app
    ;可执行文件为
    /Applications/SolidCraft.app/Contents/MacOS/SolidCraft
    和
    .../solidcraft-cli
    (二者都位于同一个应用包中)。
  3. Linux: AppImage、
    /snap/bin/solidcraft
    ,或快捷方式的目标路径。
  4. 驱动它无需安装任何额外组件。 控制端口通过回环 TCP 传输按行分隔的 JSON;
    scripts/sc.py
    是一个无依赖的小型包装器,任何能够打开 socket 的语言都可以使用它。只有 MCP 桥接和无头运行时才需要
    solidcraft-cli
    。

Start and select a session

启动并选择会话

  • Watchable session (default choice): start the desktop app with a control port, then drive that live window so the user sees the model appear.
    sh
    SOLIDCRAFT_CONTROL_PORT=7878 /Applications/SolidCraft.app/Contents/MacOS/SolidCraft >/tmp/solidcraft.log 2>&1 &
  • Bridged MCP for an MCP-capable client:
    solidcraft-cli mcp --connect 127.0.0.1:7878
    (tools:
    execute
    ,
    batch
    ,
    inspect_design
    ,
    measure
    ,
    body_topology
    ,
    set_parameter
    ,
    check_parameters
    ,
    screenshot
    ,
    compare_picture
    ,
    export
    ,
    open
    ,
    save
    ,
    new_design
    ,
    undo
    ,
    redo
    ,
    list_commands
    ,
    describe_command
    ,
    pending
    ,
    running
    ,
    crash_reports
    ,
    skill_reference
    ).
  • Headless (
    solidcraft-cli mcp
    with no
    --connect
    , or
    solidcraft-cli run script.json
    ) has its own in-process design and cannot touch the user's open window. Use it for unattended file processing.
Reuse a running instance when one exists (
pgrep -lf SolidCraft
) and keep the channel on loopback.
Authentication: each launch mints a random token and writes it, hex, to a
0600
file the app removes on exit — macOS
~/Library/Application Support/SolidCraft/control/PORT.token
, Linux
$XDG_DATA_HOME/solidcraft/control/PORT.token
, Windows
%LOCALAPPDATA%\SolidCraft\control\PORT.token
. Send it as a top-level
"token"
on the first request of a connection; later requests may omit it. A wrong or missing token answers
unauthorized
and closes. Set
SOLIDCRAFT_CONTROL_TOKEN
(≥32 hex chars) to pin one; prefer the variable over
--token
, which other users can see in the process list.
  • 可观察会话(默认选择): 使用控制端口启动桌面应用,然后驱动这个实时窗口,让用户看到模型的创建过程。
    sh
    SOLIDCRAFT_CONTROL_PORT=7878 /Applications/SolidCraft.app/Contents/MacOS/SolidCraft >/tmp/solidcraft.log 2>&1 &
  • MCP 桥接:适用于支持 MCP 的客户端;执行
    solidcraft-cli mcp --connect 127.0.0.1:7878
    (工具包括:
    execute
    、
    batch
    、
    inspect_design
    、
    measure
    、
    body_topology
    、
    set_parameter
    、
    check_parameters
    、
    screenshot
    、
    compare_picture
    、
    export
    、
    open
    、
    save
    、
    new_design
    、
    undo
    、
    redo
    、
    list_commands
    、
    describe_command
    、
    pending
    、
    running
    、
    crash_reports
    、
    skill_reference
    )。
  • 无头模式(不带
    --connect
    的
    solidcraft-cli mcp
    ,或
    solidcraft-cli run script.json
    )拥有独立的进程内设计,无法操作用户已打开的窗口。适用于无人值守的文件处理。
如果已有实例正在运行(
pgrep -lf SolidCraft
),应复用该实例,并确保通信通道使用回环地址。
身份验证: 每次启动都会生成一个随机 token,以十六进制形式写入权限为
0600
的文件;应用退出时会删除该文件。文件位置为:macOS 的
~/Library/Application Support/SolidCraft/control/PORT.token
、Linux 的
$XDG_DATA_HOME/solidcraft/control/PORT.token
、Windows 的
%LOCALAPPDATA%\SolidCraft\control\PORT.token
。在连接的首个请求中,将 token 作为顶层
token
字段发送;后续请求可以省略。token 错误或缺失会返回
unauthorized
并关闭连接。可设置
SOLIDCRAFT_CONTROL_TOKEN
(至少 32 个十六进制字符)来固定 token;应优先使用环境变量,而不是其他用户可在进程列表中看到的
--token
参数。

Discover commands before using them

使用前发现命令

engine.commands
(or
solidcraft-cli commands
, or MCP
list_commands
) gives every command's id, label, tab, panel, shortcut, parameter docs and whether it is enabled right now;
describe_command
/
engine.describe {command}
gives one command's parameter doc and JSON Schemas when it has a typed contract. The command families:
  • sketch.*
    —
    create
    ,
    line
    ,
    circle.center
    ,
    rectangle.two_point
    ,
    arc.three_point
    ,
    spline.fit_point
    ,
    slot.center_point
    ,
    polygon.*
    ,
    text
    ,
    point
    ,
    construction
    ,
    dimension
    ,
    constraint.concentric
    (and the other
    constraint.*
    relations),
    trim
    ,
    fillet
    ,
    chamfer.*
    ,
    mirror
    ,
    pattern.rectangular
    ,
    pattern.circular
    ,
    solve
    ,
    inspect
    ,
    finish
    .
  • solid.*
    — features
    extrude
    ,
    revolve
    ,
    sweep
    ,
    loft
    ,
    fillet
    ,
    chamfer
    ,
    shell
    ,
    draft
    ,
    hole
    ,
    thread
    ,
    coil
    ,
    rib
    ,
    web
    ,
    press_pull
    ,
    pipe
    ,
    emboss
    ,
    boundary_fill
    ,
    offset_face
    ,
    replace_face
    ,
    split_body
    ,
    split_face
    ,
    combine
    ,
    remove
    ,
    move
    ,
    scale
    ,
    mirror
    ,
    align
    ; patterns
    pattern.rectangular
    ,
    pattern.circular
    ,
    pattern.path
    ; direct primitives
    box
    ,
    cylinder
    ,
    sphere
    ,
    torus
    ,
    bounding_solid
    (each takes an
    operation
    of
    new
    /
    cut
    /
    join
    ).
  • face.*
    ,
    body.*
    ,
    sheet.*
    (flange, hem, fold, unfold, flat pattern,
    convert
    ),
    assembly.*
    /
    joint.*
    /
    contact.*
    /
    motion.*
    /
    explode.*
    ,
    parameters.*
    ,
    config.*
    ,
    timeline.*
    ,
    construct.*
    (planes, axes),
    surface.*
    ,
    mesh.*
    ,
    material.*
    /
    appearance.*
    ,
    document.*
    /
    doc.*
    /
    file.*
    ,
    view.*
    ,
    browser.*
    ,
    select.*
    /
    selection.*
    ,
    inspect.*
    (
    measure
    ,
    section
    ,
    interference
    ,
    clearance
    ,
    draft
    ,
    curvature_map
    ,
    center_of_mass
    ,
    minimum_radius
    ),
    render.*
    ,
    edit.*
    (
    undo
    ,
    redo
    ,
    checkpoint
    ,
    restore_checkpoint
    ),
    diagnostics.*
    .
engine.commands
(或
solidcraft-cli commands
,或 MCP
list_commands
)会提供每个命令的 id、标签、标签页、面板、快捷键、参数文档,以及当前是否可用;
describe_command
/
engine.describe {command}
会在命令具有类型化契约时提供其参数文档和 JSON Schema。命令族如下:
  • sketch.*
    —
    create
    、
    line
    、
    circle.center
    、
    rectangle.two_point
    、
    arc.three_point
    、
    spline.fit_point
    、
    slot.center_point
    、
    polygon.*
    、
    text
    、
    point
    、
    construction
    、
    dimension
    、
    constraint.concentric
    (以及其他
    constraint.*
    关系)、
    trim
    、
    fillet
    、
    chamfer.*
    、
    mirror
    、
    pattern.rectangular
    、
    pattern.circular
    、
    solve
    、
    inspect
    、
    finish
    。
  • solid.*
    — 特征:
    extrude
    、
    revolve
    、
    sweep
    、
    loft
    、
    fillet
    、
    chamfer
    、
    shell
    、
    draft
    、
    hole
    、
    thread
    、
    coil
    、
    rib
    、
    web
    、
    press_pull
    、
    pipe
    、
    emboss
    、
    boundary_fill
    、
    offset_face
    、
    replace_face
    、
    split_body
    、
    split_face
    、
    combine
    、
    remove
    、
    move
    、
    scale
    、
    mirror
    、
    align
    ;阵列:
    pattern.rectangular
    、
    pattern.circular
    、
    pattern.path
    ;直接基元:
    box
    、
    cylinder
    、
    sphere
    、
    torus
    、
    bounding_solid
    (每个基元都可将
    operation
    设为
    new
    /
    cut
    /
    join
    )。
  • face.*
    、
    body.*
    、
    sheet.*
    (flange、hem、fold、unfold、flat pattern、
    convert
    )、
    assembly.*
    /
    joint.*
    /
    contact.*
    /
    motion.*
    /
    explode.*
    、
    parameters.*
    、
    config.*
    、
    timeline.*
    、
    construct.*
    (平面、轴)、
    surface.*
    、
    mesh.*
    、
    material.*
    /
    appearance.*
    、
    document.*
    /
    doc.*
    /
    file.*
    、
    view.*
    、
    browser.*
    、
    select.*
    /
    selection.*
    、
    inspect.*
    (
    measure
    、
    section
    、
    interference
    、
    clearance
    、
    draft
    、
    curvature_map
    、
    center_of_mass
    、
    minimum_radius
    )、
    render.*
    、
    edit.*
    (
    undo
    、
    redo
    、
    checkpoint
    、
    restore_checkpoint
    )、
    diagnostics.*
    。

Inspect, edit, and verify

检查、编辑与验证

Inspect first:
document.inspect
for parameters, timeline (errors, warnings, timings), bodies, sketches, selection and undo depth;
ui.inspect
for the camera, active tool or dialog, status line, hover, and a pending file picker (
file_picker_busy
). The app may already hold a design you did not create.
Edit with
engine.execute {command, params}
(one command, never opens a dialog) or
engine.batch {commands, rollback}
— a batch runs in one frame, stops at the first failure, and restores an engine checkpoint, reporting
failed.index
/
failed.command
/
failed.error
. Batch refuses any step that loads a file (
doc.open
,
file.insert_step
,
file.insert_mesh
) and any step while the agent cursor is shown: send those one at a time.
Verify numerically, not by eye alone:
engine.execute inspect.measure {bodies?}
(volume mm³, area mm², centre of mass, bbox, face/edge/vertex counts, totals; MCP exposes the same as its
measure
tool),
body_topology
for the faces and edge midpoints to pick for fillets and chamfers, and
inspect.measure
with
items
for picked geometry (a cylindrical face reports
diameter
,
radius
,
center
,
axis
). Check a result against an analytic value before telling the user a part is correct.
To change an existing feature, read it with
engine.execute timeline.inspect {feature}
and write it back with
timeline.edit {feature, set}
(e.g.
{"extent": {"distance": "30"}}
) rather than rebuilding the part.
Sketch notes: every mutating
sketch.*
reply carries
created: {points, curves, constraints, dimensions}
with stable ids (
l1
,
c1
,
k1
) that go straight into later commands. A bare numeric
sketch.dimension
value
is read in the design's units, exactly as typed in the dimension box; pass
"50 mm"
or
"0.5 in"
to pin units. Point coordinates are always millimetres. Angles are degrees unless an expression says otherwise — except camera
yaw
/
pitch
/
roll
, which are radians, unlike
solid.move
's
angle
.
先进行检查:通过
document.inspect
获取参数、时间线(错误、警告、耗时)、实体、草图、选择状态和撤销深度;通过
ui.inspect
获取相机、当前工具或对话框、状态栏、悬停信息及待处理的文件选择器(
file_picker_busy
)。应用中可能已经存在一个并非由你创建的设计。
使用
engine.execute {command, params}
进行编辑(一次执行一个命令,且不会打开对话框),或使用
engine.batch {commands, rollback}
。批处理会在一帧内运行,在首次失败时停止,并恢复引擎检查点,同时报告
failed.index
/
failed.command
/
failed.error
。批处理拒绝执行任何加载文件的步骤(
doc.open
、
file.insert_step
、
file.insert_mesh
),也会拒绝在显示 Agent 光标时执行步骤:这些步骤必须逐个发送。
应进行数值验证,而不能只凭肉眼判断:通过
engine.execute inspect.measure {bodies?}
获取体积 mm³、面积 mm²、质心、边界框以及面、边、顶点的数量和总计(MCP 的
measure
工具提供相同功能);使用
body_topology
查看面和边中点,以选择适合进行 fillet 和 chamfer 的位置;使用带
items
的
inspect.measure
检查选定的几何对象(圆柱面会报告
diameter
、
radius
、
center
、
axis
)。在告知用户零件正确之前,应将结果与解析值进行比较。
要修改现有特征,请使用
engine.execute timeline.inspect {feature}
读取特征,再使用
timeline.edit {feature, set}
写回修改(例如
{"extent": {"distance": "30"}}
),而不是重新构建零件。
草图说明:每个会修改状态的
sketch.*
响应都会包含
created: {points, curves, constraints, dimensions}
,并提供可直接用于后续命令的稳定 id(
l1
、
c1
、
k1
)。
sketch.dimension
中仅包含数值的
value
会按照设计所用单位读取,与在尺寸框中输入的值完全一致;传入
"50 mm"
或
"0.5 in"
可明确指定单位。点坐标始终以毫米为单位。除非表达式另有说明,角度默认使用度数;但相机的
yaw
/
pitch
/
roll
使用弧度,这与
solid.move
的
angle
不同。

Watch the user's window, and take pictures

观察用户窗口并截图

ui.render {path, width?, height?, grid?, axes?}
draws the model with the app's GPU and needs no presented window — this is the reliable way to see the design.
ui.screenshot {path}
captures the window chrome and fails with
no frame was presented (window hidden?)
when the window is minimised, fully covered, or on another macOS Space; front it first (macOS:
osascript -e 'tell application "System Events" to set frontmost of (first process whose unix id is PID) to true'
) or just use
ui.render
.
ui.view {view, animate}
and
ui.camera {target, yaw, pitch, distance, fit}
move the viewport;
ui.worldToScreen
maps world points to pixels.
For real UI work (a dialog the engine cannot reach, or showing the user a workflow):
ui.handles
names toolbar buttons (
toolbar:<command id>
), tabs (
tab:Model
), panels and browser rows (
row:<label>
);
ui.click
/
ui.move
/
ui.drag
inject pointer input in screen points,
ui.key
/
ui.text
keyboard input,
ui.start {command, params}
opens a command's dialog,
ui.menuPick
,
ui.selection
,
ui.editFeature
and
ui.confirm
handle menus, dialog inputs, rollback-to-feature and delete confirmations. One pointer event per frame.
ui.agent_cursor {show: true}
makes
engine.execute
glide the pointer to each pick so the run reads like a person modelling.
ui.render {path, width?, height?, grid?, axes?}
使用应用的 GPU 绘制模型,无需呈现窗口,是查看设计的可靠方式。
ui.screenshot {path}
捕获窗口边框;当窗口已最小化、被完全遮挡或位于另一个 macOS Space 时,该命令会因
no frame was presented (window hidden?)
而失败。可以先将窗口置于前台(macOS:
osascript -e 'tell application "System Events" to set frontmost of (first process whose unix id is PID) to true'
),也可以直接使用
ui.render
。
ui.view {view, animate}
和
ui.camera {target, yaw, pitch, distance, fit}
用于移动视口;
ui.worldToScreen
将世界坐标点映射为像素坐标。
对于实际的 UI 操作(引擎无法访问的对话框,或向用户展示某个工作流):
ui.handles
可获取工具栏按钮(
toolbar:<command id>
)、标签页(
tab:Model
)、面板和浏览器行(
row:<label>
)的名称;
ui.click
/
ui.move
/
ui.drag
以屏幕坐标注入指针输入,
ui.key
/
ui.text
提供键盘输入;
ui.start {command, params}
打开命令对话框;
ui.menuPick
、
ui.selection
、
ui.editFeature
和
ui.confirm
分别处理菜单、对话框输入、回退到特征及删除确认。每帧只能发送一个指针事件。
ui.agent_cursor {show: true}
会让
engine.execute
将指针平滑移动到每个选取位置,使执行过程看起来像人在建模。

Files, export, and access rules

文件、导出与访问规则

file.new
,
doc.open {path}
,
file.save [path]
,
file.export {path, format}
(step, 3mf, 3mf-tagged, stl, stla, obj, urdf); STEP opens as an Import base feature, 3MF/STL as mesh bodies, and
up: "y"
stands a Y-up file upright. Report the exact path and format written. Do not overwrite the user's source design unless asked — save a copy under a new name.
The MCP server restricts file paths to the open design's folder (only when strictly inside your home folder and not in a hidden folder), SolidCraft's recovery folder, and its scratch folder; widen with
--allow-path DIR
(repeatable) or lift with
--allow-any-path
. Raw control requests are unlimited for a token holder; a request may pass
allow_paths
to confine itself.
file.new
、
doc.open {path}
、
file.save [path]
、
file.export {path, format}
(step、3mf、3mf-tagged、stl、stla、obj、urdf);STEP 会作为 Import base 特征打开,3MF/STL 会作为网格实体打开,
up: "y"
表示使文件按 Y-up 方向直立。应准确报告写入的路径和格式。除非用户明确要求,不要覆盖用户的源设计;应在新名称下保存副本。
MCP 服务器会将文件路径限制在已打开设计所在的文件夹(该文件夹必须严格位于用户主目录内且不是隐藏文件夹)、SolidCraft 的恢复文件夹及其临时文件夹内;可通过重复使用
--allow-path DIR
扩大范围,也可使用
--allow-any-path
解除限制。持有 token 的用户发出的原始控制请求不受数量限制;单个请求可以传入
allow_paths
来进一步限制自身可访问的路径。

Slow commands, timeouts, and uncertain outcomes

慢速命令、超时与不确定结果

A request unanswered for 60 s (3600 s for
engine.batch
) replies
timeout: … is still running
. That is not a failure — the command may still apply, so never blindly resend a mutation. Ask
control.running
(whole app, never blocks) and
control.pending
(this connection's outstanding request, then its reply once, exactly once); while one is pending every other request on that connection replies
busy
.
solidcraft-cli mcp
and
scripts/sc.py
wait far longer than 60 s on the socket, so bridged calls usually just answer late. Render jobs (
render.start
/
status
/
cancel
/
export
) are the non-blocking path for product images.
请求在 60 秒内未响应时(
engine.batch
为 3600 秒),会返回
timeout: … is still running
。这并不表示失败——命令仍可能生效,因此绝不要盲目重新发送修改操作。查询
control.running
(检查整个应用,永不阻塞)和
control.pending
(先检查当前连接尚未完成的请求,然后恰好接收一次对应响应);当某个请求处于 pending 状态时,该连接上的其他请求都会返回
busy
。
solidcraft-cli mcp
和
scripts/sc.py
在 socket 上等待的时间远长于 60 秒,因此桥接调用通常只是响应较晚。渲染任务(
render.start
/
status
/
cancel
/
export
)是生成产品图片的非阻塞方式。

Headless and scripts

无头模式与脚本

solidcraft-cli run <script.json|design.sc|part.step> [--in F] [--out F]... [--results] [--timings] [--profile]
replays a JSON list of the same commands (
references/scripts.md
);
eval
/
script
inspect and export a design's history;
snapshot --in design --out shot.png [--view iso|--camera JSON] [--section z=27] [--body Name:color=#rrggbb]
renders without a window;
recipe
,
oracle
,
fuzz
,
gpu
and
crashes
cover the rest (
solidcraft-cli --help
).
solidcraft-cli run <script.json|design.sc|part.step> [--in F] [--out F]... [--results] [--timings] [--profile]
可重放由相同命令组成的 JSON 列表(参见
references/scripts.md
);
eval
/
script
用于检查和导出一个设计的历史记录;
snapshot --in design --out shot.png [--view iso|--camera JSON] [--section z=27] [--body Name:color=#rrggbb]
可在没有窗口的情况下渲染;
recipe
、
oracle
、
fuzz
、
gpu
和
crashes
覆盖其余功能(
solidcraft-cli --help
)。

Optional deeper guidance

可选的深入指南

Upstream ships four agent skills for the modelling workflow itself —
solidcraft-modeling
,
solidcraft-editing
,
solidcraft-checking
,
solidcraft-mechanisms
— under
skills/
. Fetch the relevant one when a task is a full part build, an edit to an existing design, regression checking, or an assembly with joints and motion studies.
上游为建模工作流本身提供了四个 Agent skill——
solidcraft-modeling
、
solidcraft-editing
、
solidcraft-checking
、
solidcraft-mechanisms
——位于
skills/
。当任务涉及完整零件构建、编辑现有设计、回归检查,或包含关节与运动研究的装配体时,应获取对应的 skill。