A starter template for building Model Context Protocol (MCP) servers, designed for UI libraries and component registries.
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.
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
This template is specifically designed for libraries following the registry
format (like shadcn/ui
), making it ideal for:
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.
git clone https://github.com/mnove/mcp-starter.git
cd mcp-starter
pnpm install
pnpm run build
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.
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
};
Modify src/server.ts
to customize your server information:
const server = new McpServer({
name: "your-mcp-server-name",
version: "1.0.0",
});
pnpm run dev
pnpm run build
pnpm run inspect
This opens the MCP Inspector to test your server tools interactively.
The MCP server provides the following tools:
getUIComponents
Returns a comprehensive list of all UI components from your registry.
Dynamic tools are created for each category defined in componentCategories
:
getButtons
- Get all button componentsgetForms
- Get all form componentsEach category tool provides:
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
src/utils/schemas.ts
:export const CustomComponentSchema = z.object({
name: z.string(),
category: z.string(),
// Add your fields
});
src/utils/api.ts
:export async function fetchCustomComponents() {
// Your implementation
}
src/server.ts
:server.tool("getCustomComponents" /*...*/);
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.
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.
Your component registry should follow this structure:
registry.json
){
"registry": [
{
"name": "button-primary",
"type": "registry:component",
"description": "Primary button component"
}
]
}
/r/{component-name}.json
){
"name": "button-primary",
"type": "registry:component",
"files": [
{
"content": "// Component implementation"
}
]
}
pnpm run build
{
"mcpServers": {
"your-mcp-server": {
"command": "node",
"args": ["/path/to/mcp-starter/dist/server.js"]
}
}
}
You can also publish this template as an NPM package for easy installation in other projects.
package.json
with your detailspnpm run build
npm publish
See CONTRIBUTING.md for details on how to contribute to this project.
This project is licensed under the MIT License - see the LICENSE file for details.
Marcello - @mnove
ā ļø Important: Remember to replace https://ui.stackzero.co
with your actual project URL before using this template in production!
Integrates the Nmap network scanning tool with MCP, enabling network scanning capabilities within MCP-compatible environments.
A GraphQL server that supports the Model Context Protocol (MCP), enabling Large Language Models (LLMs) to interact with GraphQL APIs through schema introspection and query execution.
A test server that demonstrates all features of the MCP protocol, including prompts, tools, resources, and sampling.
A template for deploying a remote, auth-less MCP server on Cloudflare Workers.
Tracks newly created Uniswap liquidity pools across nine blockchain networks, providing real-time data for DeFi analysts, traders, and developers.
A gateway server that intelligently routes MCP requests to multiple backend servers based on external configuration.
Fetch comprehensive information about CRAN packages, including READMEs, metadata, and search functionality.
A server for splitting and extracting parts of OpenAPI specifications using Redocly CLI.
Provides AI-powered mentorship to LLM agents for tasks like code review, design critique, and brainstorming, using the Deepseek API.
Manages Infrastructure as Code (IaC) operations using Ansible and Terraform. Requires external tools and manual setup.