Skip to main content
Glama
freecad-mcp

freecad-mcp

execute_code_headless

Run FreeCAD Python scripts in an isolated headless process for crash-prone OCCT operations, so GUI documents survive while output and crash diagnostics are returned.

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.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "execute_code_headless"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes
timeoutNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.32

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so: crash isolation (only the helper process dies, GUI and documents survive), crash signal and stdout reporting, timeout kills the process with partial output preserved, and no GUI and no access to the `execute_code` namespace. Environment preconditions are spelled out — you must import FreeCAD/Part yourself, open documents from disk with FreeCAD.openDocument(path), and save via doc.save()/saveAs() or Shape.exportBrep().

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well front-loaded with the mechanism in sentence one, then the use case, then environment constraints, then an Args/Returns block. Minor redundancy between 'headless' and 'fresh process without GUI', and the environment paragraph is dense, but no sentence is wasteful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Completeness is high for a tool with an idiosyncratic execution environment: it covers what is and isn't available inside the process, how documents are loaded and saved, what the return payload contains (without an output schema), and the follow-up step — call `reload_document(doc_name)` after saving a .FCStd that the GUI has open.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% (only bare titles), so the description must compensate, and it does: `code` is explicitly a *complete* script for freecadcmd (not a fragment), and `timeout` is a positive finite second count with default 600 whose expiry kills the process while preserving partial output. That timeout semantics is genuine meaning beyond the schema's `exclusiveMinimum: 0`.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Run a FreeCAD Python script') plus the crucial mechanism ('in a separate headless `freecadcmd` process'), which is exactly what distinguishes it from the sibling `execute_code`. An agent can tell the two apart without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear, concrete when-to-use list: OCCT work that can crash or block FreeCAD — helical threads, lofts/sweeps, many-tool booleans, long parametric rebuilds. It also implies when-not (safe/interactive work stays in-process) but never explicitly names `execute_code` as the alternative for quick, low-risk scripts, so routing for the ordinary case must be inferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.