Skip to main content
Glama
FreeCAD MCP

FreeCAD MCP

by abanerjee84

run_fem_analysis

Runs the CalculiX solver on an existing Fem::Analysis container to return max von Mises stress, displacement, and node count for a prepared model.

Instructions

Run the CalculiX solver on an existing Fem::FemAnalysis container and return summary results.

Prerequisites in the document, all created with `create_object`:
- A Part-derived solid (e.g. Part::Box, PartDesign::Body) acting as the geometry.
- A Fem::AnalysisPython container.
- A material: type "Fem::MaterialCommon" with analysis_name set (built with
  ObjectsFem.makeMaterialSolid) and its Material given as a dict with units,
  e.g. {"Name": "Steel", "YoungsModulus": "210 GPa", "PoissonRatio": "0.3",
  "Density": "7900 kg/m^3"}. A dict read from the material library can
  come back empty; give the values.
- A mesh: type "Fem::FemMeshGmsh" with analysis_name, Shape (the geometry)
  and CharacteristicLengthMax / CharacteristicLengthMin; it is generated
  when created. A section needs several elements across its thickness,
  or bending stress comes out far too low.
- At least one Fem::ConstraintFixed and one Fem::ConstraintForce (or
  ConstraintPressure) whose References are faces of the geometry.
- Set Force with its unit, e.g. "1000 N": create_object/edit_object reject
  unitless values. In existing documents and execute_code, a plain number
  uses millinewtons, so Force = 1000 applies 1 N. The force acts along the
  normal of the loaded face unless Direction links an edge or face;
  Reversed flips it.

A SolverCcxTools is auto-created if the analysis has none. The reply
lists mechanical loads captured in the same GUI operation as the solve
(in N and MPa, with faces and direction). A failed load read stops the solve.
Direction can be set to {"object_name": "Beam", "edge": "Edge1"}.

The solver runs synchronously on the FreeCAD GUI thread and blocks all
other RPC calls for its duration; do not fan out parallel requests.

Returns max von Mises stress (MPa), max/min displacement (mm), node count,
and the working directory CalculiX wrote to. On failure, returns the
prerequisite-check or solver error along with the working directory for
triage.

Args:
    doc_name: Name of the FreeCAD document.
    analysis_name: Name of the Fem::AnalysisPython object.
    timeout: Seconds to wait for the solver (default 600).
    include_screenshot: Whether to return a screenshot of the model (default True).
        Set to False to save tokens when only the numeric results are needed.
    view_name: The view orientation of the returned screenshot (default "Isometric").

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": {
      "doc_name": "<doc_name>",
      "analysis_name": "<analysis_name>"
    },
    "name": "run_fem_analysis"
  }
}

Input Schema

NameRequiredDescriptionDefault
timeoutNo
doc_nameYes
view_nameNoIsometric
analysis_nameYes
include_screenshotNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

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 whole burden and does so: it discloses synchronous execution blocking the GUI thread, auto-creation of SolverCcxTools, that a failed load read aborts the solve, the millinewton vs newton unit trap, and the working directory returned on failure. These are exactly the operational traits 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?

The purpose is front-loaded and the prerequisite block is bulleted and scannable. It is long and dense, with detailed material-dict and unit examples, but each item earns its place by preventing a concrete failure mode.

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?

Given a complex solver invocation with no output schema and five undocumented parameters, the description covers prerequisites, behavior, return values (von Mises stress, displacement, node count, working directory), and failure reporting. Nothing an agent needs in order to call it correctly appears to be missing.

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%, so the description must document the five parameters and it does: doc_name, analysis_name, timeout (default 600), include_screenshot (default True, with the token-saving rationale for setting False), and view_name. It adds meaning beyond names, e.g. the cost tradeoff for screenshots and the purpose of the timeout.

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?

Opens with a specific verb+resource: runs the CalculiX solver on an existing Fem::FemAnalysis container and returns summary results. That clearly separates it from sibling tools like create_object, edit_object, and execute_code, which build or modify objects rather than solving.

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?

Explains that the analysis must already exist and enumerates the full prerequisite set (geometry, AnalysisPython container, material, mesh, constraints), naming create_object as the tool that builds them. It also warns against fanning out parallel requests. It stops short of naming an explicit alternative solve path, but the context needed to decide when to call this is clear.

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