Repository navigation
MCP reference
Advanced topic. This page is for technical readers. For a simple introduction, see AI assistant.
CgeoCAD has an MCP server, so that an AI client can work with the open window. The client can read the model and its parameters, change values, see the result as an image, prepare the print plate, and run app commands.
Add the server to the client. For Claude Desktop, edit claude_desktop_config.json and restart Claude Desktop:
{
"mcpServers": {
"cgeocad": {
"command": "cgeocad",
"args": ["mcp"]
}
}
}For Claude Code:
claude mcp add cgeocad -- "cgeocad" mcpUse the full path of the binary when it is not on the PATH of the client:
- Windows:
cgeocad.exein the folder where you unpacked the zip, with double backslashes in the JSON. - macOS:
CgeoCAD.app/Contents/MacOS/cgeocadin Applications.
The step Connect an agent of the welcome tour shows both texts with the path of the running program.
Version 0.8 had the name CoCAD and the command cocad mcp. That command does not exist any more: change the command to cgeocad and the server name to cgeocad.
The client starts cgeocad mcp. This process has no window. It sends each tool call to the open window, and you see the changes there. open_model and new_model start the app when it is not running.
| Tool | Action |
|---|---|
get_state |
Loaded file, build status, last error, mesh data, changed parameters, parameter sets, the model definition (file, title, description, problems), tab, parts and reference parts, part colors, explode, section cut, the copies on the plate of the Optimize tab (plate_copies), end of the OpenSCAD log |
get_params |
All Customizer parameters with type, value, default, limits and options |
get_source |
Source of the .scad file |
view_model |
Render an image and return it to the client |
open_model |
Open a .scad file |
new_model |
Write a new .scad file and open it. Without source, the file gets a box with four parameters |
set_params, reset_params
|
Change parameters or reset them, then build |
build |
Build the model: run OpenSCAD again. The name before 0.7, render, also works. |
load_parameter_set, save_parameter_set
|
Load or save a parameter set. The sets are in <model>.yml. |
get_optimize |
The print preparation of the Optimize tab: the state and the result |
set_optimize |
Change the print preparation of the Optimize tab |
export_model |
Write the plate as STL or 3MF, or the model as STEP. With slicer, write a multicolor 3MF |
save_photo |
Write a path traced PNG |
slice |
Slice the plate and return layers, filament, weight and a rough print time |
set_view |
Change the tab, camera direction, projection, wireframe, grid, Layers view, part colors, explode, section cut and the layer of the Optimize tab. Start or stop the render of the Render tab |
list_windows, select_window
|
Choose a window when more than one is open |
list_library |
List the modules of the CgeoCAD library: name, signature, text, values and an example. Needs no window |
get_parts_list |
Get the parts list of the model: { "rows": [ { "key", "label", "size", "qty", "make", "facts" } ] }
|
get_checks |
Get the checks of the model: { "findings": [ { "level", "code", "text", "facts" } ] }
|
get_units |
Get the units of the model: { "units": [ { "id", "fact", "fields": [ { "key", "type", "default", "value" } ] } ] }
|
set_unit |
Set one value of a unit: { "unit", "key", "value" }. The value goes to the .yml file and the model builds again. null removes the value |
list_plugins |
List the plugins: id, name, version, library, if the model includes it, tabs and documents |
list_actions |
List the actions of the plugins that the model includes: { "actions": [ { "plugin", "id", "title", "read_only" } ] }
|
run_action |
Run an action of an included plugin: { "plugin", "action", "input" }. Gives its JSON answer. For example cut_plan of slotted-angle
|
get_price_items |
Get the items to price: key, description, size, needed amount, unit, currency, state and the preferred shops. filter: missing (default), old or all
|
propose_prices |
Propose prices for many items in one call: { "offers": [ { "item", "price", "currency", "pack_amount", "unit", "shop", "date", "product", "link" } ] }. link is optional |
set_preferred_shops |
Set the shops of the user: { "shops": [ { "name", "town" } ] }
|
The server has the prompts capability. The prompt fill_prices (title "Fill prices") gives an assistant the rules to fill the missing prices: real products only, no guess, one offer for each item with its link, and a list of the items that it did not find.
-
set_paramsuses the limits of the Customizer panel. One bad value rejects the whole call. -
set_paramsbuilds the model by default. With"build": false, the app follows its Auto build switch. The name before 0.7,render, also works. - Calls wait for the build, for at most 45 seconds. Then they return the state with status
building, or an error. - The status of
get_stateis one ofready,building,needs build,failed,no model,idleandno openscad with manifold.
get_optimize returns:
-
state: the values of the Optimize tab, in the form thatset_optimizetakes. -
parts: one entry for each print part:name,count,copies,fits,size_mm,orientation,issues(the problems of the Check card),fixes(the number of places that each fix changed, and the places that it skipped), and for a part that does not fit,split_proposal. A piece of a split part haspiece. -
plate:copies(the copies on the plate) andoverflow(true when the parts need more room than the bed. The slicer arranges them on its plates). -
summary(the text that shows when you hold the mouse on Export 3MF),errorsandseconds.
There is one plate. All print parts are on it, also a part that is too large for the print area. The print area sets the fit of each part and the split proposals.
set_optimize merges the given keys into the state, as a JSON merge patch: objects merge key by key, and null removes a key. Then it waits for the plate and returns the result as get_optimize does.
| Key | Value |
|---|---|
area |
The print area [width, depth, height] in mm |
gap |
The gap between the parts on the plate, in mm |
only |
The name of one print part, or null for all parts |
fixes |
teardrops, bridges, hole_above (sacrificial or stepped), sacrificial_layers, chamfer, chamfer_mm, brim, brim_w, brim_gap, ears, ear_d, ear_min, hole_size, hole_add
|
parts |
The values of each print part, by name: include, orient (model, auto or face), down (with face: the direction of the model that goes down), turns (quarter turns on the bed) and split: joint (flat, pins or dovetail), cuts (a list of [axis 0 to 2, position in mm]), clearance, and the sizes in mm pin_d, pin_depth, tab_root, tab_tip, tab_depth, tab_pitch
|
For example, this call turns on the bed chamfer, puts the part "Clip" on its best face and splits the part "Plate" with a dovetail joint at x = 130 mm:
{
"fixes": {"chamfer": true},
"parts": {
"Clip": {"orient": "auto"},
"Plate": {"split": {"joint": "dovetail", "cuts": [[0, 130]], "clearance": 0.2}}
}
}- A
split_proposalofget_optimizeis a validsplit. -
"parts": {"Lid": null}gives the part "Lid" its default values again. - An unknown key rejects the call.
- All fixes are off until you turn them on.
-
export_modelwrites.stland.3mfas the window does: the plate of the Optimize tab, with all print parts in print position and the fixes that are on. A plate 3MF has one object for each print part and one build item for each copy. When print parts are too large for the print area, the reply lists them intoo_large. They are in the file, but the printer cannot print them. Theplateargument of version 0.7 now gives an error. -
export_modelwrites.stepas the model as built. Whenonlyof the Optimize state names a part, the STEP file has only that part. -
export_modelprepares the plate when it is not ready. -
export_modelandsave_photodo not replace a file withoutoverwrite. -
export_model,save_photoandview_modelfail when the last build failed, so that they do not use an old mesh. -
open_modelopens only.scadfiles.new_modelwrites only.scadfiles, and only when the file does not exist.save_photowrites only.pngfiles. -
export_modelandsave_photodo not write through a symbolic link. - The tools cannot delete a parameter set or a file.
-
view_modelandsave_photoput the whole model in the frame. They use the camera direction of the window, or the givenview. -
view_modelandsave_photoshow the model as built, with the part colors, the explode and the section cut of the window, as the Render tab does. They do not show the reference parts. When the part colors or the explode are on and CgeoCAD still finds the parts, they wait for the parts, for at most 45 seconds. -
save_photostops after 40 seconds and saves the samples it has.
slice slices the plate of the Optimize tab, with the fixes. Given values (layer_height, first_layer, line_width, walls, infill, solid_layers, speed) also change the print settings of the window. The result has the layers, the path and filament length, the weight and a rough print time in minutes.
- These tools read the marks of the CgeoCAD library in the model. A model without marks gives empty lists and a
note. -
factsare the ids of the parts that a row or a check is about. They are the same in all three tools. -
valueinget_unitsis the value that the model used in the last build, as text. -
set_unitchecks the value against the type and the limits of the field. A bad value gives an error, and the file does not change. The.scadfile never changes. With"wait": true(the default), the call returns the units after the build. - The tools wait for a running build, as
get_statedoes.
- The tools of the plugins work on the plugins that the model includes. The MCP cannot include or install a plugin. A call for a plugin that the model does not include gives an error that tells this.
- With plugins,
get_parts_listgives the rows of the plugins: for example the raw beams to buy in place of the single angles.get_checksgives the findings of the plugins too. -
list_librarylists the modules of the core library and of the plugins that the model of the window includes. -
propose_priceswrites proposals. The user accepts them in the window. A proposal never replaces a price that the user typed or locked. An offer with a different unit or currency is refused with the reason. - The price tools need the price list plugin in the model.
An AI assistant can design a model this way: read list_library, write the .scad file with its own file tools, call build, then read get_parts_list, get_checks and view_model.
-
modeismodel,optimizeorrender. The names before 0.7,sliceandphoto, also work. -
layers: trueshows the Layers view of the Optimize tab,falsethe Plate view, as the switch of the Layers card.get_stateshows the value. -
layersets the layer of the Optimize tab, from 1. The slice is ready some time after the Layers view opens: set the layer in a later call. -
projectionisiso(parallel projection) orpersp(perspective), as the Iso button turns on or off. The Render tab and the photo always use perspective.get_stateshows the value. -
render: truestarts the render of the Render tab, as the Render button does. It needs the Render tab, so givemode: "render"in the same call or before it.falsestops the render. The tab does not start a render by itself. Therendervalue ofget_statehasrunning,samplesandof. To save an image, usesave_photo.
-
explodesets the explode distance in mm. 0 turns the explode off. A distance above the end of the slider uses the end of the slider. -
explode_axissets the direction (all,x,yorz) and turns the explode on.
section sets the section cut, for example:
{"x": {"at": 12.5, "keep": "+"}}- The object replaces all cuts. An axis that is missing or
nullhas no cut.{}turns all cuts off. -
atis the position in mm. The default is the center of the model. A position out of the slider range uses the end of the range. -
keepis+(keep the side above the position) or-(keep the side below). The default is+. - The cuts and the sides to keep stay in all tabs. In the Optimize tab, the cuts go across the plate:
atis a position on the bed, and the default is the center of the plate. The plate has its own positions. Withmodein the same call,atis in the space of that tab. -
get_stateshows the cuts in the same form, with the positions of the current tab. -
view_modelandsave_photoshow the cut of the model. No export uses the cut.
- A minimized window may not answer until you restore it.
- Each window listens on a free port of
127.0.0.1and accepts only calls with a random token. - The token is in
mcp/<pid>.jsonin the settings folder, which only your user can read. - Any program that runs as your user can read that file and control the window, and write files through the export tools.
The server is on by default. To turn it on or off, use MCP server in File > Settings. The change applies when you save. Other open windows change at their next start.
If usage analytics are on, open_model, new_model and a set_view call that changes the mode send events. The other tools send no event. The cgeocad mcp process itself sends nothing. See Privacy.
Home · Glossary · Problems and answers · Download · Website
The source of these pages is the docs/wiki/ folder of the repository. Changes that you make on the wiki website are lost at the next update.
Start
Look at the model
Furniture
Projects
More
Advanced