Skip to main content
Glama
magnusrodseth

shadcn MCP Server

shadcn/ui MCP Server

npm version npm downloads npm

A Model Context Protocol (MCP) server that provides AI assistants with direct access to shadcn/ui components and blocks. This server enables AI assistants like Claude (via Cursor) to fetch real-time component source code, documentation, and implementation examples.

โšก Quick Install

Get started instantly without any setup:

# Run directly with npx (no installation required)
npx @magnusrodseth/shadcn-mcp-server

# Or install globally
npm install -g @magnusrodseth/shadcn-mcp-server

Then add to your Cursor configuration:

{
  "mcpServers": {
    "shadcn": {
      "command": "npx",
      "args": ["@magnusrodseth/shadcn-mcp-server"]
    }
  }
}

Next, restart the MCP tool and your Cursor settings should look something like this:

Cursor Preview

Related MCP server: shadcn-ui MCP Server

๐ŸŽฏ What is this?

The Shadcn MCP Server bridges the gap between AI assistants and the shadcn/ui component library. Instead of relying on potentially outdated training data, AI assistants can now fetch the latest component implementations directly from the shadcn/ui repository.

Key Benefits

  • โœ… Always Up-to-Date: Fetches components directly from the official shadcn/ui repository

  • โœ… Complete Implementation: Get full source code, dependencies, and usage examples

  • โœ… AI-Powered Development: Let AI assistants help you implement components correctly

  • โœ… Time-Saving: No more manual copying from docs or searching for examples

๐Ÿ”„ How It Works

sequenceDiagram
    participant User as ๐Ÿ‘ค User
    participant Cursor as ๐Ÿ–ฅ๏ธ Cursor/AI Assistant
    participant MCP as ๐Ÿ”ง MCP Server
    participant GitHub as ๐Ÿ“ฆ shadcn/ui Repository

    User->>Cursor: "Show me button component"
    Cursor->>MCP: JSON-RPC Request (get_component)
    MCP->>GitHub: Fetch component data via API
    GitHub-->>MCP: Component source code & metadata
    MCP-->>Cursor: Structured component response
    Cursor->>Cursor: AI processes & formats
    Cursor-->>User: Formatted component with examples

    Note over MCP: Available Tools:<br/>โ€ข list_components<br/>โ€ข get_component<br/>โ€ข list_blocks<br/>โ€ข get_block

๐Ÿš€ Getting Started with Developing

Prerequisites

  • Node.js โ‰ฅ 22.0.0

  • pnpm (recommended) or npm

  • Cursor IDE (for AI integration)

  • Recommended: GitHub Personal Access Token (for higher rate limits)

1. Installation

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

# Install dependencies
pnpm install

# Build the project
pnpm run build

2. Cursor Configuration

# Run the setup script
node scripts/test-cursor.js

This script will:

  • Generate the correct Cursor configuration

  • Create a wrapper script for your system

  • Provide step-by-step instructions

Option B: Manual Configuration

  1. Find your Cursor settings:

    • macOS: ~/Library/Application Support/Cursor/User/globalStorage/cursor-settings.json

    • Windows: %APPDATA%\Cursor\User\globalStorage\cursor-settings.json

    • Linux: ~/.config/Cursor/User/globalStorage/cursor-settings.json

  2. Add the MCP server configuration:

{
  "mcpServers": {
    "shadcn": {
      "command": "node",
      "args": ["/absolute/path/to/shadcn-mcp-server/dist/index.js"],
      "env": {
        "GITHUB_TOKEN": "your_github_token_here"
      }
    }
  }
}
  1. Restart Cursor completely (quit and reopen)

3. Verify Installation

Open Cursor and try these commands with Claude:

"List all available shadcn components"
"Show me the button component source code"
"Get the dashboard-01 block implementation"
"What shadcn blocks are available?"

If configured correctly, Claude will fetch real-time data from the shadcn/ui repository!

๐Ÿงช Testing & Development

Local Testing

# Run unit tests
pnpm test

# Test MCP server integration
pnpm run test:mcp

# Manual testing (interactive)
pnpm run test:manual

Development Mode

# Development with hot reload
pnpm run dev

# Watch tests
pnpm run test:watch

# Clean build artifacts
pnpm run clean

๐Ÿ› ๏ธ Available Tools

Tool

Description

Example Usage

list_components

List all available shadcn/ui components

"What shadcn components are available?"

get_component

Get source code and metadata for a specific component

"Show me the button component"

list_blocks

List all available shadcn/ui blocks

"What shadcn blocks can I use?"

get_block

Get a complete shadcn/ui block implementation

