Skip to content

Commit 2e45704

Browse files
authored
Merge branch 'main' into changeset-release/main
2 parents 159df7e + 728a114 commit 2e45704

File tree

70 files changed

+10792
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+10792
-426
lines changed

.github/workflows/3pl-guard.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,14 @@ jobs:
123123
per_page: 100,
124124
});
125125
126+
// Exclude package.json under test/fixtures/ (e.g. e2e workspace-detection fixtures)
127+
const isUnderTestFixtures = (filename) =>
128+
filename.includes('/test/') && filename.includes('/fixtures/');
126129
const changedPackageJsonFiles = files
127130
.map((file) => file.filename)
128-
.filter((filename) => filename.endsWith('package.json'));
131+
.filter((filename) =>
132+
filename.endsWith('package.json') && !isUnderTestFixtures(filename),
133+
);
129134
130135
const findings = [];
131136
@@ -200,4 +205,4 @@ jobs:
200205
await addLabel(reviewLabel);
201206
core.setFailed(
202207
`Net-new third-party dependencies found: ${allNetNewDeps.join(', ')}. Add \`${approvalLabel}\` after review.`,
203-
);
208+
);

.github/workflows/e2e-tests.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,39 @@ jobs:
166166
if (context.eventName === 'schedule') {
167167
github.rest.issues.create(issue);
168168
}
169+
170+
mcp-e2e-tests:
171+
name: MCP E2E
172+
runs-on: ubuntu-latest
173+
timeout-minutes: 15
174+
steps:
175+
- uses: actions/checkout@v4
176+
- uses: actions/setup-node@v4
177+
with:
178+
node-version: '22.x'
179+
- name: Setup pnpm
180+
uses: pnpm/action-setup@v4
181+
with:
182+
version: 10.17.1
183+
- name: Get pnpm store directory
184+
id: pnpm-store
185+
shell: bash
186+
run: |
187+
echo "store_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
188+
- name: Setup pnpm cache
189+
uses: actions/cache@v4
190+
with:
191+
path: ${{ steps.pnpm-store.outputs.store_path }}
192+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
193+
restore-keys: |
194+
${{ runner.os }}-pnpm-store-
195+
- name: Install dependencies
196+
run: pnpm install --frozen-lockfile
197+
- name: Build packages
198+
run: pnpm -r run build
199+
- name: Run MCP E2E tests
200+
working-directory: packages/b2c-dx-mcp
201+
env:
202+
SFCC_DISABLE_TELEMETRY: 'true'
203+
NODE_ENV: test
204+
run: pnpm run test:e2e:ci

docs/.vitepress/config.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const guideSidebar = [
5858
{text: 'Installation', link: '/mcp/installation'},
5959
{text: 'Configuration', link: '/mcp/configuration'},
6060
{text: 'Toolsets & Tools', link: '/mcp/toolsets'},
61+
{text: 'Figma Tools Setup', link: '/mcp/figma-tools-setup'},
6162
],
6263
},
6364
{
@@ -99,9 +100,14 @@ const guideSidebar = [
99100
{text: 'mrt_bundle_push', link: '/mcp/tools/mrt-bundle-push'},
100101
{text: 'pwakit_development_guidelines', link: '/mcp/tools/pwakit-development-guidelines'},
101102
{text: 'scapi_schemas_list', link: '/mcp/tools/scapi-schemas-list'},
103+
{text: 'scapi_custom_api_scaffold', link: '/mcp/tools/scapi-custom-api-scaffold'},
102104
{text: 'scapi_custom_apis_status', link: '/mcp/tools/scapi-custom-apis-status'},
103105
{text: 'storefront_next_development_guidelines', link: '/mcp/tools/storefront-next-development-guidelines'},
106+
{text: 'storefront_next_figma_to_component_workflow', link: '/mcp/tools/storefront-next-figma-to-component-workflow'},
107+
{text: 'storefront_next_generate_component', link: '/mcp/tools/storefront-next-generate-component'},
108+
{text: 'storefront_next_map_tokens_to_theme', link: '/mcp/tools/storefront-next-map-tokens-to-theme'},
104109
{text: 'storefront_next_page_designer_decorator', link: '/mcp/tools/storefront-next-page-designer-decorator'},
110+
{text: 'storefront_next_site_theming', link: '/mcp/tools/storefront-next-site-theming'},
105111
],
106112
},
107113
];

