When a task requires building or modifying a user interface, you must use the tools available in the shadcn-ui MCP server.
When planning a UI build using shadcn:
- Discover Assets: First, use
list_components()andlist_blocks()to see all available assets in the MCP server. - Map Request to Assets: Analyze the user's request and map the required UI elements to the available components and blocks.
- Prioritize Blocks: You should prioritize using blocks (
get_block) wherever possible for common, complex UI patterns (e.g., login pages, calendars, dashboards). Blocks provide more structure and accelerate development. Use individual components (get_component) for smaller, more specific needs.
When implementing the UI:
- Get a Demo First: Before using a component, you must call the
get_component_demo(component_name)tool. This is critical for understanding how the component is used, its required props, and its structure. - Retrieve the Code:
- For a single component, call
get_component(component_name). - For a composite block, call
get_block(block_name).
- Implement Correctly: Integrate the retrieved code into the application, customizing it with the necessary props and logic to fulfill the user's request.
MCP repository: https://github.com/Jpisnice/shadcn-ui-mcp-server
Refer to https://www.youtube.com/watch?v=YKJLpgXTxCo for usage. The rule is made by him, I just slightly modified it for better redability.