"Get the dashboard-01 block"

๐Ÿ’ก Usage Examples

Basic Component Usage

User: "Show me how to create a button with different variants"

Claude with MCP: Will fetch the latest button component and provide:

  • Complete source code

  • All available variants (default, destructive, outline, secondary, ghost, link)

  • Size options (sm, default, lg, icon)

  • Usage examples with proper imports

  • Accessibility features

Advanced Block Implementation

User: "I need a complete dashboard layout"

Claude with MCP: Will fetch dashboard blocks and provide:

  • Full implementation code

  • Required dependencies

  • Component breakdown

  • Styling and layout structure

Real-time Component Discovery

User: "What new components were added to shadcn recently?"

Claude with MCP: Will fetch the current component list and highlight:

  • All available components

  • Brief descriptions

  • Categorization

๐Ÿ”ง Configuration Options

Environment Variables

Create a .env file in the project root:

# Optional: GitHub token for higher rate limits
GITHUB_TOKEN=ghp_your_token_here

# Optional: Enable debug logging
DEBUG=true

# Optional: Set environment
NODE_ENV=development
  1. Go to GitHub Settings > Developer settings > Personal access tokens

  2. Generate a new token (classic)

  3. No special permissions needed - public repository access is sufficient

  4. Add the token to your environment variables

Benefits of using a token:

  • Higher rate limits (5,000 requests/hour vs 60/hour)

  • More reliable for heavy usage

  • Better performance

๐Ÿ“ฆ Deployment Options

No installation required - always uses the latest version:

# No setup needed, just add to Cursor config:
{
  "mcpServers": {
    "shadcn": {
      "command": "npx",
      "args": ["@magnusrodseth/shadcn-mcp-server"],
      "env": {
        "GITHUB_TOKEN": "your_token_here"
      }
    }
  }
}

Benefits:

  • โœ… Always up-to-date

  • โœ… No global installation

  • โœ… Works immediately

  • โœ… No build step required

Option 2: Global npm Installation

# Install once, use everywhere
npm install -g @magnusrodseth/shadcn-mcp-server

# Use in Cursor config:
{
  "mcpServers": {
    "shadcn": {
      "command": "@magnusrodseth/shadcn-mcp-server"
    }
  }
}

Option 3: Local Development

Perfect for contributing or customization:

git clone https://github.com/yourusername/shadcn-mcp-server.git
cd shadcn-mcp-server
pnpm install && pnpm run build

# Use absolute path in Cursor config:
"command": "node",
"args": ["/path/to/shadcn-mcp-server/dist/index.js"]

Option 4: Direct Git Installation

npm install -g git+https://github.com/yourusername/shadcn-mcp-server.git

๐ŸŽฏ Architecture Overview

shadcn-mcp-server/
โ”œโ”€โ”€ index.ts                 # Main MCP server setup
โ”œโ”€โ”€ services/
โ”‚   โ””โ”€โ”€ shadcn-service.ts   # Core component fetching logic
โ”œโ”€โ”€ types/
โ”‚   โ””โ”€โ”€ shadcn.ts           # TypeScript definitions
โ”œโ”€โ”€ utils/
โ”‚   โ””โ”€โ”€ logger.ts           # Logging configuration
โ””โ”€โ”€ scripts/
    โ”œโ”€โ”€ test-cursor.js      # Cursor setup automation
    โ””โ”€โ”€ test-mcp.js         # MCP protocol testing

Key Components

  • MCP Server: Handles JSON-RPC communication with Cursor/Claude

  • Shadcn Service: Fetches components and blocks from GitHub API

  • Type Safety: Full TypeScript support for all operations

  • Error Handling: Graceful degradation and informative error messages

  • Caching: Smart caching to reduce API calls and improve performance

๐Ÿ› Troubleshooting

Common Issues

"MCP server not found"

  • Verify the absolute path in your Cursor configuration

  • Ensure the project is built (pnpm run build)

  • Check that Node.js is in your system PATH

"Rate limit exceeded"

  • Add a GitHub token to your environment variables

  • The server will automatically use the token for authenticated requests

"Component not found"

  • Check component name spelling (use list_components first)

  • Some components may have different names than expected

"Cursor not recognizing MCP server"

  • Restart Cursor completely (quit and reopen)

  • Verify JSON syntax in your Cursor configuration

  • Check the MCP server logs for errors

Debug Mode

Enable detailed logging:

DEBUG=true node dist/index.js

Or set in your Cursor configuration:

{
  "mcpServers": {
    "shadcn": {
      "command": "node",
      "args": ["/path/to/dist/index.js"],
      "env": {
        "DEBUG": "true"
      }
    }
  }
}

