Kompas-MCP
An MCP server that hands KOMPAS-3D to an AI agent: parts, assemblies and drawings are built for real, and every operation is checked against the model. The agent calls a tool through its schema and gets a measured result instead of guessing whether the call did anything.
57 tools, and the whole API through a gateway
- Parts from scratch. Sketch, extrude, revolve, loft, sweep, shell, mirror and circular pattern.
- Fillets and chamfers. Edges are addressed by a topology reference, not by ordinal number; removed material is checked against analytics.
- Assemblies. Components from files, rotation and repositioning, mates by planes — position is proven by reading it back.
- Drawings. Standard views, linear, diameter and angular dimensions, the title block and technical requirements.
- Export and snapshots. STEP, STL, DXF and model images from any angle — 13 views with a custom up-vector.
- SDK reference built in. Search over the offline help that ships with KOMPAS: the agent reads a signature rather than recalling one.
- The long tail of the API. Through the
kompas_callgateway the agent reaches 54,214 API5 and API7 entry points — with a journal and destructive routes disabled. - Editing existing models. Documents opened by hand are adopted by the server; sketches, planes and features are editable.
The answer is what was read back from the model
KOMPAS return codes cannot be trusted: on v25 a cut created the feature, returned Create() = true
and removed not a single millimetre of material. The server answers that with operation_had_no_effect
and the volume before and after — not with ok.
Verification level
call_returned, read_back, geometry_checked —
the server never claims more than it verified. Whatever stayed unchecked is listed in unverified_aspects.
Volume is the measure
Bounding size does not change on an internal cut, and the object counter returns zero on v25 — volume senses both adding and removing material.
The numbers agree
An edge fillet gives 77.256661176918 mm³ against a computed 77.2566611769186. On a large assembly, a sweep with an arc bent the wrong way returned a refusal instead of a false success.
An error comes with a reason and a next step
A script dies with a COM stack trace. The server answers with a code and a retry policy, and a retry will not
spoil the model: every mutation carries an operation_id and is journalled before and after it runs.
| Code | What happened | What to do |
|---|---|---|
stale_reference | the edge reference is out of date | re-read the topology |
revision_conflict | the model changed since it was read | refresh expected_revision |
outcome_unknown | timed out, the outcome is unknown | do not retry blindly |
path_not_allowed | the path is outside an allowed directory | stay inside the root |
invalid_argument | an argument violates the schema | fix it before KOMPAS is called |
Next to it sits retry_policy: safe_to_retry, retry_after_reread,
do_not_retry_blindly. A repeat with the same operation_id is not applied twice.
A hung call does not kill the session, and other files stay closed
A separate process
KOMPAS COM lives in the Worker: one STA thread with a command queue. A STEP export or an assembly rebuild runs for minutes and is not cancelled; a hung Worker restarts, the agent keeps its connection and learns which documents became invalid.
Directories by role
Where the agent reads models from, where it writes its own, where it exports
STEP, STL, DXF and images. With a root set, any path outside it is refused before KOMPAS is touched, and the write root
cannot be the read root. The server never closes the user's KOMPAS; documents opened by hand are taken only by an explicit adopt.
The server is written in C# against the interop assemblies: a misspelled member fails at compile time, not at the user's — that is the main fragility of pywin32 scripts, where late binding does not even see some methods.
One file, no Python, no .NET
The installer places the server, the Worker and the control window together with the .NET runtime; all you need is
an installed KOMPAS-3D with a registered COM. The wizard then checks its own work: handshake, tools/list
and server health.
{ "mcpServers": {
"kompas": { "url": "http://localhost:8770/mcp" } } } // GUI open
{ "mcpServers": {
"kompas": { "command": "KompasMcp.Server.exe", "args": [] } } } // stdio
Downloads, SHA-256 checksums and screenshots of a live run are at kompas.anyks.com. The control window shows what the agent is doing to the model and lets you stop in the middle of an operation.