Skip to main content
Glama
freecad-mcp

freecad-mcp

execute_code

Run Python code inside FreeCAD to build, modify, inspect, or automate 3D CAD models; optionally return screenshots from a chosen view.

Instructions

Execute arbitrary Python code in FreeCAD.

Args: code: The Python code to execute. include_screenshot: Whether to return a screenshot of the model (default True). Set to False to save tokens when the code does not change the model's appearance, e.g. analytical or computational scripts whose result is printed output, or intermediate steps in a longer sequence of changes. view_name: The view orientation of the returned screenshot (default "Isometric"). Pick the view that best shows the change being made. timeout: Positive finite seconds for each of the queue and GUI execution budgets, overriding the 90 s default for this call (capped at 1800). Raise it for slow work that must run on the GUI thread, such as importing or exporting a large STEP assembly. Without it the call reports a timeout while the task keeps running; poll get_task_status using the returned task_id for the late result. Prefer execute_code_async for heavy pure-geometry work that touches neither the document nor the GUI.

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

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"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes
timeoutNo
view_nameNoIsometric
include_screenshotNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.32

TDQS

A4.2/5.0
Behavior4/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 well: it discloses the 90 s default budget per queue and GUI, the 1800 s cap, and crucially what happens on timeout (the task keeps running and must be polled via get_task_status with the returned task_id). It also describes the return payload (status message, stdout, screenshot). It does not state side-effect or permission characteristics of running arbitrary code, which is the main remaining gap for a powerful execution tool.

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?

Front-loaded one-line purpose followed by labeled Args and Returns sections, so an agent can scan to the relevant parameter quickly. It is on the long side, but nearly every sentence (timeout semantics, async recommendation, screenshot heuristic) carries decision-relevant information rather than filler.

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

Completeness4/5

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

No output schema exists, so the description supplies the return shape (success/failure message, code output, screenshot) and the late-result path via task_id. For a tool this powerful, only the absence of any note on side effects, document mutation, or error/permission behavior keeps it short of full completeness.

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%, and the description compensates fully: code, include_screenshot (with a concrete token-saving heuristic), view_name (default plus guidance to pick the view showing the change), and timeout (positive finite seconds, default, cap, and the failure mode it prevents). Every parameter gains meaning beyond the bare JSON schema types and defaults.

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 ('Execute arbitrary Python code in FreeCAD'), which is unambiguous and materially different from every sibling (async/headless variants, object CRUD, task status). An agent can tell what this tool is for without opening the schema.

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

Usage Guidelines3/5

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

Offers targeted routing: 'Prefer execute_code_async for heavy pure-geometry work that touches neither the document nor the GUI', and tells the agent to set include_screenshot=False for computational scripts. However, there is no top-level statement of when to choose this over execute_code_headless or execute_code_async in general, so the guidance is embedded in parameter prose rather than framed as usage selection.

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