execute_code_headless
Run FreeCAD Python scripts in an isolated headless freecadcmd process to test crash-prone OCCT operations without losing GUI documents; returns exit status, crash diagnostics, and stdout.
Instructions
Run a FreeCAD Python script in a separate headless freecadcmd process.
Use this for OCCT work that can crash or block FreeCAD: helical threads
(makeHelix + makePipeShell), lofts and sweeps, booleans with many or
B-spline tools, long parametric rebuilds. A native OpenCascade crash
here only kills the helper process; the GUI and its open documents
survive, and the tool reports the crash signal and the script's output.
The script runs on the MCP server machine, independently of --host, in a
fresh process without GUI: import FreeCAD/Part
yourself, open documents from disk (FreeCAD.openDocument(path)), save
results with doc.save()/saveAs() or Shape.exportBrep(). Nothing from the
execute_code namespace is available. Print progress to stdout; it is
returned when the process ends. After the script saved a .FCStd that is
open in the GUI, call reload_document(doc_name) to show the result.
Args:
code: Complete Python script for freecadcmd.
timeout: Positive finite seconds to wait before killing the process
(default 600). Partial output is preserved on timeout.
Returns:
Exit status, crash/timeout diagnosis and the script's printed output.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout | No |