diff --git a/README.md b/README.md index 6de3fbe..43c9cda 100644 --- a/README.md +++ b/README.md @@ -51,15 +51,14 @@ No login. No server project storage. No heavyweight CAD install just to make a u ## Getting Started -There are three common ways to run SketchForge. If you are not sure which one to choose, use Docker. +There are two common ways to run SketchForge. If you are not sure which one to choose, use Docker. | Path | Best for | Difficulty | | --- | --- | --- | | Docker / FabLab server | Teachers, classrooms, shared computers, local network hosting | Recommended | | Local development | Developers who want to edit the code | Medium | -| Manual static hosting | Server admins who cannot use Docker | Advanced | -SketchForge is local-first in all three modes. The app files may be served from a computer or server, but projects stay in each user's browser storage. STL and OBJ exports download through the user's browser. SketchForge does not upload models to a SketchForge cloud service. +SketchForge is local-first in both modes. The app files may be served from a computer or server, but projects stay in each user's browser storage. STL and OBJ exports download through the user's browser. SketchForge does not upload models to a SketchForge cloud service. ### Download the Project @@ -276,55 +275,6 @@ Build a static export: npm run export ``` -## Manual Static Deployment (Advanced) - -Use this only if Docker is not allowed on your server. This path is harder because you must install and maintain Node.js, npm, a static web server, firewall rules, startup behavior, and future updates yourself. - -### What You Need - -- Node.js 20 or newer -- npm -- Nginx, Apache, Caddy, or another static web server -- permission to open a network port on the server firewall - -### Build the Static Files - -Linux or macOS: - -```bash -npm ci -STATIC_EXPORT=true npm run build -``` - -Windows PowerShell: - -```powershell -npm ci -$env:STATIC_EXPORT = "true" -npm run build -Remove-Item Env:STATIC_EXPORT -``` - -The deployable files are created in: - -```text -apps/web/out -``` - -Configure your web server to serve `apps/web/out`. - -For single-page app routing, unknown paths should fall back to: - -```text -index.html -``` - -The Docker Nginx config is a good reference: - -[`deploy/docker/nginx.conf`](deploy/docker/nginx.conf) - -For each update, pull or download the new source, install dependencies, rebuild `apps/web/out`, replace the served files, and reload the web server. - ## Project Layout ```text @@ -337,6 +287,8 @@ apps/web/src/lib/ Shared utilities apps/web/public/assets/ Static app images, icons, logos, shape assets scripts/ Build and local automation helpers docs/media/ README screenshots and demo videos +docs/mcp/ MCP client configuration examples +docs/skills/ Optional AI-agent skill bundles deploy/docker/ Docker, Compose, and Nginx deployment files .github/ Issue templates and community files ``` @@ -377,3 +329,74 @@ Please do not open public issues for security-sensitive reports. Read [.github/S ## License MIT. See [LICENSE](LICENSE). + +## SketchForge MCP Skill + +SketchForge includes a local MCP server for AI clients that support MCP tools. It lets an agent inspect and control a live local editor tab: list open editors, read the scene, create/update/select objects, group/cut/separate parts, list CAD edge ids, apply chamfer or fillet, inspect errors, and capture viewport images. + +This is for local development only. Run SketchForge with `npm run dev`; the MCP route is disabled in production builds and Docker/static hosting. + +### Start SketchForge for MCP + +From the SketchForge project folder: + +```bash +npm install +npm run dev +``` + +Open an editor tab: + +```text +http://127.0.0.1:3000/?editor=1 +``` + +The AI client starts the MCP server with: + +```bash +node scripts/sketchforge-mcp-server.mjs +``` + +### Codex + +The Codex skill is included at: + +```text +docs/skills/sketchforge-mcp-skill +``` + +Install it into your Codex skills folder. + +Windows PowerShell: + +```powershell +New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex\skills" | Out-Null +Copy-Item -Recurse -Force "docs\skills\sketchforge-mcp-skill" "$env:USERPROFILE\.codex\skills\sketchforge-mcp-skill" +``` + +macOS or Linux: + +```bash +mkdir -p ~/.codex/skills +cp -R docs/skills/sketchforge-mcp-skill ~/.codex/skills/ +``` + +Then add an MCP server entry to your Codex config. Use [`docs/mcp/codex-config.example.toml`](docs/mcp/codex-config.example.toml) as the template and replace the script path with the absolute path on your machine. Restart Codex after changing the config. + +Once installed, ask Codex: + +```text +Use $sketchforge-mcp-skill to list my open SketchForge editors and inspect the current scene. +``` + +### Claude + +Claude does not use Codex `SKILL.md` files, but it can use the same SketchForge MCP server. Add the server to Claude Desktop's MCP config using [`docs/mcp/claude-desktop-config.example.json`](docs/mcp/claude-desktop-config.example.json) as the template, replacing the script path with the absolute path on your machine. + +After restarting Claude Desktop, ask: + +```text +Use the SketchForge MCP tools to list open editors, inspect the scene, and modify the selected object. +``` + +The main tool names are `sketchforge_list_editors`, `sketchforge_read_scene`, `sketchforge_list_objects`, `sketchforge_create_shape`, `sketchforge_update_object`, `sketchforge_list_edges`, `sketchforge_apply_edge_treatment`, and `sketchforge_capture_image`. diff --git a/docs/mcp/claude-desktop-config.example.json b/docs/mcp/claude-desktop-config.example.json new file mode 100644 index 0000000..4f4cec7 --- /dev/null +++ b/docs/mcp/claude-desktop-config.example.json @@ -0,0 +1,10 @@ +{ + "mcpServers": { + "sketchforge": { + "command": "node", + "args": [ + "/absolute/path/to/SketchForge-3D/scripts/sketchforge-mcp-server.mjs" + ] + } + } +} diff --git a/docs/mcp/codex-config.example.toml b/docs/mcp/codex-config.example.toml new file mode 100644 index 0000000..47616ed --- /dev/null +++ b/docs/mcp/codex-config.example.toml @@ -0,0 +1,10 @@ +# Copy this server block into your Codex config.toml and replace the script +# path with the absolute path to your SketchForge checkout. +# +# Windows paths can use forward slashes: +# C:/Users/you/Desktop/SketchForge-3D/scripts/sketchforge-mcp-server.mjs + +[mcp_servers.sketchforge] +command = "node" +args = ["/absolute/path/to/SketchForge-3D/scripts/sketchforge-mcp-server.mjs"] +startup_timeout_sec = 20 diff --git a/docs/skills/sketchforge-mcp-skill/SKILL.md b/docs/skills/sketchforge-mcp-skill/SKILL.md new file mode 100644 index 0000000..27c1fa6 --- /dev/null +++ b/docs/skills/sketchforge-mcp-skill/SKILL.md @@ -0,0 +1,92 @@ +--- +name: sketchforge-mcp-skill +description: Control a live local SketchForge editor through its MCP server. Use when Codex needs to list currently open SketchForge editor tabs, target a tab by editorNumber/projectName, read the current scene, list or select objects, create boxes/cubes/cylinders/sketch extrusions, update dimensions/position/rotation, align objects, group/ungroup/cut/separate parts, list exact CAD edge ids, apply chamfer/fillet to specific edges, inspect editor errors, or capture viewport images from view-cube angles. +--- + +# SketchForge MCP + +## Quick Start + +Use this skill only with a local SketchForge app running in development mode. + +1. Start SketchForge from the repo: + +```bash +npm run dev +``` + +2. Open an editor tab at `http://localhost:3000/?editor=1`. + +3. Configure your MCP client to start the stdio server: + +```bash +node scripts/sketchforge-mcp-server.mjs +``` + +The MCP server talks to the app through `/api/sketchforge-mcp`. Open editor tabs heartbeat into that route and receive commands from it. Production and Docker/static builds intentionally return 404 for the MCP route. + +## Client Compatibility + +Codex can use this folder as a skill and the MCP server as tools. Install the folder under `~/.codex/skills/sketchforge-mcp-skill` and configure the MCP server in Codex. + +Claude Desktop does not read Codex skills, but it can use the same `scripts/sketchforge-mcp-server.mjs` MCP server through Claude's `mcpServers` JSON config. Use the repository README for client setup examples. + +## Targeting Editors + +Always call `sketchforge_list_editors` first when the user mentions multiple projects, tabs, or a number like `49536`. + +Use `editorNumber` for follow-up commands. It is a 5-digit per-tab number stored in browser `sessionStorage`, so two open SketchForge tabs have different numbers. The list also includes `projectName`, `projectId`, URL, shape count, selected count, notice, and last error. + +If only one editor is open, commands may omit `editorNumber`; the server will target the sole live editor. + +## Core Workflow + +Read scene/object state before modifying geometry: + +```text +sketchforge_list_editors +sketchforge_read_scene({ editorNumber }) +sketchforge_list_objects({ editorNumber }) +``` + +For object edits, use exact object `id` values from the scene. Do not invent object names; names are helpful labels only. + +Useful tools: + +- `sketchforge_select_objects`: select ids in the live editor. +- `sketchforge_delete_objects`: delete ids in the live editor, or delete the current selection when ids are omitted. +- `sketchforge_create_shape`: create `box`, `cube`, `cylinder`, or `sketch`. +- `sketchforge_import_mesh`: import STL-style mesh data into the editor. +- `sketchforge_update_object`: set exact dimensions, position, color, name, hole state, and `rotation`/`rotationX`/`rotationZ`. +- `sketchforge_align_objects`: align two or more ids using the same logic as the editor Alignment button. +- `sketchforge_group_objects`: group selected ids using the normal SketchForge group/boolean path. +- `sketchforge_boolean_cut`: pass `solidIds` and `holeIds`; the result replaces the operands. +- `sketchforge_ungroup_objects`: restore grouped children while preserving edited child geometry. +- `sketchforge_separate_parts`: split disconnected parts in one object. +- `sketchforge_inspect_errors`: read the editor notice, edge modifier error, and last MCP error. + +## Edge Features + +Chamfer and fillet are separate edge-treatment operations in SketchForge. Do not fake a chamfer/fillet with cylinders or extra decorative geometry. Cylinders are only appropriate when the requested shape itself has a circular/rounded 2D footprint, such as rounded tray corners or a cylindrical peg. + +For chamfer/fillet, never guess edge ids. + +1. Call `sketchforge_list_edges({ editorNumber, id, sharpAngle })`. +2. Use returned `selectableEdgeIds` or inspect returned edge geometry. +3. Call `sketchforge_apply_edge_treatment({ editorNumber, id, kind, edgeIds, amount, chamferAngle })`. + +`edgeIds` can be an array of numeric ids or `"all"`. `kind` is `chamfer` or `fillet`. The app commits the result through normal history, so undo/redo works. + +## Images + +Use `sketchforge_capture_image` for viewport PNGs. `face` can be `current`, `home`, `top`, `bottom`, `front`, `back`, `right`, or `left`. These use the same camera/view-cube orientation logic as the editor UI. + +## Visual Verification + +After creating or heavily modifying an object, use vision when available. Capture at least one useful viewport image with `sketchforge_capture_image`; for 3D geometry, prefer `home` plus any needed orthographic-style faces such as `top`, `front`, or `right`. Inspect the rendered result against the user's requirements before saying the task is done. + +Do not rely only on numeric scene data when the user asked for a physical object. Use numeric checks for dimensions and visual checks for whether the model reads correctly. + +## Safety + +This bridge is local-development only. If a command fails, call `sketchforge_inspect_errors` before retrying. For geometry operations that can be expensive, set a larger `timeoutMs` on the tool call. diff --git a/docs/skills/sketchforge-mcp-skill/agents/openai.yaml b/docs/skills/sketchforge-mcp-skill/agents/openai.yaml new file mode 100644 index 0000000..c7774df --- /dev/null +++ b/docs/skills/sketchforge-mcp-skill/agents/openai.yaml @@ -0,0 +1,4 @@ +interface: + display_name: "SketchForge MCP Skill" + short_description: "Control live SketchForge editor tabs" + default_prompt: "Use $sketchforge-mcp-skill to inspect the live SketchForge scene and modify selected objects."