Skip to main content
Glama

MCP Server Starter Template

A comprehensive starter template for building Model Context Protocol (MCP) servers, specifically designed for UI libraries and component registries. This template provides a robust foundation for creating MCP servers that can fetch, categorize, and provide component information to AI assistants like Claude.

šŸŒŽ Real world example?

Check out the stackzero-labs/mcp which uses this template to expose its UI components and blocks to AI models. You can also checkout the UI referenced project stackzero/ui

Related MCP server: ui-registry-mcp

šŸš€ Features

  • Ready-to-use MCP server with TypeScript support

  • Component registry integration for UI libraries

  • Categorized component organization with flexible category system

  • Zod schema validation for type safety

  • Development tools including hot reload and inspector

  • Example implementation using a real project URL for demonstration

  • Extensible architecture for custom component types and categories

šŸ“‹ Prerequisites

  • Node.js 18 or higher

  • pnpm (recommended) or npm

  • Basic understanding of TypeScript and MCP

šŸ¤ Intended Use Cases

This template is specifically designed for libraries following the registry format (like shadcn/ui), making it ideal for:

  • UI component libraries

  • Design systems

  • Component registries that need to be accessible via AI assistants

  • Tools, utilities, and frameworks that require a structured way to expose UI components to AI models

Read more about components registries like shadcn/ui here Component Registries.

With some customizations however, it can be adapted for other types of MCP servers as well.

šŸ› ļø Installation

  1. Clone or download this template:

git clone https://github.com/mnove/mcp-starter.git
cd mcp-starter
  1. Install dependencies:

pnpm install
  1. Build the project:

pnpm run build

āš™ļø Configuration

1. Update Project Configuration

Edit src/lib/config.ts to point to your own component registry:

export const mcpConfig = {
  projectName: "your-project-name",
  // Replace with your actual project URL
  baseUrl: "https://your-ui-library.com",
  registryUrl: "https://your-ui-library.com/r",
  registryFileUrl: "https://your-ui-library.com/registry.json",
};

Note: This template currently uses https://ui.stackzero.co as a demonstration URL. You must replace this with your actual project URL for production use.

2. Define Component Categories

Customize src/lib/categories.ts to match your component structure:

export const componentCategories = {
  Buttons: ["button-primary", "button-secondary", "button-ghost"],
  Forms: ["input-text", "input-email", "textarea"],
  // Add your categories here
};

3. Update Server Metadata

Modify src/server.ts to customize your server information:

const server = new McpServer({
  name: "your-mcp-server-name",
  version: "1.0.0",
});

šŸƒā€ā™‚ļø Development

Start Development Server

pnpm run dev

Build for Production

pnpm run build

Inspect MCP Server

pnpm run inspect

This opens the MCP Inspector to test your server tools interactively. Make sure you auth token is present in the inspector url, otherwise the connection will fail.

šŸ“š Available Tools

The MCP server provides the following tools:

getUIComponents

Returns a comprehensive list of all UI components from your registry.

Category-specific Tools

Dynamic tools are created for each category defined in componentCategories:

  • getButtons - Get all button components

  • getForms - Get all form components

  • etc.

Each category tool provides:

  • Component implementation details

  • Usage examples

  • Installation instructions

  • Related components

šŸ—ļø Project Structure

mcp-starter/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ server.ts              # Main MCP server implementation
│   ā”œā”€ā”€ lib/
│   │   ā”œā”€ā”€ config.ts          # Configuration settings
│   │   └── categories.ts      # Component categories
│   └── utils/
│       ā”œā”€ā”€ api.ts             # API fetching utilities
│       ā”œā”€ā”€ formatters.ts      # Data formatting helpers
│       ā”œā”€ā”€ schemas.ts         # Zod validation schemas
│       └── index.ts           # Utility exports
ā”œā”€ā”€ dist/                      # Built files
ā”œā”€ā”€ package.json
└── README.md

šŸ”§ Customization

Adding New Component Types

  1. Update schemas in src/utils/schemas.ts:

export const CustomComponentSchema = z.object({
  name: z.string(),
  category: z.string(),
  // Add your fields
});
  1. Add API functions in src/utils/api.ts:

