nodeId.
get_code
Generate high-fidelity code output for a Figma selection, including markup, styles, assets, and design tokens.Target node ID to generate code for. If omitted, uses the current single selection in Figma.
Preferred output language. If omitted, TemPad Dev uses the design’s hint or detected language, falling back to JSX. Note that plugins may override this preference.
When
true, inlines token values for quick renders. When false (default), returns token metadata so you can map into your project’s theming system. Token resolution is mode-aware per node.Response Schema
Asset Descriptor Schema
Usage Example
Warnings
Thewarnings array may include:
Type:
depth-capThe response was truncated due to depth limits. The data field includes a cappedNodes array with node IDs that were not fully expanded.Action: Call get_code again for each listed nodeId to retrieve the full subtree.Type:
auto-layoutAuto-layout was inferred or uncertain. Layout may not be precise.Action: Use get_structure to confirm hierarchy and overlap with explicit geometry.Type: Error (not a warning)The output exceeded the payload size limit (~4MB). The error message includes current consumption, limit, and overage.Action: Pass a smaller subtree
nodeId to narrow scope, then retry.get_structure
Retrieve a compact structural and geometry outline for understanding node hierarchy, layout intent, and overlap.Target node ID to outline. If omitted, uses the current single selection.
Limit traversal depth. If omitted, traverses the full tree (subject to safety caps).
Response Schema
Usage Example
Use
get_structure when get_code warnings indicate auto-layout uncertainty or when you need explicit geometry for layout refactoring.get_screenshot
Capture a rendered PNG screenshot of a node for visual verification.Target node ID to screenshot. If omitted, uses the current single selection.
Response Schema
get_token_defs
Resolve canonical token names to literal values, optionally including all modes.Array of canonical token names in CSS variable form (e.g.,
--color-primary). Must start with --.When
true, includes all token modes (light, dark, etc.) instead of just the active mode.Response Schema
get_assets
Resolve asset hashes to downloadable URLs and metadata.Array of asset hashes (8 hex characters) from tool responses.
Response Schema
Error Handling
All tools may return these error codes:No TemPad Dev extension is connected or active.Troubleshooting:
- Open TemPad Dev panel in Figma and enable MCP
- Click the MCP badge to activate the tab if multiple tabs are open
- Keep the Figma tab active while running MCP tools
The selection is invalid or empty.Action: Select exactly one visible node, or pass a valid
nodeId.The target node is not visible (hidden layer or outside viewport).Action: Ensure the node is visible and not in a collapsed group.
The extension did not respond within the timeout period (default 15 seconds).Action: Try a smaller selection or increase
TEMPAD_MCP_TOOL_TIMEOUT.The extension disconnected during the operation.Action: Refresh the Figma tab and ensure MCP is enabled.
Best Practices
Start with get_code
Use
get_code as your primary source of truth for design implementation. It provides complete markup, styles, assets, and configuration.Use get_structure for clarity
When
get_code warnings mention auto-layout inference, call get_structure to verify hierarchy and positioning.Handle depth-cap warnings
If truncation warnings appear, make additional
get_code calls for each capped node ID to retrieve the full subtree.Download assets immediately
Asset URLs are ephemeral. Download bytes from
asset.url as soon as you receive them and store them in your project’s asset pipeline.