From 99f479a44c6a02a8010f0dc5607d587d8d92aeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20R=C3=B8rvik?= <11362831+asbis@users.noreply.github.com> Date: Wed, 30 Sep 2026 09:53:46 +0200 Subject: [PATCH 1/2] feat(extension): add Mistral Vibe as an MCP client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mistral Vibe (CLI and VS Code extension) now appears in the MCP Clients view, and "Install MCP Server…" can register ShapeItUp with it: after a modal that shows exactly what gets written, it appends an [[mcp_servers]] entry to ~/.vibe/config.toml ($VIBE_HOME is honoured) and can copy the skill to ~/.vibe/skills/shapeitup/. Uninstall removes both. Vibe's config is TOML, so the entry is found, appended and removed as text without touching the rest of the file. The entry sets startup_timeout_sec = 60. Vibe's default is 10 s, and the first `npx -y @shapeitup/mcp-server` took 17.5 s from an empty npm cache, so a fresh install timed out on its first launch. Checked against Vibe 2.25.8: its config loader accepts the files this writes, its MCP client lists all 29 tools and calls one, `vibe mcp remove` works on them, and it loads SKILL.md unchanged. Also: clicking a row in the MCP Clients view now goes straight to that client's install action, as each row's tooltip already said, and INSTALL.md's skill URL no longer 404s (skill/ -> skills/shapeitup/). Docs cover Vibe in both READMEs and INSTALL.md. Extension, mcp-server and plugin manifest move to 1.30.0. Closes #1 Co-Authored-By: Claude Opus 5.5 --- .claude-plugin/marketplace.json | 2 +- CHANGELOG.md | 30 ++++ CONTRIBUTING.md | 2 +- DEVELOPMENT.md | 2 +- INSTALL.md | 38 ++++- README.md | 18 ++- packages/extension/media/walkthrough-mcp.md | 9 +- packages/extension/package.json | 6 +- packages/extension/src/extension.ts | 137 ++++++++++++++++-- packages/extension/src/mcp-clients-view.ts | 44 +++++- packages/extension/src/vibe-config.test.ts | 138 ++++++++++++++++++ packages/extension/src/vibe-config.ts | 147 ++++++++++++++++++++ packages/mcp-server/README.md | 25 +++- packages/mcp-server/package.json | 2 +- 14 files changed, 571 insertions(+), 29 deletions(-) create mode 100644 packages/extension/src/vibe-config.test.ts create mode 100644 packages/extension/src/vibe-config.ts diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 51d779e..b7ede95 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -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.29.5", + "version": "1.30.0", "author": { "name": "Asbjorn Rorvik", "email": "rorvik.asbjorn@gmail.com" diff --git a/CHANGELOG.md b/CHANGELOG.md index a95c997..a4d587b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,36 @@ 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.0] - Unreleased + +Extension `1.30.0` / mcp-server `1.30.0` — Mistral Vibe support +([#1](https://github.com/asbis/ShapeItUp/issues/1), thanks @martinrieder). + +### Added +- **Mistral Vibe in the MCP Clients view.** The sidebar detects Vibe (CLI or + VS Code extension, both of which read `~/.vibe/`, or `$VIBE_HOME`) and shows + whether `config.toml` registers ShapeItUp. +- **ShapeItUp: Install MCP Server… → Add to Mistral Vibe.** Appends a + `[[mcp_servers]]` entry to `~/.vibe/config.toml` and, if you want it, copies + the skill to `~/.vibe/skills/shapeitup/SKILL.md`, where Vibe also exposes it + as `/shapeitup`. A modal shows exactly what gets written first, and nothing + else in the file is touched. **ShapeItUp: Uninstall MCP Server…** removes + both again. +- **Vibe setup in the docs** (`README.md`, `packages/mcp-server/README.md`, + `INSTALL.md`), including `vibe mcp add`. The entry sets + `startup_timeout_sec = 60`: Vibe's default is 10 s, and the first `npx -y` + run took 17.5 s from an empty npm cache, so a fresh install would time out + on its first launch without it. + +### Changed +- **Clicking a client in the MCP Clients view goes straight to that client's + install action**, which each row's tooltip already described, instead of + opening the full list of options. + +### Fixed +- **`INSTALL.md` pointed agents at `skill/SKILL.md`, which returns 404.** The + skill lives at `skills/shapeitup/SKILL.md`. + ## [1.29.5] - 2026-09-23 Extension `1.29.5` / mcp-server `1.29.5`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4fcf5e..6e5ba62 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,7 +48,7 @@ All packages are bundled with a single `esbuild.config.mjs` at the root. It prod 1. Add the tool definition in `packages/mcp-server/src/tools.ts` 2. Update the API reference in the `getApiReference()` function -3. Update `skill/SKILL.md` with documentation +3. Update `skills/shapeitup/SKILL.md` with documentation 4. Copy the skill to `~/.claude/commands/shapeitup.md` ## Adding Examples diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index c502f5d..4f8c277 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -20,7 +20,7 @@ Verify with `/mcp` inside a Claude Code session started in this directory — th | Extension / viewer / worker | `pnpm dev` (watch) then press **F5** in VS Code | F5 relaunches the Extension Development Host — no manual restart | | MCP server (`packages/mcp-server/src/`) | `pnpm dev:mcp` (watch) | **Yes** — `/quit` Claude Code and restart. Stdio MCP processes don't hot-reload. | | Stdlib (`packages/core/src/stdlib/`) | `pnpm dev` (rebuilds both the extension bundles *and* the mcp-server, since stdlib is bundled into both) | F5 for viewer changes; restart Claude for MCP changes | -| Skill docs (`skill/SKILL.md`) | `pnpm build` to copy into `dist/skill/` | Reinstall the skill (or reload Claude Code) to pick it up | +| Skill docs (`skills/shapeitup/SKILL.md`) | `pnpm build` to copy into `dist/skills/shapeitup/` | Reinstall the skill (or reload Claude Code) to pick it up | F5 alone works too — `.vscode/launch.json` runs `pnpm build` as a pre-launch task, so you don't need a separate dev server running if you just want a one-shot test. diff --git a/INSTALL.md b/INSTALL.md index 68e8c27..45fb504 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,7 +1,7 @@ # ShapeItUp — Install Prompt for AI Agents > **For humans:** paste the whole of this file into any agentic CLI -> (Claude Code, Cursor agent, Gemini, Codex, etc.) and tell it to follow +> (Claude Code, Cursor agent, Gemini, Mistral Vibe, Codex, etc.) and tell it to follow > the instructions. The agent will detect your MCP clients and register > ShapeItUp with your explicit approval. @@ -20,7 +20,7 @@ register the server with every MCP client. | Transport | stdio | | Command | `npx` | | Args | `["-y", "@shapeitup/mcp-server"]` | -| Skill source | `https://raw.githubusercontent.com/asbis/ShapeItUp/master/skill/SKILL.md` | +| Skill source | `https://raw.githubusercontent.com/asbis/ShapeItUp/master/skills/shapeitup/SKILL.md` | Node 20+ is required. The `npx -y @shapeitup/mcp-server` form auto-fetches the latest published version on first run and caches it; no manual install needed. @@ -43,6 +43,8 @@ Check for each of these (absence of one is fine — just skip that client): - **Claude Desktop**: `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS, `%APPDATA%\Claude\claude_desktop_config.json` on Windows. - **Gemini CLI**: `which gemini` succeeds, OR `~/.gemini/` exists. +- **Mistral Vibe** (CLI or VS Code extension): `which vibe` succeeds, OR + `~/.vibe/` exists (`$VIBE_HOME` instead of `~/.vibe` when it is set). - **VS Code / Copilot Agent Mode**: if the ShapeItUp VS Code extension is installed, the MCP server is already registered via the native provider API — **skip this client**, no action needed. @@ -117,6 +119,26 @@ Create `~/.gemini/extensions/shapeitup/gemini-extension.json`: } ``` +#### Mistral Vibe + +The config is TOML. If `~/.vibe/config.toml` already has an `[[mcp_servers]]` +entry with `name = "shapeitup"`, skip this client. Otherwise append (create the +file if missing; never rewrite what is already there): + +```toml +[[mcp_servers]] +name = "shapeitup" +transport = "stdio" +command = "npx" +args = ["-y", "@shapeitup/mcp-server"] +startup_timeout_sec = 60 +``` + +If the file declares `mcp_servers = [...]` as an inline array instead, add the +same fields to that array as an inline table rather than appending, since TOML +does not allow both forms. Keep `startup_timeout_sec`: Vibe's default of 10 s +is shorter than the first `npx` download. Tell the user to run `/reload` in Vibe. + ### Step 3 — Install the Claude Code skill (optional but recommended) If Claude Code is present, fetch `SKILL.md` from the URL in the table above @@ -125,10 +147,13 @@ full Replicad API reference when working on `.shape.ts` files. Ask first. ```bash mkdir -p ~/.claude/skills/shapeitup -curl -fsSL https://raw.githubusercontent.com/asbis/ShapeItUp/master/skill/SKILL.md \ +curl -fsSL https://raw.githubusercontent.com/asbis/ShapeItUp/master/skills/shapeitup/SKILL.md \ -o ~/.claude/skills/shapeitup/SKILL.md ``` +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`. + ### Step 4 — Verify After registration: @@ -150,6 +175,7 @@ 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. -No global state is left behind beyond those config entries and the optional -skill file at `~/.claude/skills/shapeitup/`. +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/`. diff --git a/README.md b/README.md index b5f589f..0112928 100644 --- a/README.md +++ b/README.md @@ -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, 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 / 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 @@ -42,8 +42,24 @@ Where to put it: - **Cursor** — `~/.cursor/mcp.json`, or Settings → MCP → *Add new server* to drop it in through the UI. - **Claude Desktop** — `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS, `%APPDATA%\Claude\claude_desktop_config.json` on Windows. Restart the app after editing. +- **Mistral Vibe** — TOML rather than JSON; see below. - **Any stdio MCP client** — hand it `npx -y @shapeitup/mcp-server` as the server command. +### Mistral Vibe + +Append to `~/.vibe/config.toml`, then run `/reload` in Vibe: + +```toml +[[mcp_servers]] +name = "shapeitup" +transport = "stdio" +command = "npx" +args = ["-y", "@shapeitup/mcp-server"] +startup_timeout_sec = 60 +``` + +Keep `startup_timeout_sec`: Vibe's default of 10 s is shorter than the first `npx` download. For the Replicad API reference, save [`skills/shapeitup/SKILL.md`](skills/shapeitup/SKILL.md) as `~/.vibe/skills/shapeitup/SKILL.md`. More options, including `vibe mcp add`, are in the [MCP server README](packages/mcp-server/README.md#mistral-vibe). + Node 20+ required. No native build step; everything ships as WASM. ## What you get diff --git a/packages/extension/media/walkthrough-mcp.md b/packages/extension/media/walkthrough-mcp.md index d09a82e..f901ef5 100644 --- a/packages/extension/media/walkthrough-mcp.md +++ b/packages/extension/media/walkthrough-mcp.md @@ -2,12 +2,13 @@ ShapeItUp already works inside **VS Code Copilot Agent Mode** — no setup needed. For other AI clients (Claude Code, Cursor, Claude Desktop, Gemini -CLI), use the command below. +CLI, Mistral Vibe), use the command below. Run `ShapeItUp: Install MCP Server…` from the Command Palette -(`Cmd/Ctrl+Shift+P`) and pick your client. We'll either copy the right -command to your clipboard or open a one-click install deep link — we never -write to your config without asking. +(`Cmd/Ctrl+Shift+P`) and pick your client. We'll copy the right command to +your clipboard, open a one-click install deep link, or, for Mistral Vibe, show +you exactly what we'd add to `~/.vibe/config.toml` — we never write to your +config without asking. The simplest path: pick **"Copy AI install prompt URL"**, then paste into any agentic CLI. The agent will detect your clients and install ShapeItUp for diff --git a/packages/extension/package.json b/packages/extension/package.json index f866e44..e461817 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -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.29.5", + "version": "1.30.0", "publisher": "shapeitup", "license": "MIT", "icon": "icon.png", @@ -107,12 +107,12 @@ { "id": "shapeitup.getStarted", "title": "Get started with ShapeItUp", - "description": "Enable AI assistants (Claude Code, Cursor, Gemini) to use ShapeItUp.", + "description": "Enable AI assistants (Claude Code, Cursor, Gemini, Mistral Vibe) to use ShapeItUp.", "steps": [ { "id": "installMcp", "title": "Install the MCP server for your AI client", - "description": "Run [ShapeItUp: Install MCP Server…](command:shapeitup.installMcpServer) to register ShapeItUp with Claude Code, Cursor, Claude Desktop, or Gemini CLI. VS Code Copilot Agent Mode is registered automatically — no action needed.", + "description": "Run [ShapeItUp: Install MCP Server…](command:shapeitup.installMcpServer) to register ShapeItUp with Claude Code, Cursor, Claude Desktop, Gemini CLI, or Mistral Vibe. VS Code Copilot Agent Mode is registered automatically — no action needed.", "media": { "markdown": "media/walkthrough-mcp.md" } diff --git a/packages/extension/src/extension.ts b/packages/extension/src/extension.ts index 6f1c6d3..28b3e99 100644 --- a/packages/extension/src/extension.ts +++ b/packages/extension/src/extension.ts @@ -13,6 +13,15 @@ import { } from "./workspace-types"; import { registerMcpClientsView, showFirstRunNudgeIfNeeded } from "./mcp-clients-view"; import { getCachedWasmAssets } from "./wasm-cache"; +import { + VIBE_ENTRY, + hasVibeEntry, + usesInlineMcpServers, + vibeConfigPath, + vibeSkillDir, + withVibeEntry, + withoutVibeEntry, +} from "./vibe-config"; let viewerProvider: ViewerProvider; export const outputChannel = vscode.window.createOutputChannel("ShapeItUp"); @@ -65,11 +74,12 @@ export function activate(context: vscode.ExtensionContext) { }); // Consent-based install command for Claude Code / Cursor / Claude Desktop / - // Gemini CLI. Surfaces the one-shot AI install prompt that users can paste - // into any agentic CLI. + // Gemini CLI / Mistral Vibe. Surfaces the one-shot AI install prompt that + // users can paste into any agentic CLI. The MCP Clients view passes the + // row's option id so a click goes straight to that client. context.subscriptions.push( - vscode.commands.registerCommand("shapeitup.installMcpServer", () => - showMcpInstallOptions(context, outputChannel), + vscode.commands.registerCommand("shapeitup.installMcpServer", (target?: string) => + showMcpInstallOptions(context, outputChannel, target), ), vscode.commands.registerCommand("shapeitup.uninstallMcpServer", () => uninstallMcpServer(outputChannel), @@ -429,18 +439,20 @@ function registerMcpServerForCopilot( * Consented install surface for external MCP clients. We refuse to silently * write to ~/.claude.json, ~/.claude/skills/, or ~/.gemini/ — users pick a * client from the QuickPick and we either (a) copy the `claude mcp add …` - * command to the clipboard, (b) open a deep-link to Cursor, or (c) surface - * the AI install prompt that any agentic CLI can execute on their behalf. + * command to the clipboard, (b) open a deep-link to Cursor, (c) surface + * the AI install prompt that any agentic CLI can execute on their behalf, or + * (d) for Mistral Vibe, append to its config.toml after a modal confirmation. */ async function showMcpInstallOptions( - _context: vscode.ExtensionContext, + context: vscode.ExtensionContext, output: vscode.OutputChannel, + target?: string, ) { const INSTALL_PROMPT_URL = "https://raw.githubusercontent.com/asbis/ShapeItUp/master/INSTALL.md"; const NPM_COMMAND = "npx -y @shapeitup/mcp-server"; - const picked = await vscode.window.showQuickPick( + const picked = typeof target === "string" ? { id: target } : await vscode.window.showQuickPick( [ { label: "$(copy) Copy AI install prompt URL", @@ -462,6 +474,11 @@ async function showMcpInstallOptions( description: "Paste into claude_desktop_config.json", id: "desktop", }, + { + label: "$(add) Add to Mistral Vibe", + description: "Writes ~/.vibe/config.toml after you confirm", + id: "vibe", + }, ], { placeHolder: "Install ShapeItUp MCP server for which client?" }, ); @@ -503,6 +520,10 @@ async function showMcpInstallOptions( ); break; } + case "vibe": { + if (!(await installForVibe(context, output))) return; + break; + } } output.appendLine(`[mcp] User chose install target: ${(picked as any).id}`); @@ -513,6 +534,88 @@ async function showMcpInstallOptions( warmNpxMcpCache(output); } +/** + * Register ShapeItUp with Mistral Vibe — its CLI and VS Code extension share + * `$VIBE_HOME/config.toml` — and optionally copy the bundled skill next to + * it. Vibe has no deep link and no JSON to paste into a settings UI, so this + * is the one client we write for, and only after a modal that shows exactly + * what gets appended. Returns false when nothing was written. + */ +async function installForVibe( + context: vscode.ExtensionContext, + output: vscode.OutputChannel, +): Promise { + const configFile = vibeConfigPath(); + const readConfig = () => (fs.existsSync(configFile) ? fs.readFileSync(configFile, "utf-8") : ""); + let text: string; + try { + text = readConfig(); + } catch (e: any) { + vscode.window.showErrorMessage(`Couldn't read ${configFile}: ${e.message}`); + return false; + } + + const skillSrc = path.join(context.extensionPath, "dist", "skills", "shapeitup", "SKILL.md"); + const skillFile = path.join(vibeSkillDir(), "SKILL.md"); + const needServer = !hasVibeEntry(text); + const needSkill = fs.existsSync(skillSrc) && !fs.existsSync(skillFile); + + if (needServer && usesInlineMcpServers(text)) { + // An inline `mcp_servers = [...]` can't be extended by appending a table, + // and rewriting the user's array is not a guess worth making for them. + await vscode.env.clipboard.writeText( + `{ name = "shapeitup", transport = "stdio", command = "npx", args = ["-y", "@shapeitup/mcp-server"], startup_timeout_sec = 60 }`, + ); + await vscode.window.showTextDocument(vscode.Uri.file(configFile)); + vscode.window.showInformationMessage( + "This config.toml declares mcp_servers inline. Copied a ShapeItUp entry: add it to that list, then run /reload in Vibe.", + ); + return false; + } + if (!needServer && !needSkill) { + vscode.window.showInformationMessage(`ShapeItUp is already set up for Mistral Vibe (${configFile}).`); + return false; + } + + const BOTH = "Add server and skill"; + const SERVER = needSkill ? "Add server only" : "Add server"; + const SKILL = "Install skill"; + const detail = [ + needServer ? `Appends to ${configFile}:\n\n${VIBE_ENTRY}` : `${configFile} already registers ShapeItUp.`, + needSkill ? `The skill (Replicad API reference for .shape.ts files) goes to ${skillFile}.` : "", + ].filter(Boolean).join("\n\n"); + const choice = await vscode.window.showInformationMessage( + needServer ? "Add ShapeItUp to Mistral Vibe?" : "Install the ShapeItUp skill for Mistral Vibe?", + { modal: true, detail }, + ...(needServer ? (needSkill ? [BOTH, SERVER] : [SERVER]) : [SKILL]), + ); + if (!choice) return false; + + try { + if (needServer && choice !== SKILL) { + // Re-read: the file may have changed while the modal was open. + const current = readConfig(); + if (!hasVibeEntry(current)) { + fs.mkdirSync(path.dirname(configFile), { recursive: true }); + fs.writeFileSync(configFile, withVibeEntry(current)); + output.appendLine(`[mcp] Added shapeitup to ${configFile}`); + } + } + if (needSkill && choice !== SERVER) { + fs.mkdirSync(path.dirname(skillFile), { recursive: true }); + fs.copyFileSync(skillSrc, skillFile); + output.appendLine(`[mcp] Installed Vibe skill to ${skillFile}`); + } + } catch (e: any) { + vscode.window.showErrorMessage(`Failed to set up Mistral Vibe: ${e.message}`); + return false; + } + vscode.window.showInformationMessage( + "ShapeItUp added to Mistral Vibe. Run /reload in Vibe (or start a new session) to pick it up.", + ); + return true; +} + /** * Fire-and-forget prefetch of `@shapeitup/mcp-server` into the npx cache. * Runs detached so VS Code doesn't wait on it and the output stays quiet on @@ -586,19 +689,29 @@ async function uninstallMcpServer(output: vscode.OutputChannel) { const hasGemini = fs.existsSync(geminiExt); const skill = path.join(home, ".claude", "skills", "shapeitup"); const hasSkill = fs.existsSync(skill); + const vibeConfig = vibeConfigPath(); + let hasVibe = false; + try { + hasVibe = withoutVibeEntry(fs.readFileSync(vibeConfig, "utf-8")) !== undefined; + } catch {} + const vibeSkill = vibeSkillDir(); + const hasVibeSkill = fs.existsSync(vibeSkill); - if (found.length === 0 && !hasGemini && !hasSkill) { + if (found.length === 0 && !hasGemini && !hasSkill && !hasVibe && !hasVibeSkill) { vscode.window.showInformationMessage("No ShapeItUp MCP entries found to uninstall."); return; } type UninstallItem = | { label: string; mode: "json"; target: typeof targets[number] } + | { label: string; mode: "toml"; target: string } | { label: string; mode: "dir"; target: string }; const items: UninstallItem[] = []; for (const t of found) items.push({ label: t.label, target: t, mode: "json" }); if (hasGemini) items.push({ label: `Gemini CLI (${geminiExt})`, target: geminiExt, mode: "dir" }); if (hasSkill) items.push({ label: `Claude Code skill (${skill})`, target: skill, mode: "dir" }); + if (hasVibe) items.push({ label: `Mistral Vibe (${vibeConfig})`, target: vibeConfig, mode: "toml" }); + if (hasVibeSkill) items.push({ label: `Mistral Vibe skill (${vibeSkill})`, target: vibeSkill, mode: "dir" }); const picks = await vscode.window.showQuickPick(items, { canPickMany: true, placeHolder: "Select ShapeItUp entries to remove", @@ -622,6 +735,12 @@ async function uninstallMcpServer(output: vscode.OutputChannel) { fs.writeFileSync(t.file, JSON.stringify(c, null, 2) + "\n"); output.appendLine(`[mcp] Removed shapeitup from ${t.file}`); } + } else if (p.mode === "toml") { + const next = withoutVibeEntry(fs.readFileSync(p.target, "utf-8")); + if (next !== undefined) { + fs.writeFileSync(p.target, next); + output.appendLine(`[mcp] Removed shapeitup from ${p.target}`); + } } else { fs.rmSync(p.target as string, { recursive: true, force: true }); output.appendLine(`[mcp] Removed ${p.target}`); diff --git a/packages/extension/src/mcp-clients-view.ts b/packages/extension/src/mcp-clients-view.ts index 94a3ca4..837f062 100644 --- a/packages/extension/src/mcp-clients-view.ts +++ b/packages/extension/src/mcp-clients-view.ts @@ -10,6 +10,7 @@ import * as vscode from "vscode"; import * as path from "path"; import * as fs from "fs"; import * as os from "os"; +import { hasVibeEntry, vibeConfigPath, vibeHome } from "./vibe-config"; type Status = "registered" | "available" | "not-installed"; @@ -19,6 +20,8 @@ interface ClientInfo { status: Status; detail: string; installCommandId?: string; + /** Option id in the install QuickPick; a click skips straight to it. */ + installTarget?: string; } function readJson(file: string): any | undefined { @@ -34,6 +37,14 @@ function hasShapeitupEntry(file: string): boolean { return !!c?.mcpServers?.shapeitup; } +function hasVibeShapeitupEntry(file: string): boolean { + try { + return hasVibeEntry(fs.readFileSync(file, "utf-8")); + } catch { + return false; + } +} + function detectClients(): ClientInfo[] { const home = os.homedir(); const platform = process.platform; @@ -51,6 +62,7 @@ function detectClients(): ClientInfo[] { ? path.join(home, "AppData", "Roaming", "Claude", "claude_desktop_config.json") : path.join(home, ".config", "Claude", "claude_desktop_config.json"); const geminiManifest = path.join(home, ".gemini", "extensions", "shapeitup", "gemini-extension.json"); + const vibeConfig = vibeConfigPath(); const hasClaudeCli = fs.existsSync(claudeJson) || @@ -74,6 +86,14 @@ function detectClients(): ClientInfo[] { fs.existsSync("/usr/local/bin/gemini") || fs.existsSync("/opt/homebrew/bin/gemini"); + // Covers the CLI and the VS Code extension alike: both read ~/.vibe/. + const hasVibe = + fs.existsSync(vibeHome()) || + fs.existsSync(path.join(home, ".local", "bin", "vibe")) || + fs.existsSync("/usr/local/bin/vibe") || + fs.existsSync("/opt/homebrew/bin/vibe"); + const vibeRegistered = hasVibe && hasVibeShapeitupEntry(vibeConfig); + return [ { id: "copilot", @@ -97,6 +117,7 @@ function detectClients(): ClientInfo[] { ? "~/.claude.json has shapeitup entry" : "Click to copy `claude mcp add` command", installCommandId: "shapeitup.installMcpServer", + installTarget: "claude", }, { id: "cursor", @@ -112,6 +133,7 @@ function detectClients(): ClientInfo[] { ? "~/.cursor/mcp.json has shapeitup entry" : "Click to open Cursor install deep-link", installCommandId: "shapeitup.installMcpServer", + installTarget: "cursor", }, { id: "claude-desktop", @@ -127,6 +149,7 @@ function detectClients(): ClientInfo[] { ? "claude_desktop_config.json has shapeitup entry" : "Click to copy JSON snippet", installCommandId: "shapeitup.installMcpServer", + installTarget: "desktop", }, { id: "gemini", @@ -142,10 +165,28 @@ function detectClients(): ClientInfo[] { ? "~/.gemini/extensions/shapeitup/ exists" : "Click to copy AI install prompt", installCommandId: "shapeitup.installMcpServer", + installTarget: "ai", + }, + { + id: "vibe", + label: "Mistral Vibe", + status: !hasVibe ? "not-installed" : vibeRegistered ? "registered" : "available", + detail: !hasVibe + ? "Not detected on this machine" + : vibeRegistered + ? `${tildify(vibeConfig)} has shapeitup entry` + : `Click to add ShapeItUp to ${tildify(vibeConfig)}`, + installCommandId: "shapeitup.installMcpServer", + installTarget: "vibe", }, ]; } +function tildify(p: string): string { + const home = os.homedir(); + return p.startsWith(home + path.sep) ? "~" + p.slice(home.length) : p; +} + class McpClientItem extends vscode.TreeItem { constructor(public readonly info: ClientInfo) { super(info.label, vscode.TreeItemCollapsibleState.None); @@ -169,6 +210,7 @@ class McpClientItem extends vscode.TreeItem { this.command = { command: info.installCommandId, title: "Install", + arguments: info.installTarget ? [info.installTarget] : undefined, }; this.contextValue = "installable"; } @@ -360,7 +402,7 @@ export async function showFirstRunNudgeIfNeeded(context: vscode.ExtensionContext } const choice = await vscode.window.showInformationMessage( - "ShapeItUp is installed. To use it with Claude Code, Cursor, or Gemini, install the MCP server.", + "ShapeItUp is installed. To use it with Claude Code, Cursor, Gemini, or Mistral Vibe, install the MCP server.", "Install…", "Already done", "Don't show again", diff --git a/packages/extension/src/vibe-config.test.ts b/packages/extension/src/vibe-config.test.ts new file mode 100644 index 0000000..bbd3cb6 --- /dev/null +++ b/packages/extension/src/vibe-config.test.ts @@ -0,0 +1,138 @@ +/** + * Tests for the Mistral Vibe config.toml helpers. The fixtures are shaped like + * what Vibe itself writes (`vibe mcp add` emits multi-line arrays), plus the + * neighbours an edit must not disturb: other servers, their sub-tables, and + * comments that belong to the next section. + */ +import { describe, it, expect } from "vitest"; +import { join } from "path"; +import { + VIBE_ENTRY, + findVibeEntry, + hasVibeEntry, + usesInlineMcpServers, + vibeConfigPath, + vibeSkillDir, + withVibeEntry, + withoutVibeEntry, +} from "./vibe-config"; + +const OURS_AS_VIBE_WRITES_IT = `[[mcp_servers]] +name = "shapeitup" +startup_timeout_sec = 60.0 +transport = "stdio" +command = "npx" +args = [ + "-y", + "@shapeitup/mcp-server", +] +`; + +const OTHER = `[[mcp_servers]] +name = "github" +transport = "streamable-http" +url = "https://example.com/mcp" + +[mcp_servers.auth] +type = "static" +api_key_env = "GH_TOKEN" +`; + +describe("paths", () => { + it("defaults to ~/.vibe and honours VIBE_HOME", () => { + expect(vibeConfigPath({}, "/home/u")).toBe(join("/home/u", ".vibe", "config.toml")); + expect(vibeConfigPath({ VIBE_HOME: "/opt/vibe" }, "/home/u")).toBe(join("/opt/vibe", "config.toml")); + expect(vibeSkillDir({}, "/home/u")).toBe(join("/home/u", ".vibe", "skills", "shapeitup")); + }); +}); + +describe("hasVibeEntry", () => { + it("finds our entry in the form Vibe writes", () => { + expect(hasVibeEntry(OURS_AS_VIBE_WRITES_IT)).toBe(true); + expect(hasVibeEntry(`active_model = "devstral"\n\n${OTHER}\n${OURS_AS_VIBE_WRITES_IT}`)).toBe(true); + }); + + it("accepts single quotes and a trailing comment", () => { + expect(hasVibeEntry(`[[mcp_servers]]\nname = 'shapeitup' # cad\ncommand = "npx"\n`)).toBe(true); + }); + + it("ignores other servers, lookalike names and other tables", () => { + expect(hasVibeEntry("")).toBe(false); + expect(hasVibeEntry(OTHER)).toBe(false); + expect(hasVibeEntry(`[[mcp_servers]]\nname = "shapeitup-dev"\n`)).toBe(false); + expect(hasVibeEntry(`[[agents]]\nname = "shapeitup"\n`)).toBe(false); + }); + + it("doesn't mistake a sub-table key for the server name", () => { + const toml = `[[mcp_servers]]\nname = "other"\n\n[mcp_servers.env]\nname = "shapeitup"\n`; + expect(hasVibeEntry(toml)).toBe(false); + }); + + it("ignores a header-looking line inside a multi-line string", () => { + const toml = `system_prompt = """\n[[mcp_servers]]\nname = "shapeitup"\n"""\n`; + expect(findVibeEntry(toml)).toBeUndefined(); + }); + + it("reports the inline form as installed", () => { + const inline = `mcp_servers = [{ name = "shapeitup", transport = "stdio", command = "npx" }]\n`; + expect(usesInlineMcpServers(inline)).toBe(true); + expect(hasVibeEntry(inline)).toBe(true); + expect(findVibeEntry(inline)).toBeUndefined(); + }); +}); + +describe("withVibeEntry", () => { + it("writes just the entry into an empty or missing file", () => { + expect(withVibeEntry("")).toBe(VIBE_ENTRY + "\n"); + expect(hasVibeEntry(withVibeEntry(""))).toBe(true); + }); + + it("appends after existing content, separated by one blank line", () => { + const out = withVibeEntry(`active_model = "devstral"\n\n\n`); + expect(out).toBe(`active_model = "devstral"\n\n${VIBE_ENTRY}\n`); + }); + + it("appends after a file with no trailing newline", () => { + expect(withVibeEntry(OTHER.trimEnd())).toBe(`${OTHER.trimEnd()}\n\n${VIBE_ENTRY}\n`); + }); + + it("keeps CRLF files CRLF", () => { + const out = withVibeEntry(`active_model = "devstral"\r\n`); + expect(out).toBe(`active_model = "devstral"\r\n\r\n${VIBE_ENTRY.replace(/\n/g, "\r\n")}\r\n`); + }); + + it("asks for a startup timeout above Vibe's 10 s default", () => { + const m = /startup_timeout_sec = (\d+)/.exec(VIBE_ENTRY); + expect(Number(m?.[1])).toBeGreaterThan(10); + }); +}); + +describe("withoutVibeEntry", () => { + it("returns undefined when there is nothing to remove", () => { + expect(withoutVibeEntry(OTHER)).toBeUndefined(); + }); + + it("round-trips an append", () => { + const before = `active_model = "devstral"\n\n${OTHER}`; + expect(withoutVibeEntry(withVibeEntry(before))).toBe(before); + }); + + it("empties a file that held only our entry", () => { + expect(withoutVibeEntry(OURS_AS_VIBE_WRITES_IT)).toBe(""); + }); + + it("removes our entry from between two others, leaving them intact", () => { + const toml = `${OTHER}\n${OURS_AS_VIBE_WRITES_IT}\n[[mcp_servers]]\nname = "last"\n`; + expect(withoutVibeEntry(toml)).toBe(`${OTHER}\n[[mcp_servers]]\nname = "last"\n`); + }); + + it("takes our own sub-tables with us", () => { + const toml = `${OURS_AS_VIBE_WRITES_IT}\n[mcp_servers.env]\nDEBUG = "1"\n\n${OTHER}`; + expect(withoutVibeEntry(toml)).toBe(OTHER); + }); + + it("leaves a comment that introduces the next section", () => { + const toml = `${OURS_AS_VIBE_WRITES_IT}\n# Model settings\n[models]\nfoo = 1\n`; + expect(withoutVibeEntry(toml)).toBe(`# Model settings\n[models]\nfoo = 1\n`); + }); +}); diff --git a/packages/extension/src/vibe-config.ts b/packages/extension/src/vibe-config.ts new file mode 100644 index 0000000..8920e3c --- /dev/null +++ b/packages/extension/src/vibe-config.ts @@ -0,0 +1,147 @@ +/** + * Mistral Vibe keeps its MCP servers as `[[mcp_servers]]` tables in TOML, at + * `$VIBE_HOME/config.toml` (default `~/.vibe/config.toml`), and its skills + * under `$VIBE_HOME/skills//SKILL.md`. Every other client we support + * uses JSON, so this is the one config we edit as text. + * + * This is not a TOML parser. It recognizes table headers, which is all it + * takes to find one array-of-tables entry, append one, or cut one out without + * touching a byte of anything else in the file. Appending is always valid + * TOML — an `[[mcp_servers]]` header at the end of a file adds an element no + * matter what precedes it — except when the file already declares + * `mcp_servers = [...]` inline; `usesInlineMcpServers` detects that case so + * callers can refuse to write. + */ + +import * as path from "path"; +import * as os from "os"; + +export const VIBE_SERVER_NAME = "shapeitup"; + +/** + * The entry we append. `startup_timeout_sec` is not decoration: Vibe's default + * is 10 s, and the first `npx -y` run downloads the package (~17 s measured + * from an empty npm cache), so without it a fresh install times out on its + * very first launch. + */ +export const VIBE_ENTRY = [ + "[[mcp_servers]]", + `name = "${VIBE_SERVER_NAME}"`, + `transport = "stdio"`, + `command = "npx"`, + `args = ["-y", "@shapeitup/mcp-server"]`, + "startup_timeout_sec = 60", +].join("\n"); + +export function vibeHome(env: NodeJS.ProcessEnv = process.env, home = os.homedir()): string { + return env.VIBE_HOME || path.join(home, ".vibe"); +} + +export function vibeConfigPath(env: NodeJS.ProcessEnv = process.env, home = os.homedir()): string { + return path.join(vibeHome(env, home), "config.toml"); +} + +export function vibeSkillDir(env: NodeJS.ProcessEnv = process.env, home = os.homedir()): string { + return path.join(vibeHome(env, home), "skills", VIBE_SERVER_NAME); +} + +// `[table]` or `[[array.of.tables]]`, keys bare or quoted. Requiring a key +// character set keeps array values that start a line (` [1, 2]`) from +// reading as headers. +const HEADER = /^\s*(\[\[|\[)\s*([A-Za-z0-9_\-."' ]+?)\s*(\]\]|\])\s*(#.*)?$/; +const NAME_IS_OURS = new RegExp(`^\\s*name\\s*=\\s*(["'])${VIBE_SERVER_NAME}\\1\\s*(#.*)?$`); +const INLINE_MCP_SERVERS = /^\s*mcp_servers\s*=/m; + +interface Header { + line: number; + arrayOfTables: boolean; + key: string; +} + +function splitLines(text: string): string[] { + return text.split(/\r?\n/); +} + +function headers(lines: string[]): Header[] { + const out: Header[] = []; + // Delimiter of the multi-line string we are inside, if any: a line of + // prompt text that happens to start with `[` is not a table. + let open: string | undefined; + lines.forEach((line, i) => { + const startedInside = open !== undefined; + for (const delim of ['"""', "'''"]) { + if (open && open !== delim) continue; + if ((line.split(delim).length - 1) % 2 === 1) open = open ? undefined : delim; + } + if (startedInside || open) return; + const m = HEADER.exec(line); + if (!m) return; + const arrayOfTables = m[1] === "[["; + if (arrayOfTables !== (m[3] === "]]")) return; + out.push({ line: i, arrayOfTables, key: m[2].replace(/\s*\.\s*/g, ".") }); + }); + return out; +} + +/** + * Line range `[start, end)` of our `[[mcp_servers]]` entry, including any + * `[mcp_servers.*]` sub-tables that belong to it. Trailing blank and comment + * lines are left out of the range: a comment directly above the next header + * describes that header, not us. + */ +export function findVibeEntry(text: string): { start: number; end: number } | undefined { + const lines = splitLines(text); + const hs = headers(lines); + for (let h = 0; h < hs.length; h++) { + if (!hs[h].arrayOfTables || hs[h].key !== "mcp_servers") continue; + let next = h + 1; + // Our own keys run up to the next header; `name` lives there, not in a + // sub-table (an env var called `name` must not count). + const ownEnd = next < hs.length ? hs[next].line : lines.length; + const ours = lines.slice(hs[h].line + 1, ownEnd).some((l) => NAME_IS_OURS.test(l)); + while (next < hs.length && !hs[next].arrayOfTables && hs[next].key.startsWith("mcp_servers.")) { + next++; + } + if (!ours) continue; + let end = next < hs.length ? hs[next].line : lines.length; + while (end > hs[h].line + 1 && /^\s*(#.*)?$/.test(lines[end - 1])) end--; + return { start: hs[h].line, end }; + } + return undefined; +} + +export function usesInlineMcpServers(text: string): boolean { + return INLINE_MCP_SERVERS.test(text); +} + +/** + * Whether `config.toml` registers ShapeItUp. Read-only, so it accepts the + * inline form too: there we can't edit, but we can still report "installed". + */ +export function hasVibeEntry(text: string): boolean { + if (findVibeEntry(text)) return true; + if (!usesInlineMcpServers(text)) return false; + return new RegExp(`\\bname\\s*=\\s*(["'])${VIBE_SERVER_NAME}\\1`).test(text); +} + +/** `text` with our entry appended. Callers check `usesInlineMcpServers` first. */ +export function withVibeEntry(text: string): string { + const eol = text.includes("\r\n") ? "\r\n" : "\n"; + const entry = VIBE_ENTRY.split("\n").join(eol) + eol; + if (text.trim() === "") return entry; + return text.replace(/(\r?\n)*$/, "") + eol + eol + entry; +} + +/** `text` with our entry removed, or undefined if there is none to remove. */ +export function withoutVibeEntry(text: string): string | undefined { + const range = findVibeEntry(text); + if (!range) return undefined; + const eol = text.includes("\r\n") ? "\r\n" : "\n"; + const lines = splitLines(text); + let { start, end } = range; + // Take one separating blank line with us so removal doesn't leave a gap. + if (start > 0 && lines[start - 1].trim() === "") start--; + else if (end < lines.length && lines[end].trim() === "") end++; + lines.splice(start, end - start); + return lines.join(eol); +} diff --git a/packages/mcp-server/README.md b/packages/mcp-server/README.md index bb8d699..d2f4655 100644 --- a/packages/mcp-server/README.md +++ b/packages/mcp-server/README.md @@ -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, 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, Cursor, Claude Desktop, Gemini CLI, Mistral Vibe, and any stdio MCP client. Fully headless, no VSCode required. ## Install @@ -32,6 +32,29 @@ claude mcp add shapeitup -- npx -y @shapeitup/mcp-server - Cursor: `~/.cursor/mcp.json` (or Settings → MCP) - Claude Desktop: `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS), `%APPDATA%\Claude\claude_desktop_config.json` (Windows) +### Mistral Vibe + +Append to `~/.vibe/config.toml` (the CLI and the VS Code extension share it), then run `/reload` in Vibe: + +```toml +[[mcp_servers]] +name = "shapeitup" +transport = "stdio" +command = "npx" +args = ["-y", "@shapeitup/mcp-server"] +startup_timeout_sec = 60 +``` + +Or have Vibe write it for you: + +```bash +vibe mcp add shapeitup --transport stdio --command npx --arg=-y --arg=@shapeitup/mcp-server --startup-timeout-sec 60 +``` + +Keep `startup_timeout_sec`. Vibe's default is 10 s, and the first run of `npx` downloads the package, which can take longer than that. The tools show up as `shapeitup_create_shape`, `shapeitup_render_preview` and so on. + +For the Replicad API reference, save [`SKILL.md`](https://github.com/asbis/ShapeItUp/blob/master/skills/shapeitup/SKILL.md) as `~/.vibe/skills/shapeitup/SKILL.md`. Vibe loads it as-is, and it also becomes the `/shapeitup` command. With the VS Code extension installed, **ShapeItUp: Install MCP Server… → Add to Mistral Vibe** does both steps after you confirm. + Node 20+ required. Works in Docker / CI (WASM, no native deps). ## What's in the box diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index da50b8d..99caf9f 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -1,6 +1,6 @@ { "name": "@shapeitup/mcp-server", - "version": "1.29.5", + "version": "1.30.0", "description": "ShapeItUp MCP server — scripted CAD tools (Replicad/OpenCascade) for Claude Code, Cursor, Claude Desktop, and other MCP clients.", "type": "module", "bin": { From 242566b81ad42b7255c901e7a125d2b9a761be4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20R=C3=B8rvik?= <11362831+asbis@users.noreply.github.com> Date: Wed, 30 Sep 2026 10:00:01 +0200 Subject: [PATCH 2/2] Release as 1.30.0 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4d587b..d74743c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ 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.0] - Unreleased +## [1.30.0] - 2026-09-30 Extension `1.30.0` / mcp-server `1.30.0` — Mistral Vibe support ([#1](https://github.com/asbis/ShapeItUp/issues/1), thanks @martinrieder).