MCP
AI Agent를 활용해 생산성을 높일 수 있는 Model Context Protocol(MCP)를 제공합니다.
설치
Prerequisites
Cursor
Cursor Settings > MCP > Add MCP Server 에 다음 설정을 추가합니다.
{
"mcpServers": {
"SEED Design": {
"command": "bunx",
"args": ["-y", "@seed-design/mcp"],
"type": "stdio"
}
}
}
Figma
Figma MCP 플러그인을 설치합니다.
사용법
웹소켓 서버 실행
bunx --bun @seed-design/mcp socket
Figma 플러그인 실행
설치된 SEED Design MCP 플러그인을 실행합니다.
연결이 완료되면, 선택된 노드를 참고해 React로 구현해주세요.
와 같은 요청을 전달할 수 있습니다.
주요 툴 목록
get_selection
선택한 노드의 id를 반환합니다.
get_node_react_code
노드의 React codegen 결과를 반환합니다.
export_node_as_image
노드의 이미지를 반환합니다. Playwright MCP 등과 통합해 이미지 단위 비교에 활용할 수 있습니다.
add_annotations
Figma 파일에 Annotation을 추가합니다. 참고
커스텀 설정 사용하기
--config
플래그를 통해 커스텀 설정 파일을 로드할 수 있습니다.
bunx --bun @seed-design/mcp --config /path/to/config.ts
지원하는 설정 파일 형식
@seed-design/mcp
는 다음 확장자의 설정 파일을 지원합니다:
.js
.mjs
.ts
.mts
설정 파일 예시
import { type react, defineComponentHandler, createElement } from "@seed-design/figma";
export default {
extend: {
componentHandlers: [
(_deps: react.ComponentHandlerDeps) => defineComponentHandler(
"figma_component_key",
({ componentProperties: props }) => {
const tone = props.Tone.value.toLowerCase();
return createElement(
"CustomButton",
{
tone
}
);
}
)
]
},
} satisfies react.CreatePipelineConfig;
MCP로 ComponentHandler 작성하기
프롬프트 복사
아래 프롬프트를 복사해 파일로 저장합니다.
Cursor IDE를 사용하는 경우, Cursor rule로 저장할 수 있습니다.
# ComponentHandler Implementation Guide
## Initial Context Gathering
1. **Analyze Figma Selection**:
- Use \`get_selection()\` to examine the currently selected node(s)
- If no selection exists, prompt the user to select a specific component node
- Verify the selected node is a component that can be transformed
2. **Retrieve Component Information**:
- Use \`get_component_info(nodeId)\` to extract detailed information about the component
- Collect the component key, all component properties, and variant definitions
- Identify any nested components or instances that might need special handling
## Component Analysis and Planning
3. **Determine Component Structure**:
- Analyze the component's visual structure, layout, and behavior patterns
- If the target React component implementation is unknown, request an example or props interface
- Identify which Figma properties should map to which React props
4. **Define Transformation Strategy**:
- Plan how to handle variants, properties, nested components and children
- Determine if additional utilities or helper functions are needed
- Consider edge cases and special requirements for this component
## Implementation
5. **Create Component Handler**:
- Implement the handler using the following pattern:
\`\`\`typescript
import {
createElement,
defineComponentHandler,
type InferComponentDefinition,
type react,
} from "@seed-design/figma";
// Define component properties based on Figma definition
export type ComponentNameProperties = InferComponentDefinition<{
// Map all component properties from Figma
// Example:
"PropertyName": {
type: "VARIANT" | "TEXT" | "BOOLEAN" | "INSTANCE_SWAP",
variantOptions?: string[], // For VARIANT type
defaultValue?: string | boolean
}
}>;
// Create and export the handler
export const createComponentNameHandler = (_deps: react.ComponentHandlerDeps) => defineComponentHandler<ComponentNameProperties>(
"component-key-from-figma", // Replace with actual component key
({ componentProperties: props }) => {
// Transform Figma properties to React props
// Use conditionals for variants and property handling
return createElement(
"ComponentName", // The React component name
{
// Map properties appropriately
propName: props.PropertyName.value,
// Add additional props as needed
},
[], // Nested elements if any (undefined or omitted if not needed)
"Optional comment for accessibility or development notes, use sparingly"
);
}
);
\`\`\`
## Validation and Testing
6. **Verify Handler Functionality**:
- Test the handler with different component variants
- Ensure all properties are correctly mapped and transformed
- Check that nested components and children are handled properly
## Best Practices
- Create reusable helper functions for common transformation patterns
- Handle edge cases and optional properties gracefully
- Add descriptive comments for complex transformations
- Consider performance implications for deeply nested components
- Ensure type safety throughout the transformation process
프롬프트 실행
저장된 프롬프트 파일과 구현해야 할 컴포넌트 파일을 맥락으로 전달하며 프롬프트를 실행합니다.
예시:
@CustomButton.tsx @ComponentHandlerRule.md CustomButton 컴포넌트의 ComponentHandler를 구현해주세요.
결과 확인
프롬프트 실행 결과로 생성된 ComponentHandler를 확인합니다.
예시
import {
createElement,
defineComponentHandler,
type InferComponentDefinition,
type react,
} from "@seed-design/figma";
export type CustomButtonProperties = InferComponentDefinition<{
tone: {
type: "VARIANT";
variantOptions: ["neutral", "brand"];
};
}>;
export const createCustomButtonHandler = (_deps: react.ComponentHandlerDeps) => defineComponentHandler<CustomButtonProperties>(
"figma_component_key",
({ componentProperties: props }) => {
const tone = props.tone.value.toLowerCase();
return createElement(
"CustomButton",
{
tone
}
);
}
)
설정 파일 적용
생성된 ComponentHandler를 설정 파일에 추가합니다.
import { type react } from "@seed-design/figma";
import { createCustomButtonHandler } from "./CustomButton";
export default {
extend: {
componentHandlers: [
createCustomButtonHandler,
]
},
} satisfies react.CreatePipelineConfig;
Last updated on