Skip to main content
Glama

OpenFOAM MCP by iLab — a CFD co-pilot for any MCP client

openfoam-mcp is a Model Context Protocol server that turns an AI assistant (Claude Desktop, and any other MCP client) into an OpenFOAM setup and debugging co-pilot. It scaffolds runnable cases, edits dictionaries safely, sizes your near-wall mesh, computes inlet turbulence values, and reads solver logs to tell you whether a run converged or blew up — all without you leaving the chat.

Most of the tools are pure Python and need no OpenFOAM installation, so they work anywhere. The few that call OpenFOAM utilities (e.g. blockMesh, checkMesh) detect the environment and degrade gracefully when it is absent.

Validated end-to-end on real OpenFOAM (ESI v1912). Generated cases run through blockMesh and the solvers — simpleFoam converges, all four mesh presets produce valid meshes, and the real logs are read back correctly by the residual and mesh-quality parsers. See VALIDATION.md.

OpenFOAM version support

scaffold_case takes an openfoam_flavor:

  • classic (default) — application <solver>; with transportProperties. Validated on ESI v1912; works on ESI v2006+ and Foundation v8–v10.

  • foundation-v12 — application foamRun; + solver incompressibleFluid; with physicalProperties, for OpenFOAM Foundation v11/v12. Run foamRun instead of the solver name.

Why it's useful

Setting up a CFD case is fiddly bookkeeping: the right y+, matching boundary patches between the mesh and every 0/ field, consistent turbulence fields for the chosen model, a stable Courant number, and reading pages of residual output to see if it converged. This server does that bookkeeping through natural language.

Related MCP server: Foam-Agent

Make the hard part simple

Two tools do the work most people find fiddly:

  • recommend_setup — tell it your goal in plain words ("flow through a pipe", "drag on a car") and it returns the solver, turbulence model, target y+, mesh preset, per-patch boundary conditions and a numbered plan — asking you for only the numbers it still needs.

  • generate_blockmesh — auto-writes a valid, boundary-layer-graded blockMeshDict from a geometry preset. Give it your target first-cell height and it computes the wall grading for you. No hand-writing vertices or blocks.

Tools (20)

Tool

What it does

recommend_setup

Start here. Goal to solver, model, mesh preset, BCs, plan (asks for missing inputs).

generate_blockmesh

Auto blockMesh with wall grading auto-sized to your y+ (presets: channel, flatplate, step, box).

list_mesh_presets

List the blockMesh geometry presets.

list_solvers

List scaffold-able solver templates (simpleFoam, pimpleFoam, icoFoam).

flow_regime

Reynolds number, laminar/turbulent verdict, turbulence-model recommendation.

first_cell_height

First-cell height for a target y+ (flat-plate correlation).

y_plus_from_height

Inverse: predicted y+ from a cell height, with regime warning.

inlet_turbulence

Inlet k, epsilon, omega, nut from intensity + length scale.

time_step_from_cfl

Transient time step from a target Courant number.

pipe_pressure_drop

Colebrook-White friction factor + Darcy-Weisbach pressure drop / head loss.

heat_transfer_pipe

Convective h for internal flow (Dittus-Boelter Nusselt).

scaffold_case

Write a runnable case tree (system/, constant/, 0/) for a solver.

read_dict

Read a dictionary file or a single entry (via foamDictionary).

set_dict_entry

Set a dictionary keyword (nested via foamDictionary; text fallback).

set_boundary_condition

Set/insert a patch's boundaryField entry in a 0/ field.

analyze_stl

STL watertight/manifold check, bbox, area, volume, snappyHexMesh prep.

mesh_quality_report

Parse a checkMesh log into a non-ortho/skewness/aspect verdict + scheme advice.

check_case

Validate a case: files present, turbulence fields consistent, patches match mesh.

analyze_residuals

Parse a solver log into per-field residual drop + convergence verdict.

run_openfoam_command

Run a whitelisted OpenFOAM utility inside a case (if installed).

Install & run

The server ships as a PyPI package with a console entry point, so the usual zero-install runner is uvx:

uvx openfoam-mcp

or install it into an environment:

pip install openfoam-mcp
openfoam-mcp

Claude Desktop configuration

Add this to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/, Windows: %APPDATA%\Claude\):

{
  "mcpServers": {
    "openfoam": {
      "command": "uvx",
      "args": ["openfoam-mcp"]
    }
  }
}

Restart Claude Desktop; the OpenFOAM tools appear under the tools menu.

