Ask what is open.
Start with get_editor_state. It reveals the
active file, selection, reusable components, and—when
requested—the schema required for safe edits.
Connected service reference
Nine MCP tools for reading, shaping, validating, and exporting
.pen design files—explained as practical decisions,
not protocol trivia.
01 / Mental model
Each “endpoint” below is an MCP tool call with a JSON argument object. The host handles transport, authentication, and response envelopes; you choose the right tool and provide valid arguments.
.pen files with ordinary file
tools.They are encrypted. Use Pencil’s inspection tools to understand
them, and Pencil’s design tool to change them.
Start with get_editor_state. It reveals the
active file, selection, reusable components, and—when
requested—the schema required for safe edits.
Use targeted reads, variables, layout snapshots, and
screenshots. Only then use batch_design for
small, coherent mutations.
Use snapshot_layout for clipping and geometry.
Use screenshots sparingly for color, type, alignment, and
visual fidelity.
02 / Tool index
Search by tool name, task, or argument. Open any row for its request shape and a copyable example grounded in the connected workspace.
Showing 9 tools
03 / Workflows
A good Pencil session is a short loop: orient, inspect, act, verify. These recipes show the smallest dependable sequence for common jobs.
Start broad, then descend only into the nodes that matter. Low read depths keep responses legible and reduce stale assumptions.
get_editor_state with the schema on your
first call.
batch_get with
readDepth: 1.
get_variables before interpreting variable
references.
Pencil is multiplayer. Re-read the target before editing, use a placeholder while constructing root frames, and verify immediately after each section.
get_guidelines for the matching
task.
batch_design script with named
nodes.
Clipping and bounds are cheap to inspect as data. Color, typography, and optical alignment require a rendered image.
snapshot_layout with
problemsOnly: true.
HTML export is a useful artifact, not a substitute for understanding component intent. Variables and node structure still inform maintainable production code.
export_html or
export_nodes to a deliberate output
path.
04 / Connection report
These checks used the active cards.pen document.
Read-only calls were preferred; write and export probes were
kept non-destructive.
get_editor_stateActive file, selection, 34 components, and schema
returned.
get_guidelinesGuide and style catalogs returned; Code guide loaded.
get_variablesLive token definitions returned from the active file.
batch_getTop-level canvas nodes and system metadata returned.
snapshot_layoutProblem-only structural scan returned clipped-node
locations.
get_screenshotFocused render probe completed on a reusable
component.
batch_designNon-mutating script probe completed without changing the
document.
export_nodesTemporary PNG export probe completed.
export_htmlTemporary HTML + CSS export probe completed.
05 / Guardrails
Most failures come from stale context, unsupported schema guesses, overly broad reads, or treating a collaborative canvas like a static file.
.pen.The format is encrypted. Pencil MCP is the supported read/write boundary.
Call editor state with the schema, then use only supported Pencil values—not CSS assumptions.
Re-read before edits. If a node moved or changed, inspect again instead of recreating it.
Begin at depth 1–3, group node IDs into a single call, and descend deliberately.
Keep each design script small and coherent. Verify the completed section before continuing.
Layout snapshots answer structural questions faster; screenshots are for visual fidelity.
06 / Iterate & deploy
Edit index.html, test locally, then deploy the
folder again. Cloudflare Pages updates the project while
preserving its production address.
npx wrangler pages deploy . \ --project-name pencil-mcp-field-guide