Skip to main content
Glama
hram

FreeCAD MCP

by hram

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

NameRequiredDescriptionDefault
codeYes
timeoutNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

With zero annotations, the description carries the full burden and does it well: crash isolation ('only kills the helper process; the GUI and its open documents survive'), process independence from --host, no GUI, no execute_code namespace, mandatory manual imports, stdout capture, and partial-output preservation on timeout. These are exactly the behavioral facts an agent cannot infer from the schema.

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?

It is front-loaded with the core definition and then uses a tight Args/Returns block, so structure is strong. It runs slightly long and repeats the isolation idea in two places, but no sentence is filler.

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?

There is no output schema, and the description supplies the return contract (exit status, crash/timeout diagnosis, printed output). Together with the isolation model, import requirements, and the reload_document handoff, an agent has everything needed to invoke it correctly.

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 description coverage is 0%, so the description must compensate, and it does: `code` is specified as a 'complete Python script for freecadcmd' (i.e., stateless, self-contained), and `timeout` is constrained to 'positive finite seconds,' given a default of 600, and its failure mode (partial output preserved) is described.

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?

The first sentence states a specific verb, resource, and execution context: run a FreeCAD Python script in a separate headless `freecadcmd` process. It also implicitly separates this from the in-process `execute_code` sibling by noting that 'Nothing from the execute_code namespace is available,' so an agent can tell which tool it is looking at.

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

Usage Guidelines5/5

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

'Use this for OCCT work that can crash or block FreeCAD' followed by concrete triggers (helical threads, lofts/sweeps, large booleans, long rebuilds) gives the selection criterion directly. It also supplies a required follow-up action: 'After the script saved a .FCStd that is open in the GUI, call reload_document(doc_name).'

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