layerlingInstrukcja
Polski
Otwórz edytor

Building with an AI (MCP)

How an AI assistant such as Claude or Codex creates and changes shapes, groups them and takes pictures of the view in your open editor.

Ten rozdział nie jest jeszcze przetłumaczony na polski. Poniżej tekst angielski.

layerling comes with an MCP server. MCP is a standard through which an AI assistant can use tools in other programs. With it an AI client such as Claude or Codex sees an open editor tab and works in it: it creates shapes, changes dimensions, groups, cuts, rounds edges, reads out the scene and takes pictures of the view. You describe the part, the AI builds it, you watch and can step in at any moment.

The bridge between AI client and editor runs locally on your computer. Keep in mind, though: what the AI reads, meaning the scene and the pictures of the view, goes to the provider of your AI client, like any other input there.

Setting up

  1. Get layerling from GitHub and start it in the project folder with npm run dev. Node.js must be installed. On Windows the quick-start line in the README takes care of that.
  2. Open an editor tab, for example http://127.0.0.1:3000/?editor=1. You can leave that to the AI: when no editor is open, the first tool that needs one starts your browser with an editor and waits until it has connected. That works for a layerling on your own computer; a copy on a NAS or server needs you to open the editor. Set LAYERLING_MCP_OPEN_EDITOR=0 for the MCP server to switch it off.
  3. Connect your AI client to the MCP server. The client starts it itself with node scripts/layerling-mcp-server.mjs.

Claude Code

Nothing to install: the project brings a .mcp.json that registers the server, and the skill under .claude/skills/layerling-mcp-skill. Open the layerling folder in Claude Code and ask, for example: "Use the layerling MCP tools to list my open editors and inspect the scene."

Claude Desktop

Claude Desktop does not read project files. Enter the server in its own configuration. As a template use docs/mcp/claude-desktop-config.example.json in the project, replacing the script path with the absolute path on your computer. Then restart Claude Desktop.

Codex

Copy the skill from docs/skills/layerling-mcp-skill into your Codex skills folder, enter the server in your Codex configuration using docs/mcp/codex-config.example.toml, and restart Codex.

The detailed instructions for all three are in the README on GitHub.

A copy on a NAS or server

A copy you host yourself can let an AI client drive its open editors over the network. It is off by default, because whoever can drive the bridge can read and change the open designs. On the server, set LAYERLING_MCP_REMOTE to true and LAYERLING_MCP_TOKEN to a secret of at least 16 characters (for the Docker image in environment: of the compose file; no rebuild needed). Open an editor tab of that copy and keep it open, and give the MCP client the address and the same token: LAYERLING_URL=http://nas:3000 and LAYERLING_MCP_TOKEN=<the token>.

Only a client with the token can list or drive the editors. The editor pages need none, but they only count under an address or name that only your own network can use (an IP address, a name without a dot, or one ending in .local or .lan); a real domain behind a reverse proxy goes into LAYERLING_MCP_ALLOWED_HOSTS. Use it on a network you trust, and HTTPS beyond it. The README has the details.

What the AI can do

The AI works with the same functions as you, through the same path as your operation in the editor. New layerling functions get their MCP action right away. The tools:

