Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
"name": "shapeitup",
"description": "CAD scripting toolkit: create/modify .shape.ts files, validate geometry, check collisions, export STEP/STL/3MF via Replicad + OpenCascade. Runs headless; live 3D preview available if the ShapeItUp VS Code extension is installed.",
"version": "1.30.0",
"version": "1.30.1",
"author": {
"name": "Asbjorn Rorvik",
"email": "rorvik.asbjorn@gmail.com"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Test @shapeitup/core
run: pnpm --filter @shapeitup/core exec vitest run

- name: Test @shapeitup/shared
run: pnpm --filter @shapeitup/shared exec vitest run

- name: Test shapeitup-vscode (extension)
run: pnpm --filter shapeitup-vscode exec vitest run

Expand Down
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@ Releases 1.17.0–1.24.0 are described only in their
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); the
project follows semantic versioning at the extension level.

## [1.30.1] - 2026-10-12

Extension `1.30.1` / mcp-server `1.30.1` — Codex setup docs and three fixes.

### Added
- **Codex setup in the docs** (`README.md`, `packages/mcp-server/README.md`,
`INSTALL.md`, shapeitup.dev). `codex mcp add`, then `startup_timeout_sec = 60`
and `tool_timeout_sec = 180` in `~/.codex/config.toml`. Codex's defaults are
10 s to start and 60 s per tool; a first `npx` run from an empty cache took
34 s, so a fresh install timed out before it answered. The skill goes in
`~/.agents/skills/shapeitup/`, where Codex looks for skills.

### Fixed
- **On macOS the MCP server and the VS Code extension never found each
other.** The server hardcoded `~/.config/Code/...` on every non-Windows OS,
but VS Code on macOS keeps globalStorage under
`~/Library/Application Support/Code/...`. The extension never saw the
server's heartbeat, so live viewer sync, `set_render_mode`,
`toggle_dimensions` and workspace-root detection silently did nothing there.
The server now follows VS Code's own rules (`APPDATA` on Windows,
`XDG_CONFIG_HOME` on Linux) and, when the extension runs in Cursor,
VS Code Insiders, VSCodium or Windsurf, uses that editor's directory.
- **Every render warned `Import "sim" will always be undefined`** unless the
file exported `sim`. The filter for the wrapper's optional exports predated
`sim`. Both bundlers now use one list in `@shapeitup/shared`, and a test
fails if the wrapper gains a name the filter doesn't cover.
- **Published builds signed every tool result `[shapeitup mcp vdev …]`.** The
version lookup used `__dirname`, which doesn't exist in the ESM bundle. It
now uses the version esbuild bakes in, as `serverInfo` already did.

### Changed
- CI now runs the `@shapeitup/shared` tests.

## [1.30.0] - 2026-09-30

Extension `1.30.0` / mcp-server `1.30.0` — Mistral Vibe support
Expand Down
47 changes: 42 additions & 5 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Check for each of these (absence of one is fine — just skip that client):

- **Claude Code CLI**: `which claude` succeeds, OR `~/.claude.json` exists,
OR `~/.claude/` exists.
- **Codex** (CLI, IDE extension or ChatGPT desktop app — they share one
config): `which codex` succeeds, OR `~/.codex/` exists.
- **Cursor**: `~/.cursor/mcp.json` exists, OR the Cursor app is installed
(`/Applications/Cursor.app` on macOS, `%LOCALAPPDATA%\Programs\cursor` on
Windows).
Expand Down Expand Up @@ -81,6 +83,35 @@ Fallback if `claude mcp add` isn't available: merge this into `~/.claude.json`:
`mcpServers.shapeitup` entry, write back. If the file is malformed, stop and
tell the user.

#### Codex

Preferred: use the CLI.

```bash
codex mcp add shapeitup -- npx -y @shapeitup/mcp-server
```

Then open `~/.codex/config.toml` and make sure the `[mcp_servers.shapeitup]`
table carries both timeouts. Add the two keys if they are missing; leave
everything else in the file alone:

```toml
[mcp_servers.shapeitup]
command = "npx"
args = ["-y", "@shapeitup/mcp-server"]
startup_timeout_sec = 60
tool_timeout_sec = 180
```

Fallback if `codex` isn't on the PATH (the desktop app alone doesn't add it):
append that table to `~/.codex/config.toml`, creating the file if missing. If
the file already has a `[mcp_servers.shapeitup]` table, edit it instead —
TOML rejects a table defined twice.

Keep both timeouts. Codex gives a server 10 s to start by default, which is
shorter than the first `npx` download, and a tool 60 s, which a cold render of
complex geometry can exceed. Tell the user to restart Codex.

