Skip to main content
Glama
maximedns5

freecad-mcp

by maximedns5

execute_code

Execute custom Python code in FreeCAD to handle operations beyond standard tools. The code is checked for safety before running, and you receive output plus a screenshot.

Instructions

Execute arbitrary Python code in FreeCAD.

This is an unverified escape hatch: prefer the typed tools (pad, pocket,
place, measure, probe_material_at, fillet, chamfer, linear_pattern,
polar_pattern, create_sketch/add_rectangle/add_circle/add_polygon,
instantiate_family) for normal geometry work, since they check what
actually happened (volume, isValid, bounding box) instead of only
reporting whether the code raised — the usual CAD failure mode is an
operation that silently does nothing, not one that throws. Code
containing process-level imports (os/subprocess), eval/exec/open/
__import__, or Sketcher calls known to hang FreeCAD's solver (.solve(),
deleteAllGeometry(), movePoint() on an already-constrained sketch) is
rejected before it runs.

Args:
    code: The Python code to execute.

Returns:
    A message indicating the success or failure of the code execution, the output of the code execution, and a screenshot of the object.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

With no annotations, the description carries full burden. It discloses the unverified nature, the fact that it reports only whether code raised (with typed tools being safer), and the specific patterns rejected before execution (process-level imports, eval/exec/open, dangerous Sketcher calls). This goes well beyond basic transparency.

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

Conciseness5/5

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

The description is organized into purpose, guidance, safety restrictions, args, and returns. Every sentence adds value; the front-loaded purpose immediately informs the agent. Length is justified by the complexity of a code-execution tool.

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?

Despite the complexity, the description covers what the tool does, when to use it (as a last resort), safety constraints, parameter meaning, and return value structure. The presence of an output schema reduces the burden on describing return values in detail, and the summary is sufficient.

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

Parameters4/5

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

The schema says nothing beyond 'code' being a string, but the description adds meaningful constraints (rejecting specific code patterns) and states 'The Python code to execute.' While it doesn't detail the execution environment, the single parameter is well contextualized by the tool's purpose.

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 description opens with 'Execute arbitrary Python code in FreeCAD,' using a specific verb and resource. It clearly distinguishes itself from sibling tools by labeling itself as an 'unverified escape hatch' and listing the preferred typed alternatives.

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?

Explicit guidance is given: 'prefer the typed tools... for normal geometry work,' with a clear rationale (typed tools validate results). It also enumerates what kinds of code are rejected, giving concrete usage boundaries.

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

Install Server

Other Tools

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/maximedns5/freecad-mcp'

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