ToolWhat it does
layerling_list_editorslists the open editor tabs
layerling_open_editoropens a new editor tab in your default browser and waits until it has connected (on your own computer only)
layerling_read_scenereads scene, selection, units and the exact dimensions of all objects
layerling_list_objectslists all objects with dimensions, position, rotation and id
layerling_select_objectsselects objects
layerling_delete_objectsdeletes objects
layerling_create_shapecreates a shape: box, cylinder, text (also curved), thread, gear, sketch body and all the others
layerling_import_fileimports a file as the import window does, a coloured OBJ or 3MF as one body per colour, a 3MF with several objects as one body per object
layerling_add_fontadds a font of one's own for text from a TrueType, OpenType or WOFF file; it stays in the browser, a design keeps only the letters it uses
layerling_list_fontslists the built-in fonts and the fonts of one's own, with id and name
layerling_import_meshbrings a triangle mesh into the design
layerling_update_objectchanges dimensions, position, colour, name, solid or hole and everything else that makes up the shape, a text's letter edge included
layerling_align_objectsaligns objects with each other
layerling_scale_objectsscales objects by a percentage, together or each in place
layerling_lay_flatlays an object with one face on the plate
layerling_place_on_facesets objects down on a face of another, sloped ones too, like the C key
layerling_perforate_facecuts a hole pattern into a flat face; the holes stay as holes grouped with the body
layerling_mate_facesbrings a face of one object against a face of another, face to face or flush
layerling_open_groupopens a group so its parts can be changed one by one, also a group inside an open one
layerling_close_groupcloses it again ("Done") or cancels
layerling_group_objectsgroups objects
layerling_ungroup_objectsdissolves groups
layerling_boolean_cutcuts solids with holes
layerling_intersect_objectskeeps only what the objects have in common (Intersection)
layerling_separate_partsseparates a shape into its loose parts
layerling_split_objectscuts solids or holes in two with a plane
layerling_list_edgeslists the real CAD edges of an object
layerling_apply_edge_treatmentchamfers or fillets chosen edges
layerling_hollow_objecthollows a body with an even wall
layerling_array_objectsmultiplies in a row or on a circle
layerling_bundle_objectsbundles objects like Ctrl+B: they move together, keep their colour and kind and go out separately in an export
layerling_layer_textturns a text into a stack of layers for a multicolour print (letters, wider rims, a plate without holes) or builds a stack again, with a key ring hole, the corners per layer and a rounded or chamfered letter edge; with a name list, one tag per name
layerling_layer_iconturns an SVG icon (the text of the file, or an extruded sketch body) into a layered icon tag for a multicolour print - the icon, wider rims, a plate without holes - or builds one again with a new width or layers; with a count it fills the plate with copies
layerling_measure_sectionmeasures on a cutting plane between two points that snap to the outline - wall thickness, gaps, fits
layerling_show_overhangsswitches the overhang hatching on or off, sets the angle and reports for each body the area that would need supports
layerling_estimate_printestimates volume, weight and filament for the selection or the whole design: for a solid body, and as a rough guess with walls and infill like the export window
layerling_add_reference_pointsmarks reference points - on the centre, corners or edge middles of objects, or at exact positions - that shapes snap to
layerling_list_reference_pointslists the reference points with their ids and positions
layerling_remove_reference_pointsdeletes reference points by id, or all of them
layerling_inspect_errorsshows the last message and the last error, plus the messages and errors of the session
layerling_wrap_around_cylinderwraps a body lying flat, an SVG or text for example, around a cylinder, outward or inward as an engraving
layerling_simplify_meshreduces the triangle count of an imported mesh, to a share in percent or to a number of triangles
layerling_save_custom_shapekeeps bodies as a custom shape, on the server or in the browser, to insert them into other designs
layerling_list_custom_shapeslists the custom shapes on the server and in the browser
layerling_insert_custom_shapeinserts a custom shape into the open design, at a spot x/z if you like
layerling_delete_custom_shaperemoves a custom shape; inserted bodies stay
layerling_show_workplanehides and shows the plate with its grid, for a picture of the underside for example (only the view)
layerling_set_section_viewcuts the view open along a plane to look inside (only the view, nothing is cut apart)
layerling_clear_historydeletes every undo step for good, as the History view's "Delete history" button does; needs confirm: true
layerling_set_history_viewlooks back at an earlier state of the project, like the History view (the real design stays untouched; changing tools wait until it is closed)
layerling_export_section_svgreturns the outlines on a cutting plane as an SVG at 1:1, from the same bodies as the export
layerling_export_drawingmakes the workshop drawing of the "2D" export: three views at 1:1 on an ISO sheet with overall sizes and a table of the round bores, as SVG text or PDF
layerling_set_workplaneputs the workplane on a side of a body or back on the base plate, and hides or shows it
layerling_capture_imagetakes a picture of the view: front, top, side, diagonally from a corner and more

That lets the AI check itself: it creates something, takes a picture, looks and improves.

An example

You say: "Build me a round box 60 mm across, 40 mm high with a 2.5 mm wall, open at the top, plus a flat lid with 'Tea' written in an arc." The AI creates the cylinders, hollows one, puts the curved text on the lid and takes pictures at the end to see whether it fits.