#### Cursor

Merge into `~/.cursor/mcp.json` (create if missing):
Expand Down Expand Up @@ -154,12 +185,16 @@ curl -fsSL https://raw.githubusercontent.com/asbis/ShapeItUp/master/skills/shape
If Mistral Vibe is present, the same file works there unchanged: write it to
`~/.vibe/skills/shapeitup/SKILL.md` (ask first). Vibe picks it up on `/reload`.

If Codex is present, write the same file to `~/.agents/skills/shapeitup/SKILL.md`
(ask first). That is Codex's user-level skills directory; it picks up new
skills without a restart.

### Step 4 — Verify

After registration:

1. For CLI clients, ask the user to restart their agent session (or run
`claude mcp list` to confirm `shapeitup` is listed).
`claude mcp list` / `codex mcp list` to confirm `shapeitup` is listed).
2. Tell the user to try a prompt like: *"Use the ShapeItUp MCP to create a
simple 20mm cube and render it."* If the agent reports that the `shapeitup`
tools are available, installation succeeded.
Expand All @@ -175,7 +210,9 @@ so the user can troubleshoot.
## Uninstall

To remove ShapeItUp from an MCP client, delete the `shapeitup` entry from the
relevant config file, or run `claude mcp remove shapeitup` for Claude Code and
`vibe mcp remove shapeitup` for Mistral Vibe. No global state is left behind
beyond those config entries and the optional skill files at
`~/.claude/skills/shapeitup/` and `~/.vibe/skills/shapeitup/`.
relevant config file (for Codex, the `[mcp_servers.shapeitup]` table in
`~/.codex/config.toml`), or run `claude mcp remove shapeitup` for Claude Code
and `vibe mcp remove shapeitup` for Mistral Vibe. No global state is left
behind beyond those config entries and the optional skill files at
`~/.claude/skills/shapeitup/`, `~/.vibe/skills/shapeitup/` and
`~/.agents/skills/shapeitup/`.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

---

