Skip to content

Commit f38118a

Browse files
committed
feat: enhance instructions for get_code tool with detailed usage guidelines and layout handling
1 parent 236c5d9 commit f38118a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
You are connected to a Figma design file via the MCP server. Convert design elements into production code, preserving design intent while fitting the user’s codebase conventions.
22

3-
- Start from `get_code` as the baseline, then refactor to match project conventions (components, styling system, file structure, naming).
3+
- Start from `get_code` as the baseline (omit `nodeId` to use the current single selection), then refactor to match project conventions (components, styling system, file structure, naming). Treat `get_code` as authoritative.
4+
- If `get_code` returns a `depth-cap` warning, call `get_code` again once per listed `nodeId` to fetch each omitted subtree.
45
- Layout confidence:
5-
- If `get_code` contains no `data-hint-auto-layout`, it likely indicates the layout is explicit. You can be more confident implementing directly from `get_code`.
6-
- If any `data-hint-auto-layout` is `none` or `inferred`, the corresponding layout may be uncertain. If you feel ambiguity or uncertainty, consult `get_structure` (hierarchy + geometry) and `get_screenshot` (visual intent such as layering/overlap/masks/shadows/translucency).
7-
- If `data-hint-component` plus repetition supports it, extract reusable components/variants aligned with project patterns. Do not preserve hint strings in output.
6+
- If `data-hint-auto-layout="inferred"` appears, layout may be less certain. You can call `get_structure` or `get_screenshot` with a specific `nodeId` (both accept `nodeId`, otherwise they use the current single selection) to improve layout understanding, but keep `get_code` as the baseline.
7+
- Otherwise, assume layout is explicit and implement directly from `get_code`.
8+
- If `data-hint-design-component` plus repetition supports it, extract reusable components/variants aligned with project patterns. Do not preserve hint strings in output.
89
- Tokens: `get_code.tokens` is a single map keyed by canonical token name. Multi‑mode values use `${collectionName}:${modeName}` keys. Nodes with explicit overrides include `data-hint-variable-mode="Collection=Mode;Collection=Mode"`; use this to pick the correct mode for a given node. Collection names are assumed unique.
910
- Assets: follow the project’s existing conventions/practices (icon system, asset pipeline, import/path rules, optimization) to decide how to represent and reference assets. If `get_code` uses resource URIs, you may replace them with the project’s canonical references when appropriate without changing rendering.
10-
- Do not output any `data-*` attributes returned by `get_code`.
11+
- Do not output any `data-*` attributes returned by `get_code` (they are hints only).
1112
- For SVG/vector assets: use the exact provided asset, preserving `path` data, `viewBox`, and full SVG structure. Never redraw or approximate vectors.

packages/mcp-server/src/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const TOOL_DEFS = [
7171
extTool({
7272
name: 'get_code',
7373
description:
74-
'Get a high-fidelity code snapshot for a nodeId/current selection, including assets/tokens and codegen plugin/config. Start here, then refactor into your component/styling/file/naming conventions; strip any data-* hints. If no data-hint-auto-layout is present, layout is explicit; if any hint is none/inferred, pair with get_structure/get_screenshot to confirm hierarchy/overlap. Use data-hint-component plus repetition to decide on reusable components. Replace resource URIs with your canonical asset system as needed. Tokens: get_code.tokens is a single map keyed by canonical token name; multi-mode values use `${collectionName}:${modeName}` keys. Nodes with explicit mode overrides include data-hint-variable-mode="Collection=Mode;Collection=Mode". Collection names are assumed unique.',
74+
'Get a high-fidelity code snapshot for a nodeId/current selection (omit nodeId to use the current single selection), including assets/tokens and codegen plugin/config. Start here, then refactor into your component/styling/file/naming conventions; strip any data-* hints. Treat get_code as authoritative. If warnings include depth-cap, call get_code again once per listed nodeId to fetch each omitted subtree. If any data-hint-auto-layout="inferred" appears, you may call get_structure or get_screenshot with a nodeId (both accept nodeId; omit it to use the current single selection) to confirm hierarchy/overlap, but keep get_code as the baseline. Use data-hint-design-component plus repetition to decide on reusable components. Replace resource URIs with your canonical asset system as needed. Tokens: get_code.tokens is a single map keyed by canonical token name; multi-mode values use `${collectionName}:${modeName}` keys. Nodes with explicit mode overrides include data-hint-variable-mode="Collection=Mode;Collection=Mode". Collection names are assumed unique.',
7575
parameters: GetCodeParametersSchema,
7676
target: 'extension',
7777
format: createCodeToolResponse

0 commit comments

Comments
 (0)