Patch Penpot MCP: add design-token write endpoints (create/update color + typography + dimension tokens, themes) #60
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks#60
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story
As the designer agent (from #56), I want to create and modify design tokens — colors, typographies, dimensions, themes — programmatically through the Penpot MCP, so that when I open a new design file I can seed a proper token-backed palette instead of drawing visual swatches as regular shapes.
Context
Penpot has first-class design-token support (Tokens tab in the UI: Border Radius, Color, Dimensions, Font Family, Font Size, Font Weight, Letter Spacing, Number, Opacity, Rotation, Shadow, Sizing, Spacing, Stroke Width, Text Case, Text Decoration, Typography + Themes + Collections). The internal format is DTCG-compatible (Design Tokens Community Group / Tokens Studio).
Our patched MCP at
~/Workspace/penpot-mcp-server/currently exposes:get_design_tokens(file_id)— read path, DB-only, fails on our OIDC Penpot instance because the DB pool isn't initialized (see #57's context; same symptom aslist_teams).create_color,update_color,create_theme,apply_token_to_shape, nothing.Consequence on #55: we drew 24 colored rectangles + 72 labels to mimic a token palette visually. That's not real tokens — shapes can't bind to the palette, theme-switch is impossible, and exporting for CSS/Style Dictionary means the operator copy-pastes from a handoff comment instead of pointing a tool at a JSON file.
The
designeragent from #56 is blocked from doing this properly until the MCP can write tokens.Short-term workaround (landing in parallel): hand-authored DTCG JSON at
design/tokens.jsonin this repo, user imports it via Penpot's Tokens tab UI. Works for today but not sustainable for agent-driven design.Acceptance criteria
MCP — new tools
Under
penpot-mcp-server/src/penpot_mcp/tools/(or equivalent):create_color_token(file_id, set_name, name, value, description?)— inserts a color token into the given token set (creating the set if missing).update_color_token(file_id, set_name, name, value)— updates an existing token; errors if missing.delete_color_token(file_id, set_name, name)— removes a token.create_typography_token(file_id, set_name, name, font_family, font_size, font_weight, letter_spacing?, line_height?)— typography composite.create_dimension_token(file_id, set_name, name, value, type)—type∈spacing/sizing/borderRadius/strokeWidthetc.create_theme(file_id, theme_name, set_names[])— bundles token sets into a named theme.set_active_theme(file_id, theme_name)— marks which theme is active in the file's metadata.import_tokens_dtcg(file_id, json_string)— bulk import from DTCG / Tokens Studio JSON; one shot covers everything above.MCP — fallback behavior
get_design_tokenswork on the OIDC instance (mirrors theget_file_infoRPC fallback we landed on #55). If the DB pool isNone, fall through toapi.command("get-file", ...)and pluck thetokens-libsection.Write path — implementation strategy
Two viable approaches, pick one:
update-filecommand acceptsmod-token/add-token/del-tokenchange operations. This is how the UI itself does it. Mirrors the existingchanges.pystyle — cleanest, zero new dependencies.execute_plugin_script— Penpot's plugin API haslibrary.colors.createColor(...),library.typographies.createTypography(...), etc. Works but adds a runtime layer.Strong preference: (1) direct RPC — matches the rest of
services/api.py, same auth model, sameapply_changesflow.Tests
get_design_tokens→ assert present → delete → assert absent).design/tokens.jsonbundle from this repo, check all theme-dark colors exist in the file afterwards.apply_changesrevn handling must cover token writes).Image + deployment
claude-hooks:devrebuild picks up the new tools (sincepenpot-mcp-server/is baked in per #57's infra work or its predecessor).designeragent container (#56) sees the new tools via the Penpot MCP binding.Documentation
penpot-mcp-server/README.md: document the new token tools.penpot-mcp-server/CHANGELOG.md(or equivalent): note the addition.Out of scope
import_tokens_dtcgtool is enough.References
design/tokens.jsonin this repo — DTCG JSON the operator imports manually via Penpot UI.services/changes.pyin our patched MCP (same patterns, new change types).Dependencies
main, or thepenpot-mcp-server/vendored copy if we fork it into the claude-hooks repo.designer+design-reviewercontainers #64