@trohde/agentic-canvas
v0.6.2
Published
Local-first visual canvas controlled by MCP tools.
Maintainers
Readme
Agentic Canvas
Agentic Canvas is a local-first visual canvas that an AI agent drives through a local MCP server. It supports Excalidraw for freeform diagrams, JSON Canvas for portable semantic knowledge maps, and Flow for Agentic Canvas-native typed graphs, while a single local Node process serves the browser app, exposes MCP over Streamable HTTP, and syncs scene changes over WebSocket.
Published package: @trohde/agentic-canvas
Executable: agentic-canvas
Prerequisites
- Node.js 20.19 or newer
- npm
- A modern browser
- An MCP-capable client, such as Codex, Claude Code, or Claude Desktop
Setup
npm install
npm run buildRun
npm start -- --canvas excalidraw
npm start -- --canvas jsoncanvas
npm start -- --canvas flowFor package usage after publishing:
npx @trohde/agentic-canvas --canvas excalidraw
npx @trohde/agentic-canvas --canvas jsoncanvas
npx @trohde/agentic-canvas --canvas flowFlags:
--canvas <name>: canvas plugin, one ofexcalidraw,jsoncanvas,flow--port <n>: port, default3333--host <host>: bind host, default127.0.0.1--workspace <dir>: root for save/open/screenshot files, default current directory--open/--no-open: open the browser on startup, default open
Optional environment overrides are AGENTIC_CANVAS_PORT, AGENTIC_CANVAS_HOST, and AGENTIC_CANVAS_WORKSPACE. save_canvas, open_canvas, and screenshot file writes are constrained to the configured workspace root. An HTTP MCP client config only points at an already-running server; it does not choose that server's current working directory. Start the server with --workspace <project> when files should be scoped to a project directory. No secrets or .env file are required.
Develop
For backend, MCP tool, plugin, or workspace changes:
npm run devFor browser HMR, run the backend and Vite dev server in separate terminals:
npm run dev:server
npm run dev:webOpen http://127.0.0.1:5173 for the Vite UI. MCP clients should still connect to the backend at http://127.0.0.1:3333/mcp.
See docs/mcp-dev.md for Codex configuration, example profiles in docs/codex/,
MCP Inspector usage, and restart expectations.
Connect An MCP Client
With the server running on the default port:
claude mcp add --transport http agentic-canvas http://127.0.0.1:3333/mcpCodex example profiles are committed under docs/codex/ for readonly, authoring, and
dangerous tool sets. Copy one into your local Codex config instead of committing an
active .codex/config.toml.
Example tool flow:
- Call
get_canvas_stateto identify the active canvas type. - Call
get_canvas_capabilitiesto discover supported tool groups and preferred workflows. - For
--canvas excalidraw, callapply_canvas_patchto create several nodes in one atomic change. - Call
connect_objectsto add bound arrows between the nodes. - Call
auto_layout_objectsoralign_distribute_objectsto clean up spacing. - Call
find_objectsto locate objects by type, label text, geometry, style, link, or metadata. - Select an object in the browser and call
get_selected_objects; the tool returns the selected normalized object. - Call
select_objectswith an object id to select it from the MCP client. - Call
screenshot; the tool returns a PNG image. - Call
save_canvaswith{ "path": "demo" }; the file is written asdemo.excalidrawinside the workspace. - Call
clear_canvas, thenopen_canvaswith{ "path": "demo" }; the saved scene is restored.
save_canvas and open_canvas append the active canvas extension when no
extension is provided and reject other extensions. screenshot appends .png for
file writes and rejects other extensions.
For --canvas jsoncanvas, agents can use add_text_card, add_file_card,
add_link_card, create_group, connect_cards, find_cards, find_edges,
auto_layout_cards, and apply_jsoncanvas_patch. A typical JSON Canvas flow:
- Call
add_text_cardfor context, risks, decisions, and next steps. - Call
connect_cardswith labels such ascauses,mitigates, ordepends on. - Call
create_groupto frame related cards. - Call
auto_layout_cards. - Call
save_canvaswith{ "path": "architecture-review" }; the file is written asarchitecture-review.canvas.
The JSON Canvas plugin writes standards-compatible .canvas files without Agentic
Canvas metadata. Default card sizes are intentional: text cards are 360x180,
file/link cards are 360x120, and groups are 520x360. connect_cards defaults
toEnd to "arrow"; pass toEnd:"none" for a plain line. auto_layout_cards
treats layerSpacing and nodeSpacing as gaps added to measured card sizes, so
small explicit spacing values should not overlap cards. It does not fetch link
previews, index Obsidian vaults, or render arbitrary embedded media in this
version.
For --canvas flow, agents should use Flow-specific graph tools instead of
generic shape tools. Available operations include add_flow_node, add_port,
connect_flow_nodes, find_flow_nodes, find_flow_edges, find_upstream,
find_downstream, find_paths, find_cycles, validate_flow,
auto_layout_flow, export_mermaid, and transactional apply_flow_patch. A
typical Flow graph flow:
- Call
apply_flow_patchoradd_flow_nodeto create typed services, systems, data stores, queues, steps, risks, controls, and boundaries. - Call
add_portwhere interface, data, or queue semantics matter. - Call
connect_flow_nodeswith edge types such ascalls,publishes,subscribes,reads,writes,mitigates, ordepends_on. - Call
validate_flow, thenauto_layout_flow. Use{ "mode": "strict", "domainRules": true }when required ports, decision connectivity, self-loops, and containment consistency should be enforced. - Call
export_mermaidwhen a text diagram is needed; boundaries export as Mermaidsubgraphblocks and labels are escaped for Mermaid syntax. - Call
save_canvaswith{ "path": "system-flow" }; the file is written assystem-flow.flow.
Flow writes Agentic Canvas-native .flow JSON with type:"agentic-flow" and
version:1. It is designed for architecture, workflow, data-lineage, and
risk/control maps, but it is not BPMN, ArchiMate, UML, or C4 compliant in this
version. Structural containment uses parentId; contains edges are treated as
an optional mirrored relationship and Flow tools reconcile them after mutations.
Self-loops are allowed by default and are reported by find_cycles,
find_paths, and validation stats; strict/domain validation reports them as
errors.
Agent Plugins
This repository bundles one Agentic Canvas plugin payload under
plugins/agentic-canvas, packaged for Codex, Claude Code, and GitHub Copilot.
All three formats use the same bundled skill and the same .mcp.json endpoint for
http://127.0.0.1:3333/mcp.
Marketplace and manifest files:
- Codex:
.agents/plugins/marketplace.jsonandplugins/agentic-canvas/.codex-plugin/plugin.json - Claude Code:
.claude-plugin/marketplace.jsonandplugins/agentic-canvas/.claude-plugin/plugin.json - GitHub Copilot CLI / VS Code Agent Plugins:
.github/plugin/marketplace.jsonandplugins/agentic-canvas/plugin.json - Compatibility:
plugins/agentic-canvas/.plugin/plugin.json
Install for Codex from a checkout of this repository:
codex plugin marketplace add .
codex plugin add agentic-canvas@agentic-canvasInstall for GitHub Copilot CLI from a checkout or GitHub repository:
copilot plugin marketplace add .
copilot plugin install agentic-canvas@agentic-canvasInstall for Claude Code from a checkout or GitHub repository:
claude plugin marketplace add .
claude plugin install agentic-canvas@agentic-canvasStart a new agent thread/session after installing so plugin skills and MCP tools are
loaded. The plugin connects to http://127.0.0.1:3333/mcp, so start Agentic Canvas
before using it. Select the canvas type when starting the server:
npx @trohde/agentic-canvas@latest --canvas excalidraw --workspace <project-dir>
npx @trohde/agentic-canvas@latest --canvas jsoncanvas --workspace <project-dir>
npx @trohde/agentic-canvas@latest --canvas flow --workspace <project-dir>The plugin is one marketplace entry for all Agentic Canvas canvas types. It does not
encode the canvas type in .mcp.json; agents should call get_canvas_state and
get_canvas_capabilities to select Excalidraw, JSON Canvas, Flow, or future
canvas-specific workflows. For parallel canvases, run separate Agentic Canvas
servers on different ports and configure additional MCP entries manually.
Test And Build
npm run verify
npm run buildIndividual checks:
npm run typecheck
npm run lint
npm testBuilt-server smoke test:
node dist/cli/index.js --no-open --port 3939Then probe http://127.0.0.1:3939/healthz and call get_canvas_state through an MCP Streamable HTTP client.
MCP Inspector:
npm run inspect:mcpManual UI Verification
- Run
npm run build && npm start -- --canvas excalidraw. - Connect an MCP client to
http://127.0.0.1:3333/mcp. - Call
draw_rectangle,add_text,draw_arrow, andcreate_flowchart. - Confirm the shapes appear live in the browser.
- Call
save_canvas,clear_canvas, andopen_canvas; confirm the scene clears and reloads. - Select a shape in the browser, then call
get_selected_objects; confirm the selected object id is returned. - Call
select_objects; confirm the browser selection changes. - Call
undoandredo; confirm the browser scene follows the server history. - Call
screenshot; confirm a PNG is returned and, whenpathis provided, written in the workspace. - Drag or edit a shape by hand in the browser, then call
list_objects; confirm the listing reflects the human edit.
For JSON Canvas, run npm run build && npm start -- --canvas jsoncanvas --workspace <tmp-dir>, then call add_text_card, connect_cards, auto_layout_cards, save_canvas, clear_canvas, open_canvas, and screenshot. Confirm cards and edges appear in the browser, drag a card, and verify get_object reflects the updated x/y.
For Flow, run npm run build && npm start -- --canvas flow --workspace <tmp-dir>,
then call apply_flow_patch, connect_flow_nodes, validate_flow,
auto_layout_flow, export_mermaid, save_canvas, clear_canvas,
open_canvas, and screenshot. Confirm typed nodes, ports, and edges appear in
the browser, browser edits sync back, selection round-trips through
select_objects and get_selected_objects, and saved files use .flow.
Release Checks
This project follows Semantic Versioning. Version scripts update package.json and package-lock.json without committing or tagging:
npm run version:patch
npm run version:minor
npm run version:majorBefore publishing, run:
npm run release:dry-runSee docs/release.md for the GitHub Actions and npm trusted publishing flow.
Project Structure
src/cli/ CLI entry
src/server/ Express, MCP HTTP, WebSocket bridge, workspace safety
src/mcp/ MCP server registration and baseline tools
src/core/ Plugin interface and normalized scene types
src/plugins/excalidraw/ Excalidraw plugin, element builder, adapter, tools
src/plugins/flow/ Flow model, validation, graph algorithms, layout, tools
src/plugins/jsoncanvas/ JSON Canvas model, adapter, validation, tools
src/web/ React browser app and canvas renderers
src/shared/ Shared protocol and logger
tests/ Vitest unit and integration tests
docs/ Architecture notes, MCP development docs, Codex profiles
scripts/ Release and package smoke scripts
.github/workflows/ CI and npm publish workflowsKnown Limitations
- HTTP MCP transport only; no stdio transport in v1.
- Single browser session is the expected mode.
- Full-scene sync is used instead of diffs or CRDT collaboration.
- Screenshot and selection tools require a connected browser. Selection is
ephemeral browser UI state, may be cleared by mutations or undo/redo, and is not
persisted in
.excalidraw,.canvas, or.flowfiles. - MCP
versionfields are monotonic scene revision counters, not package versions, scene hashes, or optimistic-concurrency tokens. - The Excalidraw tool surface is intentionally small: shapes, text, frames, groups, arrows, flowcharts, object search, atomic patches, layout cleanup, save/open, and screenshot.
- The JSON Canvas tool surface is semantic-card focused: text/file/link cards, groups, edges, search, layout, atomic patches, save/open, and screenshot.
- The Flow tool surface is typed-graph focused: nodes, ports, edges, traversal, validation, deterministic layout, Mermaid export, atomic patches, save/open, and screenshot. Flow is an Agentic Canvas-native graph format, not a standards-compliant BPMN, ArchiMate, UML, or C4 implementation.