ShapeItUp is an MCP server that turns [Replicad](https://replicad.xyz) / OpenCascade into AI-agent-grade CAD tooling. It writes, renders, verifies, and exports parametric 3D models from TypeScript `.shape.ts` files, headlessly — from the terminal, from Claude Code / Cursor / Claude Desktop / Mistral Vibe, or from CI. A [VSCode extension](#vscode-extension-optional) is available as an optional interactive viewer for humans who want to watch the renders happen live.
ShapeItUp is an MCP server that turns [Replicad](https://replicad.xyz) / OpenCascade into AI-agent-grade CAD tooling. It writes, renders, verifies, and exports parametric 3D models from TypeScript `.shape.ts` files, headlessly — from the terminal, from Claude Code / Codex / Cursor / Claude Desktop / Mistral Vibe, or from CI. A [VSCode extension](#vscode-extension-optional) is available as an optional interactive viewer for humans who want to watch the renders happen live.

## Install for Claude Code

Expand All @@ -23,6 +23,30 @@ claude mcp add shapeitup -- npx -y @shapeitup/mcp-server

That's it. `claude mcp add` registers the server in your Claude Code config so agent sessions pick it up automatically. See the [Claude Code MCP docs](https://docs.claude.com/en/docs/claude-code/mcp) for scoping options (`-s user` for all projects, `-s project` for just this repo).

## Install for Codex

```bash
codex mcp add shapeitup -- npx -y @shapeitup/mcp-server
```

Then raise the timeouts in `~/.codex/config.toml`, under the entry that command wrote:

```toml
[mcp_servers.shapeitup]
command = "npx"
args = ["-y", "@shapeitup/mcp-server"]
startup_timeout_sec = 60
tool_timeout_sec = 180
```

Keep both. Codex gives a server 10 s to start, and the first `npx` run downloads the package, which can take half a minute. It gives a tool 60 s, and a cold render of complex geometry can need more. The Codex CLI, the IDE extension and the ChatGPT desktop app share this file. Check with `codex mcp list`, or `/mcp` inside Codex.

For the Replicad API reference, save [`SKILL.md`](skills/shapeitup/SKILL.md) where Codex looks for skills:

```bash
mkdir -p ~/.agents/skills/shapeitup && curl -fsSL https://raw.githubusercontent.com/asbis/ShapeItUp/master/skills/shapeitup/SKILL.md -o ~/.agents/skills/shapeitup/SKILL.md
```

## Install for Cursor / Claude Desktop / other MCP clients

The generic MCP-config snippet:
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shapeitup-vscode",
"displayName": "ShapeItUp",
"description": "Scripted CAD for VS Code — write TypeScript, see 3D, export STEP/STL/3MF (Bambu Studio & OrcaSlicer ready). AI-powered with Claude Code MCP integration.",
"version": "1.30.0",
"version": "1.30.1",
"publisher": "shapeitup",
"license": "MIT",
"icon": "icon.png",
Expand Down
10 changes: 5 additions & 5 deletions packages/extension/src/viewer-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
describeTransformFailure,
renderViewerHtml,
computeParamEdit,
isOptionalReexportWarning,
type ExportFormat,
type ParamCommitResult,
type FaceOpResultMessage,
Expand Down Expand Up @@ -1287,13 +1288,12 @@ export class ViewerProvider implements vscode.WebviewViewProvider {
throw new Error(`Unresolved imports:\n${msg}`);
}
// Filter out "Import 'X' will always be undefined" warnings for the
// optional names the synthetic wrapper re-exports (`config`, `material`,
// `params`). These fire on every file that doesn't declare one of them
// — which is most — and the re-export pattern is deliberate.
const OPTIONAL_REEXPORT_NAMES = /Import "(config|material|params)" will always be undefined/;
// optional names the synthetic wrapper re-exports. These fire on every
// file that doesn't declare one of them — which is most — and the
// re-export pattern is deliberate.
// Surface other (non-fatal) warnings in the output channel.
for (const w of result.warnings) {
if (OPTIONAL_REEXPORT_NAMES.test(w.text)) continue;
if (isOptionalReexportWarning(w.text)) continue;
this.output.appendLine(`[warn] ${w.text}`);
}

Expand Down
22 changes: 21 additions & 1 deletion packages/mcp-server/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @shapeitup/mcp-server

MCP server for [ShapeItUp](https://github.com/asbis/ShapeItUp) — scripted CAD tools (Replicad / OpenCascade WASM) for Claude Code, Cursor, Claude Desktop, Gemini CLI, Mistral Vibe, and any stdio MCP client. Fully headless, no VSCode required.
MCP server for [ShapeItUp](https://github.com/asbis/ShapeItUp) — scripted CAD tools (Replicad / OpenCascade WASM) for Claude Code, Codex, Cursor, Claude Desktop, Gemini CLI, Mistral Vibe, and any stdio MCP client. Fully headless, no VSCode required.

## Install

Expand All @@ -16,6 +16,26 @@ npx -y @shapeitup/mcp-server
claude mcp add shapeitup -- npx -y @shapeitup/mcp-server
```

### Codex

```bash
codex mcp add shapeitup -- npx -y @shapeitup/mcp-server
```

Then raise the timeouts in `~/.codex/config.toml`, under the entry that command wrote:

```toml
[mcp_servers.shapeitup]
command = "npx"
args = ["-y", "@shapeitup/mcp-server"]
startup_timeout_sec = 60
tool_timeout_sec = 180
```

Keep both. Codex gives a server 10 s to start, and the first `npx` run downloads the package, which can take half a minute. It gives a tool 60 s, and a cold render of complex geometry can need more. The CLI, the IDE extension and the ChatGPT desktop app share this file.

For the Replicad API reference, save [`SKILL.md`](https://github.com/asbis/ShapeItUp/blob/master/skills/shapeitup/SKILL.md) as `~/.agents/skills/shapeitup/SKILL.md`, where Codex looks for skills.

### Cursor / Claude Desktop / generic MCP client

```json
Expand Down
4 changes: 2 additions & 2 deletions packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@shapeitup/mcp-server",
"version": "1.30.0",
"description": "ShapeItUp MCP server — scripted CAD tools (Replicad/OpenCascade) for Claude Code, Cursor, Claude Desktop, and other MCP clients.",
"version": "1.30.1",
"description": "ShapeItUp MCP server — scripted CAD tools (Replicad/OpenCascade) for Claude Code, Codex, Cursor, Claude Desktop, and other MCP clients.",
"type": "module",
"bin": {
"shapeitup-mcp": "./dist/index.js"
Expand Down
13 changes: 6 additions & 7 deletions packages/mcp-server/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
type Core,
type ExecutedPart,
} from "@shapeitup/core";
import type { ParamValue } from "@shapeitup/shared";
import { isOptionalReexportWarning, type ParamValue } from "@shapeitup/shared";
import * as esbuild from "esbuild-wasm";

// esbuild-wasm requires a one-shot initialize() before the first build().
Expand Down Expand Up @@ -1209,13 +1209,12 @@ export async function executeShapeFile(
// `params` from a sibling .shape.ts — supported but fragile).
//
// Filter out "Import 'X' will always be undefined" warnings for the
// optional names the synthetic wrapper re-exports (`config`, `material`,
// `params`). These fire on every file that doesn't declare one of them —
// which is most of them — and the re-export pattern is deliberate (back-
// compat with the executor's ambient `typeof foo !== "undefined"` lookup).
const OPTIONAL_REEXPORT_NAMES = /Import "(config|material|params)" will always be undefined/;
// optional names the synthetic wrapper re-exports. These fire on every
// file that doesn't declare one of them — which is most of them — and the
// re-export pattern is deliberate (back-compat with the executor's
// ambient `typeof foo !== "undefined"` lookup).
const filteredEsbuildWarnings = result.warnings.filter(
(w) => !OPTIONAL_REEXPORT_NAMES.test(w.text),
(w) => !isOptionalReexportWarning(w.text),
);
const combinedWarnings = [
...preflightResult.warnings,
Expand Down
63 changes: 61 additions & 2 deletions packages/mcp-server/src/subscriber-bus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
* - with zero subscribers, publishEvent returns delivered=0 without hanging
*/
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import { mkdtempSync, rmSync, existsSync, readdirSync } from "fs";
import { mkdtempSync, rmSync, existsSync, readdirSync, mkdirSync, writeFileSync, utimesSync } from "fs";
import { tmpdir } from "os";
import { join } from "path";
import { WebSocket } from "ws";
import { SubscriberBus, readMcpServerHeartbeat } from "./subscriber-bus.js";
import { SubscriberBus, readMcpServerHeartbeat, resolveGlobalStorageDir } from "./subscriber-bus.js";

// Tiny helper so each test's subscriber can block until it sees a message.
function awaitMessage(ws: WebSocket, timeoutMs = 2000): Promise<any> {
Expand Down Expand Up @@ -170,3 +170,62 @@ describe("SubscriberBus", () => {
expect(existsSync(storageDir)).toBe(true); // the dir itself stays
});
});

describe("resolveGlobalStorageDir", () => {
const ID = "shapeitup.shapeitup-vscode";
let home: string;

beforeEach(() => {
home = mkdtempSync(join(tmpdir(), "global-storage-"));
});

afterEach(() => {
try { rmSync(home, { recursive: true, force: true }); } catch {}
});

// What the extension leaves behind: a heartbeat in its own globalStorage.
function extensionHeartbeat(dir: string, ageSeconds: number, name = "shapeitup-heartbeat.json") {
mkdirSync(dir, { recursive: true });
const file = join(dir, name);
writeFileSync(file, "{}");
const t = Date.now() / 1000 - ageSeconds;
utimesSync(file, t, t);
}

it("uses VS Code's macOS location, not ~/.config", () => {
expect(resolveGlobalStorageDir({ home, platform: "darwin", env: {} })).toBe(
join(home, "Library", "Application Support", "Code", "User", "globalStorage", ID),
);
});

it("follows APPDATA on Windows and XDG_CONFIG_HOME on Linux", () => {
expect(resolveGlobalStorageDir({ home, platform: "win32", env: { APPDATA: join(home, "Roaming") } })).toBe(
join(home, "Roaming", "Code", "User", "globalStorage", ID),
);
expect(resolveGlobalStorageDir({ home, platform: "linux", env: {} })).toBe(
join(home, ".config", "Code", "User", "globalStorage", ID),
);
expect(resolveGlobalStorageDir({ home, platform: "linux", env: { XDG_CONFIG_HOME: join(home, "xdg") } })).toBe(
join(home, "xdg", "Code", "User", "globalStorage", ID),
);
});

it("picks the editor the extension ran in, even when VS Code's dir exists", () => {
const root = join(home, "Library", "Application Support");
// This server creates VS Code's dir on its own, so its existence proves nothing.
mkdirSync(join(root, "Code", "User", "globalStorage", ID), { recursive: true });
extensionHeartbeat(join(root, "Cursor", "User", "globalStorage", ID), 60, "shapeitup-heartbeat-123.json");
expect(resolveGlobalStorageDir({ home, platform: "darwin", env: {} })).toBe(
join(root, "Cursor", "User", "globalStorage", ID),
);
});

it("prefers the editor with the most recent heartbeat", () => {
const root = join(home, ".config");
extensionHeartbeat(join(root, "Cursor", "User", "globalStorage", ID), 3600);
extensionHeartbeat(join(root, "Code", "User", "globalStorage", ID), 5);
expect(resolveGlobalStorageDir({ home, platform: "linux", env: {} })).toBe(
join(root, "Code", "User", "globalStorage", ID),
);
});
});
Loading
Loading