Skip to content

MCP reference

Christos Georgiou edited this page Nov 25, 2026 · 4 revisions

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.

Setup

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" mcp

Use the full path of the binary when it is not on the PATH of the client:

  • Windows: cgeocad.exe in the folder where you unpacked the zip, with double backslashes in the JSON.
  • macOS: CgeoCAD.app/Contents/MacOS/cgeocad in 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.

How it works

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.

Tools

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" } ] }

Prompts

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.

Behavior

Parameters and builds

  • set_params uses the limits of the Customizer panel. One bad value rejects the whole call.
  • set_params builds 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_state is one of ready, building, needs build, failed, no model, idle and no openscad with manifold.

Optimize

get_optimize returns:

  • state: the values of the Optimize tab, in the form that set_optimize takes.
  • 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 has piece.
  • plate: copies (the copies on the plate) and overflow (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), errors and seconds.

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_proposal of get_optimize is a valid split.
  • "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.

Files

  • export_model writes .stl and .3mf as 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 in too_large. They are in the file, but the printer cannot print them. The plate argument of version 0.7 now gives an error.
  • export_model writes .step as the model as built. When only of the Optimize state names a part, the STEP file has only that part.
  • export_model prepares the plate when it is not ready.
  • export_model and save_photo do not replace a file without overwrite.
  • export_model, save_photo and view_model fail when the last build failed, so that they do not use an old mesh.
  • open_model opens only .scad files. new_model writes only .scad files, and only when the file does not exist. save_photo writes only .png files.
  • export_model and save_photo do not write through a symbolic link.
  • The tools cannot delete a parameter set or a file.

Images

  • view_model and save_photo put the whole model in the frame. They use the camera direction of the window, or the given view.
  • view_model and save_photo show 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_photo stops after 40 seconds and saves the samples it has.

slice

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.

Parts list, checks and units

  • These tools read the marks of the CgeoCAD library in the model. A model without marks gives empty lists and a note.
  • facts are the ids of the parts that a row or a check is about. They are the same in all three tools.
  • value in get_units is the value that the model used in the last build, as text.
  • set_unit checks the value against the type and the limits of the field. A bad value gives an error, and the file does not change. The .scad file never changes. With "wait": true (the default), the call returns the units after the build.
  • The tools wait for a running build, as get_state does.

Plugins and prices

  • 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_list gives the rows of the plugins: for example the raw beams to buy in place of the single angles. get_checks gives the findings of the plugins too.
  • list_library lists the modules of the core library and of the plugins that the model of the window includes.
  • propose_prices writes 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.

set_view: tab and layer

  • mode is model, optimize or render. The names before 0.7, slice and photo, also work.
  • layers: true shows the Layers view of the Optimize tab, false the Plate view, as the switch of the Layers card. get_state shows the value.
  • layer sets 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.
  • projection is iso (parallel projection) or persp (perspective), as the Iso button turns on or off. The Render tab and the photo always use perspective. get_state shows the value.
  • render: true starts the render of the Render tab, as the Render button does. It needs the Render tab, so give mode: "render" in the same call or before it. false stops the render. The tab does not start a render by itself. The render value of get_state has running, samples and of. To save an image, use save_photo.

set_view: explode

  • explode sets 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_axis sets the direction (all, x, y or z) and turns the explode on.

set_view: section

section sets the section cut, for example:

{"x": {"at": 12.5, "keep": "+"}}
  • The object replaces all cuts. An axis that is missing or null has no cut. {} turns all cuts off.
  • at is 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.
  • keep is + (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: at is a position on the bed, and the default is the center of the plate. The plate has its own positions. With mode in the same call, at is in the space of that tab.
  • get_state shows the cuts in the same form, with the positions of the current tab.
  • view_model and save_photo show the cut of the model. No export uses the cut.

Window

  • A minimized window may not answer until you restore it.

Security

  • Each window listens on a free port of 127.0.0.1 and accepts only calls with a random token.
  • The token is in mcp/<pid>.json in 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.

Analytics

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.

Clone this wiki locally