Example prompts

  • "I have air at 30 m/s over a 0.5 m chord. What Reynolds number is that, and what first-cell height do I need for y+ = 1?"

  • "Scaffold a steady simpleFoam case in ./duct at 12 m/s and check it."

  • "Set endTime to 3000 in ./duct/system/controlDict."

  • "Read ./duct/log.simpleFoam and tell me if it converged."

Solver templates

Template

Physics

Typical use

simpleFoam

Steady incompressible RANS (k-ω SST)

Ducts, external aero, general steady flow

pimpleFoam

Transient incompressible RANS (k-ω SST)

Vortex shedding, unsteady flows

icoFoam

Transient incompressible laminar

Low-Re teaching cases (cavity, low-Re pipe)

Templates follow the OpenFOAM foundation v9–v12 / ESI v2306+ tutorial style (transportProperties + momentumTransport). The generated box mesh has patches inlet, outlet, walls, frontAndBack.

Development

pip install -e ".[dev]"
pytest

License

MIT © 2026 iLab (Tanawat Manokieng)

Available Tools

20 tools
analyze_residualsA

Parse an OpenFOAM solver log file and report per-field residual drop, Courant number, bounded fields, and a convergence verdict (converged / diverging / NaN / still running).

Inputs: log_path (required).

analyze_stlA

Analyze an STL surface (ASCII or binary): triangle count, bounding box, surface area, enclosed volume, and a watertight/closed-manifold check with the count of unpaired edges — plus a suggested background cell size and snappyHexMesh advice. No OpenFOAM needed. Use before snappyHexMesh.

Inputs: path (required).

check_caseA

Logically validate a case directory: required system files present, solver read, turbulence fields consistent with the model, and 0/ boundary patches matching the mesh. Returns errors, warnings and a pass flag. Does not require OpenFOAM to be installed.

Inputs: case_dir (required).

first_cell_heightA

Estimate the wall-normal first-cell height needed to hit a target y+ on a turbulent boundary layer (flat-plate correlation). Use before meshing to set the near-wall cell size. Defaults are for air at sea level.

Inputs: length (required), y_plus (required), velocity (required), density, +1 more.

flow_regimeA

Reynolds number, laminar/transitional/turbulent classification, and a turbulence-model recommendation. geometry = 'internal' (pipe/duct) or 'external' (plate/bluff body/airfoil).

Inputs: length (required), velocity (required), geometry, kinematic_viscosity.

generate_blockmeshA

Auto-generate a valid, boundary-layer-graded blockMeshDict and write it to output_path (typically '/system/blockMeshDict'). Pick a preset (channel, flatplate, step, box). If first_cell_height > 0, wall-normal grading is computed automatically so the near-wall cell matches that height (feed it the value from the first_cell_height tool to hit a target y+). This removes the hardest, most error-prone part of setting up a case.

Inputs: output_path (required), depth, height, length, +5 more.

heat_transfer_pipeB

Convective heat-transfer coefficient for internal flow (Dittus-Boelter Nu = 0.023 Re^0.8 Pr^n; laminar Nu = 3.66). Defaults are for water. Returns Nusselt number and h (W/m^2K).

Inputs: diameter (required), velocity (required), density, heating, +3 more.

inlet_turbulenceA

Compute inlet k, epsilon, omega and nut from turbulence intensity (fraction, e.g. 0.05) and turbulent length scale (m). Use to fill the 0/ directory inlet/internalField values for a RANS case.

Inputs: velocity (required), length_scale (required), turbulence_intensity (required), kinematic_viscosity.

list_mesh_presetsA

List the auto-blockMesh geometry presets (channel, flatplate, step, box).

Inputs: no named parameters.

list_solversA

List the OpenFOAM solver templates this server can scaffold, with a one-line description of each and when to use it.

Inputs: no named parameters.

mesh_quality_reportA

Parse a checkMesh log file into a quality verdict: max/avg non-orthogonality, skewness, aspect ratio, pass/fail, and concrete fvSchemes/fvSolution advice (e.g. nNonOrthogonalCorrectors). Works from a saved log without OpenFOAM installed.

Inputs: log_path (required).

pipe_pressure_dropB

Darcy friction factor (Colebrook-White for turbulent, 64/Re laminar) and Darcy-Weisbach pressure drop / head loss for pipe flow. Defaults are for water; set roughness (m) for rough pipes. Handy sanity check against CFD.

Inputs: length (required), diameter (required), velocity (required), density, +2 more.

read_dictA

Read an OpenFOAM dictionary file. If entry is given (foamDictionary path syntax, e.g. 'endTime' or 'solvers/p/solver') and OpenFOAM is installed, return just that entry's value; otherwise return full contents.

