MCP Server Starter Template
A comprehensive template for building MCP servers that expose UI component registries and design systems to AI assistants. It enables users to browse, fetch, and retrieve implementation details from registries following the shadcn/ui format.
README
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
🚀 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
- Clone or download this template:
git clone https://github.com/mnove/mcp-starter.git
cd mcp-starter
- Install dependencies:
pnpm install
- 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.
📚 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 componentsgetForms- 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
- Update schemas in
src/utils/schemas.ts:
export const CustomComponentSchema = z.object({
name: z.string(),
category: z.string(),
// Add your fields
});
- Add API functions in
src/utils/api.ts:
export async function fetchCustomComponents() {
// Your implementation
}
- 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.
📖 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
- Build the project:
pnpm run build
- 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.
- Update
package.jsonwith your details - 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
- 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!
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。