MCP examples
Build and export a local project
This executable workflow uses the local project store. It creates a temporary project, adds an 80 × 56 × 3 mm mounting plate, reads the resulting scene, exports an .skf file, and removes the temporary directory when it exits. It does not need a browser, running editor, or API token.
For the .skf file's archive layout, validation, and compatibility behavior, see the project format guide and generated format reference. REST-based automation is covered separately in the REST API guide.
From the repository root, run the checked command below. It builds the engine and then runs the isolated workflow:
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
cd "$repo_root"
npm run engine:build >&2
node docs/mcp/examples/local-project.mjsThe example source starts the repository MCP server, reads the current tools/list registry, validates each tool argument against its advertised input schema, and then invokes those tools over JSON-RPC. The MCP tool reference lists the complete current registry and schemas. The executable contract is checked by tests/docs/mcp-examples.test.mjs.
This example operates on a temporary local project directory and deletes it in a finally block. To target a live editor or a persistent local project, follow the setup and targeting guidance in the SketchForge MCP skill.
Import, inspect, and export an STL
This second executable workflow creates a temporary project, imports a tetrahedron STL with the local-only compatibility alias, reads its exact shape properties, exports the scene as STL, and removes the temporary files when it exits. The STL fixture is generated by the example, so no external file or API token is needed.
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
cd "$repo_root"
npm run engine:build >&2
node docs/mcp/examples/local-stl-import.mjsThe example source validates each call against the current tools/list schema before invoking it. The import source and exported STL are both kept inside the temporary project directory, matching the configured MCP file-root rules.
Documentation version: 1.30.0 · Repository revision: 1cb9fee8dff4d394684c229dd67a21da539d167f · View source