Inputs: path (required), entry.

recommend_setupA

Turn a plain-language goal (e.g. 'flow through a pipe', 'drag on a car') into a complete setup plan: recommended solver, turbulence model, target y+, which blockMesh preset to auto-generate, the 0/ fields needed, per-patch boundary conditions, and a numbered step list. If velocity/length are missing it returns targeted questions to ask the user first. Start here.

Inputs: goal (required), fluid, length, velocity, +2 more.

run_openfoam_commandA

Run a whitelisted OpenFOAM utility (blockMesh, checkMesh, foamDictionary, renumberMesh, decomposePar, foamListTimes, surfaceCheck, transformPoints) inside a case directory. Requires OpenFOAM installed and its environment sourced. Returns return code and the tail of stdout/stderr.

Inputs: command (required), case_dir (required), timeout.

scaffold_caseA

Create a runnable OpenFOAM case skeleton at case_dir for the chosen solver (simpleFoam / pimpleFoam / icoFoam). Writes system/, constant/ and 0/ with a single-block box mesh (patches: inlet, outlet, walls, frontAndBack) and consistent turbulence fields.

openfoam_flavor selects the case style:

  • 'classic' (default): application ; + transportProperties. Validated on ESI v1912; works on ESI v2006+ and Foundation v8-v10.

  • 'foundation-v12': application foamRun; solver incompressibleFluid; + physicalProperties. Targets OpenFOAM Foundation v11/v12. Run blockMesh, then <solver> (classic) or foamRun (foundation-v12).

Inputs: case_dir (required), solver, cells_x, cells_y, +8 more.

set_boundary_conditionA

Set (or insert) the boundaryField entry for a patch in a 0/ field file, e.g. field_file='0/U', patch='inlet', bc_type='fixedValue', value='(10 0 0)'.

Inputs: patch (required), bc_type (required), field_file (required), value.

set_dict_entryA

Set a keyword in a dictionary file. Uses foamDictionary when available (supports nested entries like 'solvers/p/tolerance'); otherwise falls back to editing a top-level single-line entry as text.

Inputs: path (required), entry (required), value (required).

time_step_from_cflB

Maximum/target transient time step from a target Courant number (dt = Co * dx / U).

Inputs: velocity (required), cell_size (required), target_courant.

y_plus_from_heightB

Predict the y+ that a given first-cell height will produce, and whether it lands in the viscous sublayer, buffer layer (avoid), or log-law region.

Inputs: length (required), velocity (required), first_cell_height_m (required), density, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 20 tools

    Disambiguation5/5

    Each tool serves a distinct purpose: analysis (residuals, mesh quality), setup (scaffolding, blockMesh), physical calculations (y+, pressure drop), config editing (dict, boundary conditions), and execution. The inverse pair first_cell_height/y_plus_from_height are clearly complementary, not overlapping. No two tools could be easily confused.

    Naming Consistency5/5

    All tool names follow a consistent snake_case convention with a verb_noun pattern (analyze_residuals, scaffold_case, run_openfoam_command) or descriptive noun phrases (pipe_pressure_drop, heat_transfer_pipe). No mixing of camelCase or inconsistent verb styles, making the set predictable.

    Tool Count4/5

    20 tools is on the higher end but well-scoped for a CFD setup and analysis server. The count is justified by covering the full workflow: planning, mesh generation, case configuration, execution utilities, and diagnostics. Slightly above the 15-tool sweet spot but not excessive.

    Completeness4/5

    The tools cover the complete lifecycle from recommended setup through mesh generation, case validation, boundary condition editing, running whitelisted utilities, and analyzing both residuals and mesh quality. Minor gaps: no direct solver execution (by design) and no post-processing tools, but core workflows are fully supported.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      F
      maintenance
      Enables natural language-driven ANSYS simulations (Fluent, Mechanical, Geometry) with automatic TUI script generation for reproducibility.
      41
      5
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Automates OpenFOAM CFD simulations via MCP, enabling AI agents to mesh, run, and post-process cases from natural language prompts without any API keys.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      An MCP server that enables AI assistants to interact with Ansys CFX through PyCFX, supporting natural-language-assisted CFX-Pre, CFX Solver, and CFD-Post workflows for setup, execution, and postprocessing.
      7
      1,162 PyPI
      4
      Apache 2.0
    • A
      license
      A
      quality
      C
      maintenance
      Voice-driven CFD MCP server that enables natural language setup, execution, and analysis of OpenFOAM simulations, with results exportable to ParaView.
      16
      MIT