Environment setup and run instructions. Doubles as the demo runbook. (Commands assume the
repo-scaffoldtask has been implemented.)
- Node.js 20+ and npm
- VS Code (the primary host)
- Copilot CLI installed and authenticated, run in VS Code's integrated terminal
- The Canvas VS Code extension installed (from
/extension) and the Canvas MCP server registered with Copilot CLI (see Install the extension & register the server)
Copy .env.example to .env and fill in (most are optional for local use):
| Variable | Description | Example |
|---|---|---|
CANVAS_LOG_LEVEL |
Server log verbosity | info |
CANVAS_DEBUG_WS_PORT |
Optional local-debug WebSocket fallback port (non-primary) | 4317 |
npm installnpm run build # builds the MCP server, the /canvas bundle, and the /extensionArchitecture is Pattern 1 (ADR-007 addendum): the VS Code extension hosts the
Canvas MCP server in-process over a local HTTP endpoint, and Copilot CLI connects
to it. So registration is just an mcp-config.json entry pointing at the extension.
- Register the Canvas MCP server with Copilot CLI. Easiest: when you run the
extension it offers one-time setup — click "Set up" and it registers the
canvasserver, adds the "always draw with the canvas" instruction, and installs the/diagram*skills for you. To do it manually instead, add to~/.copilot/mcp-config.json:"canvas": { "type": "http", "url": "http://127.0.0.1:4123/mcp", "tools": ["*"] }
- Run the extension (F5 dev host, or install the
.vsix). On activation it starts the MCP server on127.0.0.1:4123and shows "MCP server ready at …".
Works in any project (global install): "Set up" copies the diagram skills into
~/.copilot/skills/(the personal location the CLI scans for every project), so the/diagram,/diagram-dependency,/diagram-flowchart,/diagram-state-machine,/diagram-classand/diagram-erslash commands work in all your repos — not only this one. (A repo's own.github/skills/is only discovered while you're inside that repo.) The skills ship inside the.vsix(dist/skills/); after setup, restart the CLI and run/skills reload. The extension also refreshes them automatically on upgrade.
Reliable tool triggering: this repo ships
.github/copilot-instructions.md(and the extension can install a global copy) telling Copilot to always use thecreate_diagramcanvas tool for any diagram/draw/visualize request and never emit HTML/Mermaid. Restart the CLI session after setup so it loads the instruction.
End-to-end "type in CLI → example diagram appears as a VS Code tab":
- Open the repo in VS Code and press F5 (builds canvas + extension, launches the Extension Development Host). Wait for the "Canvas for Copilot: MCP server ready at http://127.0.0.1:4123/mcp" notification.
- In that dev-host window, open the integrated terminal and start a Copilot
CLI session (restart it if it was already running, so it picks up the new
canvasMCP server). - Type: "open canvas for copilot". Copilot calls the
open_canvastool → the canvas opens as a webview tab beside the terminal, rendering the example Cytoscape graph. - Now generate your own: "create a diagram to explain the workflow for obtaining
a JWT for auth on a page". Copilot generates the graph and calls
create_diagram→ the canvas opens (if needed) and renders it.
The two prototype tools (both over the local MCP endpoint):
open_canvas— opens the canvas and shows the fixed example diagram.create_diagram— Copilot generates a graph (title + nodes + edges) from your request and renders it; opens the canvas tab if it isn't already open.
There are also specialised diagram tools/skills built on create_diagram — one
per diagram type, each with its own notation (dependency, flowchart, state machine,
class, ER). Invoke them in natural language or with a / slash command
(/diagram-flowchart …, or /diagram … to auto-detect the type). After first run,
/skills reload in the CLI picks them up. See docs/DIAGRAM_TOOLS.md for the
full list, per-type input, notation, and how to test each one.
Quick check without the CLI: run Ctrl/Cmd+Shift+P → "Canvas for Copilot: Open Canvas" — it opens the example diagram directly.
npm run dev # rebuilds the server + canvas bundle + extension on changeOpen VS Code, run Copilot CLI in the integrated terminal, and ask for a diagram — the extension opens the canvas as a webview tab the first time a diagram is pushed. No separate browser process or port is required for the primary path.
You do not need the VS Code Marketplace (no publisher account / PAT). Three local options:
1. Extension Development Host (F5) — the dev loop.
Open the repo in VS Code and press F5 (launch config "Run Canvas Extension").
A second VS Code window opens with the extension loaded from source (the
build-extension task bundles it first). In that window, run
Ctrl/Cmd+Shift+P → "Canvas for Copilot: Open Canvas". Edit code, then reload the
dev-host window to pick up changes (or run the watch-extension task for rebuild on
save). Config lives in .vscode/launch.json + .vscode/tasks.json.
2. Install a packaged .vsix — everyday use, no F5.
From a fresh clone, one command builds everything and writes the package to the repo
root, then install it into VS Code:
npm install # once
npm run package # → ./canvas-for-copilot.vsix
code --install-extension canvas-for-copilot.vsixReload VS Code, accept the one-time Set up prompt, then run Copilot CLI in the integrated terminal and ask for a diagram. Update later by re-running the two commands; uninstall from the Extensions panel.
3. Automated tests (@vscode/test-electron).
Headless VS Code that activates the extension and asserts behavior — add for CI once
there is real logic in the vscode-extension task, not for the stub.
- Open your project in VS Code and start a Copilot CLI session in the integrated terminal (with the Canvas MCP server registered).
- Ask, e.g., "diagram the auth flow."
- The canvas opens as a VS Code tab beside the terminal; click nodes and issue
follow-ups (explain, expand, modify) — see
docs/REQUIREMENTS.mdfor supported interactions.
- Canvas tab didn't open: confirm the Canvas extension is installed/activated and the MCP server is registered with the CLI; check the extension's Output channel and the CLI's MCP logs.
- Blank canvas: likely an invalid graph model — an error overlay should appear;
the server should validate the
elementsmodel before sending (seeARCHITECTURE.md). - Canvas not updating: check the webview
postMessagechannel in the extension's Output channel; the canvas should re-sync when the extension reloads the webview.