npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

shadcn-mcp

v1.0.0

Published

MCP server for shadcn/ui component references

Readme

shadcn-mcp

An advanced MCP (Model Context Protocol) server for shadcn/ui component references. This server provides AI assistants like Claude with detailed, structured information about shadcn/ui components to help developers implement them correctly.

Features

  • Rich Component Library: Access to all shadcn/ui components with code, usage examples, and documentation
  • Enhanced Search: Find components by name, feature, category, or functionality
  • Component Composition Patterns: See how different components work together in common UI patterns
  • Migration Guides: Help with upgrading to React 19 and Tailwind CSS v4
  • Best Practices: Coding standards and patterns for shadcn/ui development
  • Theme Customization: Examples of how to customize components for different design systems
  • Accessibility Information: WCAG compliance levels and accessibility considerations for each component
  • Responsive Examples: See how components adapt to different screen sizes
  • Analytics: Track which components are most frequently requested
  • Validation: Validate components against shadcn/ui best practices
  • GitHub Synchronization: Keep components up-to-date with the latest shadcn/ui releases
  • Filesystem Storage: Easy to manage and extend component library

Installation

# Install globally
npm install -g shadcn-mcp

# Or run with npx (no installation required)
npx shadcn-mcp

Development

# Clone the repository
git clone https://github.com/yourusername/shadcn-mcp.git
cd shadcn-mcp

# Install dependencies
npm install

# Build the project
npm run build

# Start the server (runs on port 3176 by default)
npm start

# Start in development mode (auto-restart on changes)
npm run watch

# Test with the inspector
npm run inspector

Commands

  • npm start - Start the MCP server
  • npm run dev - Start the server in development mode
  • npm run watch - Start the server with auto-restart on file changes
  • npm run build - Build the TypeScript project
  • npm run inspector - Test the MCP server with the inspector utility
  • npm run sync - Synchronize components from shadcn/ui GitHub repository
  • npm run validate - Run component validation tool
  • npm run analytics - View component query analytics
  • npm run add-component - Add a new component interactively

Adding Custom Components

Use the interactive component adding tool:

npm run add-component

Or manually add a JSON file to the data/components directory following this structure:

{
  "name": "ComponentName",
  "description": "Description of the component",
  "code": "// Full component code here",
  "usage": "<ComponentName>Example usage</ComponentName>",
  "version": "1.0.0",
  "lastUpdated": "2025-05-16T12:00:00Z",
  "props": {
    "propName": {
      "type": "string",
      "description": "Description of the prop",
      "required": false,
      "default": "Default value"
    }
  },
  "importStatement": "import { ComponentName } from \"@/components/ui/component-name\"",
  "dependencies": ["package-name"],
  "examples": [
    {
      "name": "Example name",
      "code": "<ComponentName>Example code</ComponentName>",
      "description": "Example description"
    }
  ],
  "compositionPatterns": [
    {
      "name": "Pattern name",
      "description": "Pattern description",
      "code": "// Example code using multiple components",
      "components": ["ComponentName", "AnotherComponent"]
    }
  ],
  "themeCustomization": {
    "cssVariables": "--component-bg: oklch(var(--p));",
    "tailwindConfig": "theme: { extend: {...} }",
    "examples": [
      {
        "name": "Custom theme",
        "description": "Theme description",
        "code": ":root { ... }"
      }
    ]
  },
  "responsiveExamples": [
    {
      "breakpoint": "sm",
      "description": "Mobile layout",
      "code": "<div className=\"sm:flex\">...</div>"
    }
  ],
  "accessibility": {
    "wcagLevel": "AA",
    "considerations": ["Keyboard navigable", "Screen reader support"]
  },
  "features": ["feature1", "feature2"],
  "category": "Input",
  "relatedComponents": ["RelatedComponent"]
}

Configuration

Port Configuration

By default, the server runs on port 3176 to avoid conflicts with common development tools like Next.js. You can customize the port using an environment variable:

# Run on a custom port
PORT=4567 npm start

Claude Desktop

Add to your .claude.json configuration file (usually in your home directory):

{
  "mcpServers": {
    "shadcn-ui-server": {
      "command": "npx",
      "args": ["-y", "shadcn-mcp"]
    }
  }
}

Cursor

Add to your configuration:

{
  "mcpServers": {
    "shadcn-ui-server": {
      "command": "npx",
      "args": ["-y", "shadcn-mcp"]
    }
  }
}

API Endpoints

All endpoints are available at http://localhost:3176 by default:

  • POST /mcp/v1/components - Search for components

    • Body: { "query": "button" }
    • Returns: { "components": [...] }
  • GET /mcp/v1/components/:id - Get component by ID/name

    • Returns: { "component": {...} }
  • POST /mcp/v1/validate - Validate component code

    • Body: { "code": "// Component code" }
    • Returns: { "results": { "valid": true, "errors": [], "warnings": [], "suggestions": [] } }
  • GET /mcp/v1/analytics - Get component query analytics

    • Returns: { "stats": { "topQueries": [...], "totalQueries": 100 } }
  • GET /mcp/v1/categories - Get component categories

    • Returns: { "categories": ["Input", "Display", ...] }
  • GET /mcp/v1/categories/:category - Get components by category

    • Returns: { "components": [...] }
  • GET /mcp/v1/patterns - Get component patterns

    • Query: ?category=Form (optional)
    • Returns: { "patterns": [...] }
  • GET /mcp/v1/patterns/:name - Get pattern by name

    • Returns: { "pattern": {...} }
  • GET /mcp/v1/migrations - Get migrations

    • Returns: { "migrations": [...] }
  • GET /mcp/v1/migrations/:id - Get migration by ID

    • Returns: { "migration": {...} }
  • GET /mcp/v1/best-practices - Get best practices

    • Query: ?category=Styling (optional)
    • Returns: { "bestPractices": [...] }
  • GET /mcp/v1/best-practices/:id - Get best practice by ID

    • Returns: { "bestPractice": {...} }
  • GET /health - Health check endpoint

    • Returns: { "status": "healthy", "version": "1.2.0" }

Usage Examples with Claude

Here are some examples of how to use the shadcn-ui MCP with Claude:

  • Basic component request: "Show me the shadcn/ui Button component"
  • Feature search: "Which shadcn/ui components are good for form validation?"
  • Composition request: "How do I create a form with shadcn/ui components?"
  • Migration help: "How do I update my shadcn/ui components for React 19?"
  • Best practices: "What are the best practices for creating shadcn/ui components?"
  • Theme customization: "How can I change the colors of shadcn/ui components?"
  • Accessibility query: "What accessibility considerations do I need for the Dialog component?"
  • Responsive design: "How do I make the Card component responsive?"

The enhanced MCP features particularly benefit Claude Code, enabling it to generate better quality components that follow shadcn/ui patterns and best practices.

License

MIT