export async function fetchCustomComponents() {
  // Your implementation
}
  1. Register new tools in src/server.ts:

server.tool("getCustomComponents" /*...*/);

Extending Categories

Simply add new categories to src/lib/categories.ts:

export const componentCategories = {
  // Existing categories...
  Navigation: ["navbar", "sidebar", "breadcrumbs"],
  DataDisplay: ["table", "card", "badge"],
};

The server will automatically create tools for new categories.

Why categories?

Categories help organize components logically, making it easier for AI assistants to find and suggest relevant components based. Also, some models and IDE have a limit on the number of tools they can handle, so categorizing helps to keep the number of tools manageable.

You can customize your categories however you want, depending on your cases. If you do not have many tools, then you could also consider not using categories at all.

šŸ“– Registry Format

Your component registry should follow this structure:

Registry File (registry.json)

{
  "registry": [
    {
      "name": "button-primary",
      "type": "registry:component",
      "description": "Primary button component"
    }
  ]
}

Component Details (/r/{component-name}.json)

{
  "name": "button-primary",
  "type": "registry:component",
  "files": [
    {
      "content": "// Component implementation"
    }
  ]
}

šŸš€ Deployment

As a Local MCP Server

  1. Build the project:

pnpm run build
  1. Configure in your MCP client (e.g., Claude Desktop):

{
  "mcpServers": {
    "your-mcp-server": {
      "command": "node",
      "args": ["/path/to/mcp-starter/dist/server.js"]
    }
  }
}

As an NPM Package

You can also publish this template as an NPM package for easy installation in other projects.

  1. Update package.json with your details

  2. Build and publish:

pnpm run build
npm publish

šŸ¤ Contributing

See CONTRIBUTING.md for details on how to contribute to this project.

šŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

šŸ¤ Contact

Marcello - @mnove

šŸ™ Acknowledgments

  • Built with Model Context Protocol SDK

  • Originally inspired by magic-ui MCP server

  • Inspired by the need for better AI-component integration

  • Thanks to the MCP community for their contributions


āš ļø Important: Remember to replace https://ui.stackzero.co with your actual project URL before using this template in production!

Available Tools

3 tools
getAnotherSampleCateogoryC

Provides implementation details for another-component-basic, another-component-advanced components.

Inputs: no named parameters.

getRatingsC

Provides implementation details for star-rating-basic, star-rating-fractions, upvote-rating-basic, upvote-rating-animated, face-rating-basic, face-rating-gradient components.

Inputs: no named parameters.

getUIComponentsB

Provides a comprehensive list of all ui components.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.6/5.0

    Scored across 3 tools

    Disambiguation3/5

    getUIComponents is clearly a catalog/lookup tool, but getRatings and getAnotherSampleCateogory both do the same thing (return implementation details for a hardcoded component subset), so a caller must guess which bucket a component falls into. The name 'getAnotherSampleCateogory' gives no signal about what it actually covers, making selection partly arbitrary.

    Naming Consistency3/5

    All three use camelCase with a get_ prefix, so the surface is superficially consistent. However, 'getAnotherSampleCateogory' contains a typo and a meaningless placeholder-like noun, breaking the predictable verb+resource semantics the other two follow.

    Tool Count3/5

    Three tools is thin for a UI component library, and two of them are narrow hardcoded category fetchers rather than a general lookup. The count reflects a piecemeal surface rather than a deliberate scope.

    Completeness2/5

    There is no generic tool to fetch implementation details for an arbitrary component listed by getUIComponents, so the surface dead-ends for everything except ratings and the unnamed 'another sample category'. Listing without a matching detail lookup leaves a major gap for agent workflows.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables AI assistants to discover, search, and retrieve Ruixen UI components from the live registry, providing installation commands for MCP-compatible clients.
      3
      60 npm
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides coding agents live access to shadcn-style component registries, enabling them to search, compare, and fetch real component source code for UI composition.
      5
      78 npm
      7
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to search across 340+ React UI registries, inspect component code and quality scores, compare options, detect a project's stack, and generate or execute safe transactional install plans. It provides read and write safeguards with dry-run planning and rollback.
      MIT