docs/mcp/figma-tools-setup.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
description: Prerequisites and setup for Figma-to-component tools (workflow orchestrator, generate component, map tokens).
3+
---
4+
5+
# Figma-to-Component Tools Setup
6+
7+
Prerequisites and setup for using the Figma workflow tools: `storefront_next_figma_to_component_workflow`, `storefront_next_generate_component`, and `storefront_next_map_tokens_to_theme`.
8+
9+
## Overview
10+
11+
The Figma-to-component workflow uses **two MCP servers** that must both be enabled in your MCP client:
12+
13+
1. **b2c-dx-mcp** - Workflow orchestration, component analysis (REUSE/EXTEND/CREATE), and token mapping
14+
2. **Figma MCP** (external) - Fetches design context, screenshots, and metadata from Figma files
15+
16+
For full end-to-end conversion from Figma design to Storefront Next component, both servers must be configured and enabled.
17+
18+
## B2C DX MCP Configuration
19+
20+
Ensure the b2c-dx-mcp server is configured with:
21+
22+
- **`--project-directory`** - Must point to your Storefront Next project root. Required for:
23+
- `storefront_next_map_tokens_to_theme` - Theme file discovery (`app.css`)
24+
- `storefront_next_generate_component` - Workspace context
25+
- **`--allow-non-ga-tools`** - Figma tools are preview; this flag is required to enable them
26+
- **Storefront Next project** - Must have `app.css` or `src/app.css` for token mapping (or pass `themeFilePath` explicitly)
27+
28+
See [Installation](./installation) for MCP client setup (Cursor, Claude Desktop, etc.).
29+
30+
## Figma MCP Setup
31+
32+
The workflow calls Figma MCP tools to fetch design data. These come from a **separate Figma MCP server** that you must enable in your MCP client.
33+
34+
**Figma MCP tools used by the workflow:**
35+
36+
| Tool | Purpose |
37+
|------|---------|
38+
| `get_design_context` | Generates UI code from the design and returns asset URLs |
39+
| `get_screenshot` | Provides a visual reference image of the design |
40+
| `get_metadata` | Retrieves node hierarchy, layer types, names, positions, and sizes |
41+
42+
See the [Figma MCP Server Documentation](https://developers.figma.com/docs/figma-mcp-server) for official setup and tool details.
43+
44+
Figma provides two connection options. Check the [Figma MCP catalog](https://www.figma.com/mcp-catalog/) to see which your client supports, then follow the matching installation:
45+
46+
### Desktop MCP (Local)
47+
48+
Runs through the Figma desktop app on your machine. No API token required; uses your Figma app session.
49+
50+
- Requires the Figma desktop application to be installed and running
51+
- See [Figma MCP - Local Server Installation](https://developers.figma.com/docs/figma-mcp-server/local-server-installation/)
52+
53+
### Remote MCP (Hosted)
54+
55+
Connects directly to Figma's hosted endpoint. Does not require the desktop app but **requires a Figma Personal Access Token**.
56+
57+
- See [Figma MCP - Remote Server Installation](https://developers.figma.com/docs/figma-mcp-server/remote-server-installation/)
58+
59+
#### Creating a Figma Personal Access Token
60+
61+
1. Log in to [Figma](https://www.figma.com)
62+
2. Click your profile icon (top-left) → **Settings**
63+
3. Go to **Settings → Security → Personal Access Tokens**
64+
4. Click **Generate New Token** and give it a name (e.g., "MCP")
65+
5. Select **read-only** access for all scopes
66+
6. Click **Generate token** and **copy the token immediately** — Figma shows it only once
67+
68+
#### Storing the Token
69+
70+
Store the token in an environment variable (e.g., `FIGMA_API_KEY` or `FIGMA_ACCESS_TOKEN`). Do not hardcode it in configuration files or commit it to version control.
71+
72+
**Cursor** (`.cursor/mcp.json`):
73+
74+
```json
75+
{
76+
"mcpServers": {
77+
"figma": {
78+
"command": "...",
79+
"env": {
80+
"FIGMA_API_KEY": "your-token-here"
81+
}
82+
}
83+
}
84+
}
85+
```
86+
87+
Refer to your Figma MCP provider's documentation for the exact environment variable name and configuration.
88+
89+
## Figma Design File
90+
91+
### File Access
92+
93+
You must have **view access** (or higher) to the Figma file. The file cannot be restricted in a way that blocks API access.
94+
95+
### URL with node-id
96+
97+
The workflow requires a Figma URL that includes the `node-id` query parameter. This identifies the specific frame or component to convert.
98+
99+
**How to get a URL with node-id:**
100+
101+
1. Open the Figma file
102+
2. Select the frame or component you want to convert
103+
3. Right-click → **Copy link to selection** (or use the share menu)
104+
4. The copied URL will include `?node-id=1-2` (or similar)
105+
106+
**Supported URL formats:**
107+
108+
- `https://figma.com/design/:fileKey/:fileName?node-id=1-2`
109+
- `https://www.figma.com/design/:fileKey/:fileName?node-id=1-2`
110+
- `https://figma.com/file/:fileKey/:fileName?node-id=1-2`
111+
112+
### No Special Figma Configuration
113+
114+
The basic workflow does not require:
115+
116+
- Figma Dev Mode
117+
- Code Connect
118+
- Plugins
119+
- Special file structure
120+
121+
## Verification
122+
123+
To confirm both servers are working:
124+
125+
1. **b2c-dx-mcp** - List tools in your MCP client; you should see `storefront_next_figma_to_component_workflow`, `storefront_next_generate_component`, and `storefront_next_map_tokens_to_theme`
126+
2. **Figma MCP** - List tools; you should see `mcp__figma__get_design_context`, `mcp__figma__get_screenshot`, and `mcp__figma__get_metadata` (or similar names per your Figma MCP provider)
127+
128+
If the Figma MCP server is not enabled, the workflow tool will still return instructions and parsed parameters, but the AI assistant will not be able to fetch design data. Inform the user that the Figma MCP server must be enabled for full conversion.
129+
130+
## Related Documentation
131+
132+
- [storefront_next_figma_to_component_workflow](./tools/storefront-next-figma-to-component-workflow) - Workflow orchestrator (call first)
133+
- [storefront_next_generate_component](./tools/storefront-next-generate-component) - REUSE/EXTEND/CREATE recommendation
134+
- [storefront_next_map_tokens_to_theme](./tools/storefront-next-map-tokens-to-theme) - Token mapping
135+
- [STOREFRONTNEXT Toolset](./toolsets#storefrontnext) - Overview of Storefront Next tools
136+
- [Figma MCP Server Documentation](https://developers.figma.com/docs/figma-mcp-server) - Official Figma MCP setup

docs/mcp/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ AI assistants automatically decide which MCP tools to use based on your prompts.
120120
**Storefront Next Development:**
121121
- ✅ "I'm new to Storefront Next. Use the MCP tool to show me the critical rules I need to know."
122122
- ✅ "I need to build a product detail page. Use the MCP tool to show me best practices for data fetching and component patterns."
123+
- ✅ "I want to apply my brand colors to my Storefront Next site. Use the MCP tool to help me."
123124

124125
**SCAPI Discovery:**
125126
- ✅ "Use the MCP tool to list all available SCAPI schemas."
@@ -131,6 +132,11 @@ AI assistants automatically decide which MCP tools to use based on your prompts.
131132
**MRT Bundle Operations:**
132133
- ✅ "Use the MCP tool to build and push my Storefront Next bundle to staging."
133134

135+
**Figma-to-Component:**
136+
- ✅ "Use the MCP tool to convert this Figma design to a Storefront Next component: [Figma URL with node-id]"
137+
- ✅ "Use the MCP tool to create this homepage from the Figma design: [Figma URL with node-id]. Create new components or update existing components using the MCP tool if necessary, then update the home page. The expected result should be that the homepage matches as closely as possible to the provided Figma design."
138+
- ✅ "Use the MCP tool to map Figma design tokens to my theme."
139+
134140
See the [Toolsets & Tools Reference](./toolsets) for more prompting examples for each toolset.
135141

136142
## Telemetry

docs/mcp/installation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ This guide covers installing and configuring the B2C DX MCP Server for various M
1212
- A B2C Commerce project (for project-specific toolsets)
1313
- MCP client (Cursor, Claude Desktop, or compatible client)
1414

15+
**Figma-to-component tools:** If you use the Figma workflow tools (`storefront_next_figma_to_component_workflow`, `storefront_next_generate_component`, `storefront_next_map_tokens_to_theme`), you also need an external Figma MCP server enabled. See [Figma-to-Component Tools Setup](./figma-tools-setup) for prerequisites and configuration.
16+
1517
## Install via npm (Recommended)
1618

1719
```json
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
description: Workflow orchestrator for Figma-to-component conversion. Parses your Figma URL and guides your AI assistant through design-to-component conversion.
3+
---
4+
5+
# storefront_next_figma_to_component_workflow
6+
7+
Workflow orchestrator for converting Figma designs to Storefront Next components. When you ask your AI assistant to convert a Figma design, it starts with this workflow tool, which parses your URL and guides the assistant through the conversion.
8+
9+
## Overview
10+
11+
When you provide a Figma design URL, your AI assistant uses this tool to extract the file and node identifiers, then follows the workflow to fetch design data, analyze your codebase, and produce recommendations. The assistant will:
12+
13+
- Fetch design context and screenshots from Figma
14+
- **Ask for your approval before exporting images** — when the design contains image assets (photos, logos, icons), the assistant presents the list and waits for you to confirm before exporting
15+
- Discover similar components in your project
16+
- Recommend whether to REUSE, EXTEND, or CREATE a component
17+
- Map Figma design tokens to your theme variables
18+
19+
You receive a component recommendation with confidence score and a token mapping summary when the workflow completes.
20+
21+
This tool is part of the STOREFRONTNEXT toolset.
22+
23+
## Prerequisites
24+
25+
- **B2C DX MCP** configured with `--project-directory` pointing to your Storefront Next project and `--allow-non-ga-tools`
26+
- **Figma MCP server** (external) enabled in your MCP client for full workflow execution
27+
- **Valid Figma URL** with `node-id` query parameter (obtain by right-clicking a frame in Figma → Copy link to selection)
28+
29+
See [Figma-to-Component Tools Setup](../figma-tools-setup) for complete prerequisites and configuration.
30+
31+
## Authentication
32+
33+
No authentication required. This tool operates on local workflow files and URL parsing only.
34+
35+
## Parameters
36+
37+
| Parameter | Type | Required | Description |
38+
|-----------|------|----------|-------------|
39+
| `figmaUrl` | string | Yes | The Figma design URL to convert. Must be a valid URL and include the `node-id` query parameter. |
40+
| `workflowFilePath` | string | No | Optional absolute path to a custom workflow `.md` file. If not provided, uses the default built-in workflow. |
41+
42+
## Supported Figma URL Formats
43+
44+
The parser supports these URL formats:
45+
46+
- `https://figma.com/design/:fileKey/:fileName?node-id=1-2`
47+
- `https://www.figma.com/design/:fileKey/:fileName?node-id=1-2`
48+
- `https://figma.com/file/:fileKey/:fileName?node-id=1-2`
49+
50+
The `node-id` parameter accepts hyphen format (`1-2`) or colon format (`1:2`). The parser converts hyphens to colons for Figma MCP compatibility.
51+
52+
## Output
53+
54+
The workflow returns a guide with extracted Figma parameters (`fileKey`, `nodeId`, and original URL). After the full workflow completes, you receive a component recommendation (REUSE/EXTEND/CREATE) with confidence score and a token mapping summary.
55+
56+
**Example prompts:**
57+
- ✅ "Use the MCP tool to convert this Figma design to a Storefront Next component: [Figma URL with node-id]"
58+
- ✅ "Use the MCP tool to create this homepage from the Figma design: [Figma URL with node-id]. Create new components or update existing components using the MCP tool if necessary, then update the home page. The expected result should be that the homepage matches as closely as possible to the provided Figma design."
59+
- ✅ "Use the MCP tool to start the Figma-to-component workflow with a custom workflow file at /path/to/custom-workflow.md"
60+
61+
## Usage Examples
62+
63+
### Basic Workflow Start
64+
65+
```
66+
Use the MCP tool to convert this Figma design to a Storefront Next component: [Figma URL with node-id]
67+
```
68+
69+
### Custom Workflow File
70+
71+
```
72+
Use the MCP tool to start the Figma-to-component workflow with a custom workflow file at /path/to/custom-workflow.md
73+
```
74+
75+
### Full Homepage Implementation
76+
77+
Create a homepage from a Figma design, creating or updating components as needed:
78+
79+
```
80+
Use the MCP tool to create this homepage from the Figma design: [Figma URL with node-id]. Create new components or update existing components using the MCP tool if necessary, then update the home page. The expected result should be that the homepage matches as closely as possible to the provided Figma design.
81+
```
82+
83+
## Requirements
84+
85+
- Valid Figma URL from figma.com
86+
- URL must include `node-id` query parameter
87+
- For custom workflow: file must exist at the provided path
88+
89+
## Error Handling
90+
91+
The tool returns formatted error messages if:
92+
93+
- **Invalid URL**: URL is not from figma.com, or `fileKey`/`node-id` cannot be extracted
94+
- **Workflow file not found**: Custom `workflowFilePath` is provided but the file does not exist
95+
96+
**Example error format:**
97+
98+
```
99+
# Error: Invalid Figma URL
100+
101+
Could not extract node-id from URL. Expected query parameter: ?node-id=1-2
102+
103+
Please provide a valid Figma URL in the format:
104+
https://figma.com/design/:fileKey/:fileName?node-id=1-2
105+
```
106+
107+
## Related Tools
108+
109+
- [`storefront_next_generate_component`](./storefront-next-generate-component) - Analyzes design and discovered components; recommends REUSE/EXTEND/CREATE
110+
- [`storefront_next_map_tokens_to_theme`](./storefront-next-map-tokens-to-theme) - Maps Figma design tokens to theme variables
111+
- Part of the [STOREFRONTNEXT](../toolsets#storefrontnext) toolset
112+
- Auto-enabled for Storefront Next projects
113+
114+
## Figma MCP Tools (External)
115+
116+
The workflow relies on your AI assistant having access to Figma MCP tools to fetch design data:
117+
118+
- **get_design_context** - Generates UI code from the design and returns asset URLs
119+
- **get_screenshot** - Provides a visual reference image of the design
120+
- **get_metadata** - Retrieves node hierarchy, layer types, names, positions, and sizes
121+
122+
### Image Export and User Approval
123+
124+
The workflow requires the assistant to **ask for your approval before exporting any image assets**. The assistant will:
125+
126+
1. Call `get_design_context` **without** `dirForAssetWrites` on the initial call (never export on first call)
127+
2. Identify image-containing nodes (photos, banners, **logos**, **brand assets**, icons)
128+
3. Present the list of nodes to you
129+
4. Ask once: "Should I export these N image assets now? (yes/no)"
130+
5. Wait for your explicit "yes" before calling `get_design_context` with `dirForAssetWrites` to export
131+
132+
You are prompted **once per batch**—not per image. This ensures you control when assets are written to disk. Logo and brand assets are explicitly included in the identification criteria so they are not missed.
133+
134+
Ensure the Figma MCP server is enabled in your MCP client. See [Figma-to-Component Tools Setup](../figma-tools-setup) for configuration and the [Figma MCP Server Documentation](https://developers.figma.com/docs/figma-mcp-server) for official setup and tool details.
135+
136+
## See Also
137+
138+
- [Figma-to-Component Tools Setup](../figma-tools-setup) - Prerequisites and Figma MCP configuration
139+
- [STOREFRONTNEXT Toolset](../toolsets#storefrontnext) - Overview of Storefront Next development tools
140+
- [Configuration](../configuration) - Configure project directory
141+
- [Storefront Next Guide](../../guide/storefront-next) - Storefront Next development guide

0 commit comments

Comments
 (0)