Repository navigation
feat(figma): add Figma MCP for design-to-code context - #558
Conversation
Read-only Figma MCP over the REST API with per-user OAuth, so coding agents get a real reference to the design instead of guessing. Tool names follow Figma's official MCP server: - design to code: get_design_context (screenshot + one-line-per-layer outline with auto-layout as flexbox CSS, text, component props and the comments pinned in the frame), get_metadata, get_screenshot, download_assets, get_variable_defs, get_motion_context, get_figjam, get_comments - design systems: get_libraries, search_design_system - Code Connect via Figma dev resources: get_code_connect_map, add_code_connect_map, get_code_connect_suggestions, get_context_for_code_connect - whoami and the create_design_system_rules prompt Code-to-design tools are left out: creating layers needs the Plugin API, which REST does not offer. Deployed on kubernetes-bun at sites-figma.deco.site. Exempt from withAuth because Authorization carries the caller's own Figma token; OAuth state is sealed with OAUTH_STATE_SECRET and redirects are pinned to decocms.com. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… less noise From a real get_design_context run on a FILA frame: - LINE layers are dividers: emit border-top with the stroke color instead of asking for an SVG export - text with Figma vertical trim gets text-box: trim-both cap alphabetic, which explains its cap-height box - text layers show their content, not their name (names were stale: "Tamanho: 43" holding "Tamanho: GG") - drop gap on single-child frames, a no-op in CSS - containers with absolute children get position: relative - notes list the fonts in use so the agent flags missing ones instead of substituting silently Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@tlgimenes could you review and approve this when you have a moment? Once it's approved, I'll set up the secrets and publish the MCP in Studio. Why: most task-board tasks link a Figma frame, but agents have no access to it. Figma's official MCP only accepts allowlisted clients. So agents guess the layout, and the result often doesn't match the design. This MCP reads designs through the public REST API, with each user's own Figma account. Tool names follow the official server. OAuth app: created in the Figma developer portal. It's public, not listed in the Community, and currently under Figma review. Its production callback, Related: decocms/studio#7870, so the decopilot chat shows MCP images to the model instead of base64 text. |
|
Review rápida comparando com o #387 (um Figma MCP anterior, wrapper 1:1 da REST API, que vou fechar em favor deste). O #558 cobre bem melhor o caso de design-to-code; abaixo, só o que o #387 tinha e aqui falta, mais dois pontos do diff. Sugestões (opcionais, nessa ordem de valor)
Pontos no diff
|
- tokenFrom strips a "Bearer " prefix if one reaches it, so a figd_ personal token is always detected (the runtime already strips it; this keeps the tool layer from depending on that) - reformat tools/shared.ts (stray blank lines inside the zod chains) - app.json and README: until Figma approves the OAuth app, only its owner can authorize, so tell users to connect with a personal access token through a Custom Connection Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@JonasJesus42 valeu pela review! Resolvi os pontos do diff no 2f1748e:
Aproveitei para incluir no Sobre as sugestões ( |
Why
Most Studio tasks link a Figma frame, but the board agents have no access to it. Figma only offers its official MCP to approved clients. So the agents guess, and the result often does not match the design. This MCP reads designs through the public REST API with each user's own Figma account (OAuth). It gives agents a real reference: a screenshot, the layout as CSS, the tokens and the designer's comments.
What
New
figma/MCP. Tool names follow Figma's official MCP server, so prompts and skills written for it carry over.get_design_context(start here),get_metadata,get_screenshot,download_assets,get_variable_defs,get_motion_context,get_figjam,get_commentsget_libraries,search_design_systemget_code_connect_map,add_code_connect_map,get_code_connect_suggestions,get_context_for_code_connect. Mappings are stored as Figma dev resources, because Figma's own Code Connect data is not in the public API.whoami, plus thecreate_design_system_rulespromptget_design_contextreturns the PNG of the node and one line per layer:The output also lists the unresolved comments pinned inside the frame. Briefs often say these are part of the spec.
Not included, by design:
use_figma,generate_figma_design,create_new_file,upload_assetsandgenerate_diagram. Creating or editing layers needs the Plugin API inside an open Figma client, and REST does not offer it.generate_imagealready exists in Studio.Gravacao.de.ecra.1.online-video-cutter.com.mp4
Deploy and auth (needs a reviewer)
deploy.json, served athttps://sites-figma.deco.site/mcp.figmais added toauth-exemptions.json, which needs reviewer sign-off. TheAuthorizationheader carries the caller's own Figma token, and every tool forwards it toapi.figma.com. There is no shared secret to check and no server-side credential exposed. This is the same situation asdynamic-yield.^3.0.0withstateSecret. The server refuses to boot withoutOAUTH_STATE_SECRET, so the code that carries the token is never plain base64.allowedRedirectHostsis pinned todecocms.com(plusEXTRA_ALLOWED_REDIRECT_HOSTS).figd_…) in the connection's Token field also works. It is sent asX-Figma-Token.Before merging
https://sites-figma.deco.site/oauth/callbackand the scopes listed infigma/README.md. A private app only accepts users from the Figma org that owns it; a public app goes through Figma review.FIGMA_CLIENT_ID,FIGMA_CLIENT_SECRET,OAUTH_STATE_SECRET.Verified
bun testinfigma/: 10 tests pass (URL parsing, CSS conversion, truncation, XML output, comment scoping).tsc --noEmitis clean forfigma/server/**. The errors inside@decocms/runtime@3.0.0sources also show up forgithub/and come from how dependencies were installed in this environment.check:auth,build:registryand the pre-commit format and lint checks pass.dist/server/main.js:/.well-known/oauth-authorization-serveris served.tools/listreturns the 15 tools andprompts/listreturns the prompt./authorizeredirects tofigma.com/oauthwith sealed state, and a non-decoredirect_uriis rejected.api.figma.comwith the forwarded token.🤖 Generated with Claude Code
Summary by cubic
Adds a Figma MCP server so coding agents get real design context — screenshot, layout as flexbox CSS, tokens, comments, library search and Code Connect — read through the public REST API with each user's own Figma account (OAuth). Tool names mirror Figma's official MCP server, so prompts and skills written for it carry over.
The server is read-only: creating or editing layers is not included because the REST API doesn't offer it. Code Connect mappings are stored as Figma dev resources.
get_design_contextoutput was refined from a real run: LINE layers render as border-top dividers with the stroke color, text shows its content instead of stale layer names, fonts in use are listed so missing ones get flagged, and layout noise (gaps on single-child frames, missingposition: relative) is dropped.Reviewer notes
figmais added toauth-exemptions.json: every tool forwards the caller's own Figma token in the Authorization header, so there is no shared secret to check and no server-side credential to protect. OAuth state and code are sealed withOAUTH_STATE_SECRET, and redirect hosts are pinned to decocms.com.figma/README.mdand provisionFIGMA_CLIENT_ID,FIGMA_CLIENT_SECRETandOAUTH_STATE_SECRETas site secrets. Until the app is approved, only its owner can authorize, so users connect with a personal access token (figd_…) through a Custom Connection; aBearerprefix on the token is stripped before detection. Note rate limits: View and Collab seats get about 20 Tier-1 reads per month; Dev and Full seats get 10–20 per minute.Written for commit 2f1748e. Summary will update on new commits.