Skip to content
View as Markdown
View as Markdown

sfnext_analyze_component

Analyzes design and discovered components to recommend a component generation strategy. Returns a REUSE, EXTEND, or CREATE action with confidence score, key differences, and suggested implementation approach.

Note: 🚧 This MCP tool is for Storefront Next. Storefront Next is part of a closed pilot and isn't available for general use.

Overview

The sfnext_analyze_component tool compares design React code (e.g., from Figma, design handoff, or other sources) against existing components discovered in the codebase. It analyzes differences across styling, structure, behavior, and props, then recommends the best approach:

  • REUSE: Use existing component with props or minor styling adjustments
  • EXTEND: Extend existing component via props, variant, or composition pattern
  • CREATE: Create a new component (reference existing patterns if applicable)

Workflow position: Call this tool after retrieving design data and discovering similar components. It is a required step in the Figma-to-component workflow.

This tool is part of the STOREFRONTNEXT toolset.

Prerequisites

  • Design React code (from Figma MCP, design handoff, or other sources)
  • Component discovery performed before calling
  • Storefront Next project

See Figma-to-Component Tools Setup for complete prerequisites and configuration.

Parameters

ParameterTypeRequiredDescription
figmaMetadatastringYesJSON string containing design metadata (from Figma MCP or empty). Can be empty string if metadata was not fetched.
figmaCodestringYesReact code from design (e.g., from Figma mcp__figma__get_design_context, or design handoff).
componentNamestringYesSuggested name for the component extracted from the design.
discoveredComponentsarrayYesArray of similar components discovered using Glob/Grep/Read. Pass empty array if no similar components found.
workspacePathstringNoOptional workspace root path. Defaults to the MCP server project directory.

Discovered Component Schema

Each item in discoveredComponents must have:

FieldTypeDescription
pathstringAbsolute file path to the component
namestringComponent name
similaritynumberSimilarity score (0–100)
matchTypestringOne of 'name', 'structure', 'visual'
codestringFull source code of the component

Usage Examples

With Figma design URL

I have a Figma design at [URL]. Use the MCP tool to fetch the design code, search the codebase for similar components, then analyze and recommend whether to reuse, extend, or create a component.

With design code already fetched

Use the MCP tool to analyze this design and recommend reuse, extend, or create. Design code: [paste React/JSX from Figma or design handoff]. Search the codebase for similar components first, then call the tool with the discovered components.

Agent workflow note

When the agent searches the codebase and finds no similar components, it should still call the tool with discoveredComponents: [] to get a CREATE recommendation. The user does not need to specify this—the agent discovers it during the workflow.

Output

Returns a formatted recommendation including:

  • Decision: REUSE, EXTEND, or CREATE
  • Confidence: Percentage (0–100)
  • Matched Component: Path, name, similarity (if applicable)
  • Key Differences: List of difference descriptions
  • Suggested Approach: Implementation guidance
  • Next Steps: Action-specific instructions

See Also

Released under the Apache-2.0 License.