๐Ÿค Contributing

  1. Fork the repository

  2. Create a feature branch (git checkout -b feature/amazing-feature)

  3. Make your changes

  4. Add tests (pnpm test)

  5. Run the full test suite (pnpm run test:mcp)

  6. Commit your changes (git commit -m 'Add amazing feature')

  7. Push to the branch (git push origin feature/amazing-feature)

  8. Open a Pull Request


Made with โค๏ธ for the shadcn/ui and AI development community

If this project helps you build better UIs faster, consider giving it a โญ!

Available Tools

4 tools
get_blockB

Get a complete shadcn/ui block implementation

ParametersJSON Schema
NameRequiredDescriptionDefault
blockNameYesName of the block (e.g., "dashboard-01", "login-form")

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations present, so description must carry behavioral burden. It only says 'complete implementation' without specifying side effects, auth needs, or what 'complete' entails (e.g., fetching all files).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence with no unnecessary words. Front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple retrieval tool with one parameter and no output schema, the description is adequate but could benefit from mentioning return format or that it retrieves all files/code.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with clear parameter description and examples. Description adds no extra meaning beyond what schema provides, so baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states verb ('Get') and resource ('complete shadcn/ui block implementation'), distinguishing it from siblings like get_component which targets components.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool over get_component or list_blocks. No when-not-to-use or alternative suggestions provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_componentB

Get the source code and metadata for a specific shadcn/ui component

ParametersJSON Schema
NameRequiredDescriptionDefault
componentNameYesName of the component (e.g., "button", "card", "input")

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and the description does not disclose behavioral traits such as whether this is a read-only operation, authentication requirements, or any side effects. It only mentions the basic purpose without adding behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, straightforward sentence with no redundant words. It efficiently conveys the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter, no output schema), the description is adequate but lacks details on return format or any usage constraints. It is minimally complete but leaves room for improvement in providing more context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a clear parameter description for 'componentName'. However, the tool description does not add any additional semantic meaning beyond what the schema already provides, resulting in minimal added value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get'), the resource ('source code and metadata'), and the specific context ('shadcn/ui component'). It distinguishes from sibling tools like 'get_block' which targets a different resource.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'list_components' or 'get_block'. The description only states what it does, without specifying use cases or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_blocksA

List all available shadcn/ui blocks

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Minimal but adequate: 'list' implies a read-only, safe operation. Lacks details on pagination or return format, but for a no-parameter tool this is acceptable.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no fluff. Front-loaded verb and resource. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters or output schema, the description sufficiently explains the tool's purpose. Lacks mention of return type but siblings imply block objects.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters exist; baseline score per rule (0 params = baseline 4). No need to add parameter info.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description uses specific verb 'List' and resource 'all available shadcn/ui blocks', clearly distinguishing from sibling tools like get_block (single block) and list_components (components).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use vs alternatives, but the simple description implies usage for retrieving all blocks. Missing when-not or alternative recommendations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_componentsC

List all available shadcn/ui components

ParametersJSON Schema
NameRequiredDescriptionDefault
categoryNoOptional category filter

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description only states the basic action. It does not disclose pagination, output format, or any side effects. A read operation is implied but not explicitly confirmed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that gets straight to the point. It could be slightly improved by mentioning the optional filter, but it is efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has one optional parameter and no output schema. The description covers the main purpose but does not explain what the returned list contains or any limitations. It is minimally adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% for the single parameter 'category', which has a clear description 'Optional category filter'. The tool description adds no additional meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly specifies listing all available shadcn/ui components, distinguishing it from siblings like get_component (single component) and list_blocks (blocks). However, it does not mention the optional category filter, creating a slight inconsistency with 'all'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. The description does not indicate that category filtering is available or when to use get_component or list_blocks instead.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 4 tool updatesv1.1.2
    • First observedget_block
    • First observedget_component
    • First observedlist_blocks
    • First observedlist_components

TDQS

A3.7/5.0
Disambiguation5/5

Each tool has a unique purpose: listing vs getting, and blocks vs components. No overlap, clear boundaries.

Naming Consistency5/5

All tools follow a consistent verb_noun pattern (get/list + block/component) with underscores, no style mixing.

Tool Count5/5

4 tools are well-scoped for a reference server on shadcn/ui components and blocks, neither too few nor too many.

Completeness5/5

The set covers both listing and retrieving individual items for both blocks and components, meeting typical informational needs without obvious gaps.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/magnusrodseth/shadcn-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server