Isolated CAD Worker
The web service sends modeling requests to a supervisor through a private Unix socket. The supervisor starts a disposable Linux container for each build and inspection. The inspector measures the saved document and exports the mesh for OrcaSlicer.
Build the worker image
Run these commands from the Enmesh Studio checkout on a host with Docker and Python 3.11 or later. The example installs the FreeCAD package from Debian. Keep the local images on the worker host.
docker build -f workbench/cad_worker/Dockerfile.freecad -t enmesh-freecad:local .docker build -f workbench/cad_worker/Dockerfile \ --build-arg BASE_IMAGE=enmesh-freecad:local -t enmesh-worker:local .docker image inspect --format '{{.Id}}' enmesh-worker:localRecord the final image ID with the application commit. An image ID identifies the exact bytes of a locally built image. A rebuild can install different Debian package versions. Qualify each new image before enabling it.
Start the supervisor
Create a private socket directory for the supervisor. Give the web service access to that socket. For separate service accounts, use a dedicated group and a group-accessible directory. Give Docker access only to the supervisor account. Keep the Docker socket, provider keys, printer profiles, and application data outside the worker containers.
For a local trial under one account, run these commands from the checkout. Keep the supervisor in its own terminal.
install -d -m 700 "$HOME/.local/run/enmesh"export STUDIO_CAD_SOCKET="$HOME/.local/run/enmesh/cad.sock"export STUDIO_CAD_IMAGE="$(docker image inspect --format '{{.Id}}' enmesh-worker:local)"python3 -m workbench.cad_worker.supervisorSet the same socket path in the web service environment. If the web service runs in a container, mount the private socket directory there. Keep the provider key in the web service. Start the web service with the instructions in the README.
Test and recover
Use a test data directory first. Create a small editable part and request a feature change. Inspect both revisions and compare their dimensions. Slice the child revision with an installed profile. Compare the source and mesh digests with the saved revision.
Before an upgrade, stop the web service and back up the data directory. Keep the old application and image identifiers. Stop the supervisor before replacing its image. If a stopped supervisor leaves a socket file, make sure that the process exited before removing its socket.
To disable authoring, stop the web service and remove its worker socket configuration. Restart the web service. Saved models and reviews remain readable. A committed revision with a verified mesh can still be sliced. Imports and new designs need a running worker.
For a rollback rehearsal, use a separate copy of the data directory. Restore the matching application and image. Open a pre-upgrade design and download its model. Slice a qualified revision with its saved mesh. Compare the source, mesh, and G-code digests with the job receipt. Keep private documents and receipts outside the source repository.
Worker limits and evidence
The supervisor accepts one connection at a time. Each container runs as user 65534 with two CPUs, 2 GiB of memory, and a limit of 64 processes. Docker drops all Linux capabilities and disables networking. The image uses a read-only root filesystem. The input directory is read-only. The output filesystem permits 64 MiB and 128 entries. The supervisor collects only fixed filenames and verifies removal of the container.
The supervisor inspects the document archive before FreeCAD opens it. The inspector accepts a limited set of native object types, properties, and internal references. During inspection, a Python audit hook rejects dynamic imports, compilation, execution, and other listed events. Documents containing unsupported elements can fail inspection. The inspector measures the final solid and sections through its material or voids. A feature measurement identifies the contributing object by name.
Run the worker tests from the checkout against the exact image that you plan to use.
export CAD_WORKER_TEST_IMAGE="$(docker image inspect --format '{{.Id}}' enmesh-worker:local)"python3 -m unittest discover -s tests -p 'test_cad_worker*.py'Inspect the image before granting access to the supervisor. Use a base image without credentials, startup hooks, or extra volumes. Keep the digest, package revisions, and test results together. If container cleanup fails, stop the supervisor and inspect the named worker containers before restarting it.
Connect to a hosted FreeCAD service
Enmesh can send CAD builds to another machine over the Model Context Protocol (MCP). The hosted machine runs the supervisor and its disposable FreeCAD containers. Enmesh keeps the project history and slices the returned mesh.
On the CAD host, start the supervisor as described above. Give the MCP service account access to the supervisor socket. Issue a TLS certificate for the service hostname. Mount a shared bearer token of at least 32 random characters on the CAD host and the Enmesh host. Keep the token outside the repository.
On the CAD host, run the following command from the Enmesh checkout. Use the paths for your certificate, private key, token, and supervisor socket.
STUDIO_CAD_SOCKET=/run/cad/cad.sock \STUDIO_CAD_MCP_TOKEN_FILE=/run/secrets/cad-token \python -m workbench.cad_worker.mcp_server --listen 0.0.0.0 --port 8766 \ --cert /run/tls/service.crt --key /run/tls/service.keyAllow the Enmesh server to reach that port on the private network. Set STUDIO_CAD_MCP_URL on Enmesh to the HTTPS endpoint with path /mcp. Set STUDIO_CAD_MCP_TOKEN_FILE to the mounted token. If the certificate uses a private authority, set STUDIO_CAD_MCP_CA_FILE to its certificate bundle. Start Enmesh with those variables.
In the browser configuration page, select Hosted FreeCAD over MCP and click Test and save. The test checks TLS, the token, the protocol version, and both CAD tools before saving the workspace selection. New operations use that selection. To switch back, select Local FreeCAD worker and test the connection.
The MCP transport specification describes the connection. Enmesh uses stateless HTTPS requests with JSON responses under the MCP 2025-06-18 protocol. The service exposes freecad_build_revision and freecad_inspect_document. Build accepts a program, dimension checks, and an optional parent FCStd document. It returns a new FCStd document, an STL, and the inspection report. Inspection returns an STL and a report for an existing FCStd document. Other FreeCAD MCP servers need to provide these tools and artifact formats to serve as an Enmesh backend.
Enmesh can include native sketch helpers in the saved design program. The loft helpers join circular or polygonal sections on parallel planes. The polygon helper extrudes a closed outline. These helpers create editable PartDesign bodies and run inside the CAD worker. The saved source includes the helper definitions so an existing hosted worker can build the same program.