gmsh-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gmsh-mcp-server Create a structured mesh of a straight pipe and export it to OpenFOAM."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Gmsh MCP Server
A local Model Context Protocol server for creating, grading, inspecting, viewing, and exporting Gmsh meshes. Native Gmsh state runs in isolated worker processes, while an owned Gmsh GUI displays immutable geometry and mesh checkpoints.
The server favors structured meshes. It includes transfinite box meshing, a conformal external-cylinder O-H template, a five-block straight-pipe template, and user-described connected quadrilateral blocks extruded along +z. Tetrahedral meshing is available when explicitly selected. It does not automatically decompose arbitrary CAD into structured blocks.
Requirements
Python 3.12 or newer
An interactive desktop for the optional native viewer
OpenFOAM only if OpenFOAM conversion is required
The default runtime is the gmsh==4.15.2 Python wheel pinned by this project. A separately installed, matching Gmsh 5 SDK can be selected explicitly as described below.
Related MCP server: OpenFOAM MCP Server
Install and verify
git clone https://github.com/OFFTECH/gmsh-mcp-server.git
cd gmsh-mcp-server
uv sync
uv run gmsh-mcp doctorRun the included structured-duct demonstration:
uv run gmsh-mcp --workspace .gmsh-mcp-workspace/demo demoAdd --gui --hold-seconds 10 to display the checkpoints and capture the final view. The GUI requires an interactive desktop. On Linux, the Gmsh wheel also requires the system OpenGL/GLU libraries.
Configure an MCP client
Start the stdio server directly with:
uv run gmsh-mcp --workspace .gmsh-mcp-workspace/mcp serveAn MCP client can launch the virtual-environment Python executable without going through a shell. Replace the paths with absolute paths for your checkout:
{
"mcpServers": {
"gmsh": {
"command": "C:\\path\\to\\gmsh-mcp-server\\.venv\\Scripts\\python.exe",
"args": [
"-m",
"gmsh_mcp",
"--workspace",
"C:\\path\\to\\gmsh-mcp-server\\.gmsh-mcp-workspace\\mcp",
"serve"
]
}
}
}On Linux or macOS, use .venv/bin/python. Standard output is reserved for MCP protocol messages.
Workflow and capabilities
The server exposes 36 tools. Call system_capabilities and use MCP tool discovery for the installed schemas.
Area | Capabilities |
Sessions | Isolated sessions, optimistic revision guards, idempotent request keys, asynchronous mesh jobs, cancellation and deterministic recovery |
Geometry | OCC operation batches, entity inspection, named surface patches and fluid volumes |
Structured templates | Box, external-cylinder O-H, straight filled-bore pipe, and connected XY quadrilateral blocks extruded along |
Grading | One-sided geometric grading, two-sided grading, and structured layer planning |
Mesh diagnostics | Bounded node and element inventory, |
Viewer | Explicit checkpoints, six axis presets plus isometric, analytical fit, axis-aligned clipping, PNG capture |
Export | MSH 2.2 export with checksummed manifests and optional OpenFOAM conversion and |
Knowledge | Versioned Gmsh documentation cache, authored structured-meshing guidance, search, resources, and prompts |
Geometry, classification, and mesh mutations require the current expected_revision and a unique request_key. Operations that use native entity tags also require the current worker_epoch; inspect entities again after worker recovery. mesh_generate returns a job ID that is polled with job_get.
Template builders require a fresh session and own their structured controls. A configured first radial edge height constrains that edge sequence; it is not a general guarantee of uniform wall-normal height over arbitrary curved geometry.
The broker process never imports the native Gmsh module. Each model worker owns its native state, and the viewer uses a separate process. This keeps stdio handling responsive and prevents native global state from leaking between model sessions.
Select a Gmsh runtime
Wheel baseline: Gmsh 4.15.2
No runtime file is needed for the supported wheel baseline. It is selected whenever .gmsh-runtime.json is absent. It can also be selected explicitly:
$env:GMSH_MCP_RUNTIME_CONFIG = "wheel"
uv run gmsh-mcp doctorExplicit Gmsh 5 SDK
The Gmsh Python wrapper and native shared library must come from the same SDK and must be placed side by side. Never combine a wrapper and library from different builds. For the pinned Gmsh 5 reference in upstream/gmsh5.json:
Obtain the matching official SDK or build the pinned source with
scripts/build_gmsh.ps1.Put
gmsh.pyand the native library in a local directory. On Windows the expected library name for API 5.0 isgmsh-5.0.dll.Copy
gmsh-runtime.example.jsonto.gmsh-runtime.jsonand adjust its relative paths.Keep the matching source checkout available at
source_dirwhen synchronizing source-backed knowledge.Set
GMSH_MCP_RUNTIME_CONFIGto the absolute path of that configuration file.Run
uv run gmsh-mcp doctorbefore starting the server.
For example, from PowerShell:
$env:GMSH_MCP_RUNTIME_CONFIG = (Resolve-Path .gmsh-runtime.json).Path
uv run gmsh-mcp doctorA configured SDK that is missing or mismatched is an error; the server will not silently fall back to the wheel.
The official development SDK URL in upstream/gmsh5.json is a rolling artifact. Its contents can change while the URL stays the same, so verify the recorded SHA-256 before use. A checksum failure means the SDK is a different snapshot: do not combine it with the pinned wrapper, library, source revision, or knowledge cache.
Building from source requires CMake, Ninja, C and C++ compilers, plus compatible OpenCASCADE and FLTK development packages. The script does not download those dependencies. It enables the shared library, meshing, OpenCASCADE, and FLTK, and stops if any required feature is absent:
./scripts/build_gmsh.ps1 -SourceDir external/gmsh5-source -BuildDir external/build-gmsh5Knowledge cache
Populate the upstream manual, API, options, and source references explicitly:
uv run gmsh-mcp --workspace .gmsh-mcp-workspace/mcp knowledge-syncFor a matching local Gmsh checkout, add --source-checkout PATH. Set GMSH_MCP_KNOWLEDGE_DIR to share a cache between workspaces. The cache version and revision must match the selected runtime; ordinary tool calls do not download documentation.
OpenFOAM
OpenFOAM conversion is optional. GMSH_MCP_OPENFOAM_ENV must contain the descriptor as JSON text, rather than a path to a JSON file. For example, in PowerShell:
$env:GMSH_MCP_OPENFOAM_ENV = '{"mode":"wsl","distribution":"Ubuntu-24.04","bashrc":"/opt/openfoam13/etc/bashrc"}'Conversion stages a new case, runs gmshToFoam, applies the declared patch types, audits polyMesh, and requires checkMesh -allGeometry -allTopology to report success. Foundation OpenFOAM 13 under WSL Ubuntu 24.04 is the initially validated target.
Scope
Current scope includes metre coordinates, first-order meshes, MSH 2.2 ASCII export, basic OCC primitives and booleans, conservative box meshing, fixed structured templates, and explicit connected-block extrusion. Arbitrary CAD import, automatic block decomposition, general 3D layer inflation, wakes, optimization, and quality coloring are not implemented.
License
This project is licensed under the GNU General Public License v3.0 only. See LICENSE. Gmsh and other dependencies remain under their own licenses; see THIRD_PARTY_NOTICES.md.
Available Tools
36 toolsgeometry_applyC
Apply an ordered batch of supported OCC primitives, booleans and transforms.
Inputs: operations (required), session_id (required), request_key (required), expected_revision (required). Returns: object
geometry_external_cylinder_ohA
Build a conformal external-cylinder O-H template in an empty session, in metres. Cylinder centre is (0,0); x spans -upstream to length-upstream, y +/-width/2. Sixteen connected blocks are extruded from z=0 to span with ONE cell for quasi-2D. Names inlet/outlet (patch), cylinder (wall), farfield_top/bottom (symmetryPlane), front/back (empty), and fluid are assigned automatically. Cell counts and radial first-cell height are configured here; then call mesh_generate, mesh_export and openfoam_prepare. mesh_configure cannot override this template. To change its geometry or counts, create a new session. This is external flow, not a pipe bore.
Inputs: session_id (required), request_key (required), expected_revision (required), span, +11 more. Returns: object
geometry_inspectC
List bounded model entities and their geometry at the current revision.
Inputs: session_id (required), dimension. Returns: object
geometry_pipe_ohA
Build a straight internal pipe with square core and four curved blocks. The bore is centred at (0,0), extends from z=0 to length, and uses metres. Creates inlet/outlet (patch), wall (wall), and fluid automatically. First cell height controls spacing along radial block edges inward from the circular wall; it is not a guaranteed normal distance everywhere on a curved wall. circumferential_cells must be divisible by four. Requires an empty session, then mesh_generate; never falls back to tetrahedra. axial_heights optionally gives normalized cumulative axial layer endpoints.
Inputs: session_id (required), request_key (required), expected_revision (required), length, +7 more. Returns: object
geometry_structured_blocksA
Construct connected planar quadrilateral blocks and extrude along +Z, in metres. Requires an empty session. parameters contains vertices {name:[x,y]}, edges {name:{kind:'line'|'circle_arc',vertices:[a,b],cells:n,progression:ratio, center:[cx,cy] for arcs}}, faces {name:{edges:[four signed edge names]}}, span, span_cells, and patches {name:[exterior edge names]}. Shared edges must agree on cell counts. Each edge optionally sets its successive-cell progression in its declared direction. Optional span_heights contains span_cells cumulative normalized heights ending at 1; use mesh_layer_plan or mesh_grading_two_sided to calculate them. Inlet/outlet cap and fluid groups are automatic. Then call mesh_generate. Counts are locked to this recipe; no automatic arbitrary CAD decomposition.
Inputs: parameters (required), session_id (required), request_key (required), expected_revision (required). Returns: object
job_cancelC
Request cancellation of a meshing job.
Inputs: job_id (required). Returns: object
job_getC
Poll a meshing job without waiting for the native mesher.
Inputs: job_id (required). Returns: object
knowledge_catalogBRead-onlyIdempotent
List manual, api, option, source, guide or capability records with pagination.
Inputs: kind (required), limit, query, offset. Returns: object
knowledge_readBRead-onlyIdempotent
Read a bounded document excerpt with provenance and character-offset pagination.
Inputs: document_id (required), limit, offset. Returns: object
knowledge_searchBRead-onlyIdempotent
Search manual, API, option, source, guide or capability documents; read hits by ID.
Search is local and bounded. A documented upstream function is not necessarily exposed as an executable MCP tool; consult the capability documents.
Inputs: query (required), kind, limit, offset. Returns: object
knowledge_statusARead-onlyIdempotent
Report documentation versions, provenance, availability and runtime mismatch warnings.
Inputs: no named parameters. Returns: object
mesh_configureC
Set structured single-box hex controls; tetrahedral meshing is explicit.
Inputs: session_id (required), request_key (required), expected_revision (required), size_max, +5 more. Returns: object
mesh_exportC
Export classified first-order ASCII MSH 2.2 for OpenFOAM conversion.
Inputs: session_id (required), request_key (required), expected_revision (required), format. Returns: object
mesh_generateC
Start a durable meshing job and return its job ID immediately.
Inputs: session_id (required), request_key (required), expected_revision (required), dimension. Returns: object
mesh_grading_calculateARead-onlyIdempotent
Calculate structured geometric grading in metres. Supply length and at least two of cells, first_cell_height, growth_ratio (successive-cell ratio, not total expansion). strict rejects incompatible constraints. adjust_ratio preserves first height; adjust_first_height preserves ratio. Without cells, fitting selects the smallest integer count whose requested series spans length (at most 256). direction negative starts at the maximum-coordinate face. Returns cell heights, positions, actual adjustments and mesh_configure arguments; apply them then call mesh_generate. This calculation does not alter a session or generate a mesh by itself.
Inputs: length (required), fit, axis, cells, +4 more. Returns: object
mesh_grading_two_sidedARead-onlyIdempotent
Plan ordered wall-to-wall cell heights over a fixed length.
The default resolves a shared ratio while preserving both wall heights. strict accepts compatible explicit ratios; adjust_first_height scales both wall heights. Odd counts require symmetric wall inputs and contain one centre cell. Returned node positions and normalized extrusion heights are exact planning data; no native mesh is changed or certified.
Inputs: cells (required), length (required), first_cell_height (required), fit, +3 more. Returns: object
mesh_inspectARead-onlyIdempotent
Read bounded node/connectivity pages and counts from the completed mesh. Retain expected_revision across pages; stale revisions fail instead of mixing different meshes. Limits are 1..1000. dimension=-1 includes all element types.
Inputs: session_id (required), expected_revision (required), dimension, node_limit, +3 more. Returns: object
mesh_layer_planARead-onlyIdempotent
Plan one-sided geometric wall layers without modifying a model.
Supply first_cell_height plus at least two of cells, successive-cell growth_ratio and total thickness. strict rejects inconsistent inputs; adjust_ratio preserves the first height and count; adjust_first_height preserves count and ratio. Returned normalized heights are consumable by structured block extrusion. The result is a plan, not evidence that Gmsh created or validated the requested layers.
Inputs: first_cell_height (required), fit, cells, thickness, +1 more. Returns: object
mesh_qualityARead-onlyIdempotent
Evaluate all volume cells, return quality statistics/histogram and worst failures. minSICN is dimensionless; minDetJac is a dimensional determinant, so choose its threshold for the model scale. This is Gmsh quality, not OpenFOAM checkMesh. Cells at or below threshold fail. The failure list is bounded; counts and coverage describe the complete mesh.
Inputs: session_id (required), expected_revision (required), metric, threshold, +2 more. Returns: object
openfoam_convertB
Convert a verified export into a new staged case and run checkMesh.
Inputs: session_id (required), export_manifest_path (required). Returns: object
openfoam_inspectC
Audit stored polyMesh addressing, names, geometry and patch ranges.
Inputs: case_dir (required), session_id (required), export_manifest_path (required). Returns: object
openfoam_prepareC
Verify MSH2 cells, patch names, geometry and complete exterior face coverage.
Inputs: session_id (required), export_manifest_path (required). Returns: object
openfoam_probeC
Probe the server-configured OpenFOAM distribution and converter commands.
Inputs: no named parameters. Returns: object
patch_manageC
Name exterior surfaces and assign their OpenFOAM mesh patch type.
Inputs: name (required), session_id (required), request_key (required), surface_tags (required), +5 more. Returns: object
patch_validateB
Check named patch coverage before exporting a CFD mesh.
Inputs: session_id (required). Returns: object
physical_volume_setC
Classify retained fluid volume cells with a named physical volume.
Inputs: name (required), session_id (required), request_key (required), volume_tags (required), +3 more. Returns: object
session_closeB
Close the owned viewer and model worker for a session.
Inputs: session_id (required). Returns: object
session_createC
Create a model session and its isolated Gmsh worker.
Inputs: name (required), units. Returns: object
session_statusB
Read cached session and viewer state while meshing continues.
Inputs: session_id (required). Returns: object
system_capabilitiesA
Report the installed broker and optional native/OpenFOAM capabilities.
Inputs: no named parameters. Returns: object
view_captureB
Write an on-demand native PNG of the displayed checkpoint to session artifacts.
Inputs: session_id (required). Returns: object
view_clipAIdempotent
Clip the displayed model at a global coordinate plane in metres. positive retains coordinates >= position; negative retains <= position. enabled=False disables clipping. Affects only the live viewer, preserves camera and mesh revision, and persists through subsequent checkpoints.
Inputs: session_id (required), axis, keep, enabled, +1 more. Returns: object
view_closeB
Close the owned native viewer while preserving the model session.
Inputs: session_id (required). Returns: object
view_openC
Launch the owned native Gmsh GUI and show latest validated checkpoint.
Inputs: session_id (required). Returns: object
view_setAIdempotent
Select a camera preset in the open Gmsh viewer without changing geometry or mesh. Front/back look from +Z/-Z, right/left from +X/-X, top/bottom from +Y/-Y. Isometric looks from (+X,+Y,+Z). fit=True uses orthographic projection and resets pan/zoom to frame the rotated model; fit=False preserves pan/zoom. The viewer must have a displayed checkpoint. This is a display change and does not increment the authoritative session revision.
Inputs: session_id (required), fit, preset. Returns: object
view_statusB
Read the GUI heartbeat, displayed revision and last snapshot load time.
Inputs: session_id (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 36 tools
Most tools target distinct resources or lifecycle stages, and the detailed descriptions delineate overlaps such as the mesh grading planners and patch validation versus OpenFOAM preparation. A few pairs, such as patch_validate/openfoam_prepare and physical_volume_set/patch_manage, have partially overlapping verification or classification purposes, but they remain separable.
All tool names are lower snake_case with predictable domain prefixes such as knowledge_, mesh_, geometry_, session_, job_, view_, patch_, and openfoam_. Although the set is not uniformly verb_noun, the prefix-based convention is consistent across the server.
36 tools is well above the suggested 3-15 range and crosses the 25+ 'too many' threshold. The Gmsh/OpenFOAM domain is complex, but the surface includes many specialized operations that could be consolidated for an agent.
The surface covers the full lifecycle: knowledge documents, session management, geometry construction/application/inspection, grading plans, mesh configuration/generation/inspection/quality/export, patch and physical classification/validation, OpenFOAM conversion/inspection, and viewer control. No obvious core operation is missing for the stated meshing-to-OpenFOAM-prep purpose.
Maintenance
Related MCP Connectors
Build, run and analyse block-diagram simulations: PID, Bode, FFT, optimisation and code export.
Create, edit, render, save, and export voxel models with interactive 3D previews.
Manage SysML2 projects; check, evaluate, verify, query, document and diagram models.
Real BEM engineering for propellers, wings and turbines — design, optimize, visualize, export.
Related MCP Servers
- FlicenseAqualityDmaintenanceProvides aerodynamic analysis tools through MCP, enabling geometry generation, meshing, CFD solving, and visualization for 2D airfoils.7-
- FlicenseNot gradedqualityDmaintenanceEnables to read and modify OpenFOAM configuration files, including case info, dictionary files, and boundary conditions, with additional tools for thermal and buoyancy simulations.4-
- AlicenseNot gradedqualityCmaintenanceTurns an AI assistant into an OpenFOAM setup and debugging co-pilot, enabling case scaffolding, dictionary edits, mesh sizing, turbulence calculations, and solver log analysis through natural language.MIT
- AlicenseBqualityBmaintenanceEnables AI agents to drive OpenFOAM end to end: cloning tutorials or custom cases, editing dictionaries, meshing and running solvers in the background, tracking convergence and job status, and analyzing results. It also renders flow images — slices, patches, streamlines, iso-surfaces and residual or force plots — back to the agent.251MIT