templui-mcp-server

templui-mcp-server

Enables AI assistants to access TemplUI components for building Go applications with the templ templating language.

Category
访问服务器

README

TemplUI MCP Server

npm version License: MIT

🚀 The fastest way to integrate TemplUI components into your AI workflow

A Model Context Protocol (MCP) server that provides AI assistants with comprehensive access to TemplUI components. Get component source code, documentation, examples, and metadata for building Go applications with the templ templating language.

✨ Key Features

  • 🎯 Go Templ Support - Native support for Go's templ templating language
  • 📦 Component Source Code - Latest TemplUI component implementations
  • 🎨 Component Demos - Example implementations and usage patterns
  • 📋 Documentation Access - Complete component documentation from templui.io
  • 🔧 JavaScript Integration - Client-side functionality for interactive components
  • 📊 Metadata Extraction - Component properties, variants, and configuration details
  • ⚡ Smart Caching - Efficient GitHub API integration with rate limit handling

🚀 Quick Start

# Basic usage (60 requests/hour)
npx templui-mcp-server

# With GitHub token (5000 requests/hour) - Recommended
npx templui-mcp-server --github-api-key ghp_your_token_here

# Use cached documentation
npx templui-mcp-server --use-cached-docs

🎯 Get your GitHub token in 2 minutes: GitHub Personal Access Tokens

📚 Available Tools

Tool Description
get_component Get the source code (.templ file) for a specific component
get_component_demo Get demo/example code showing component usage
get_component_docs Get complete documentation for a component
get_component_javascript Get JavaScript code for interactive components
get_component_metadata Get detailed metadata including props and features
list_components List all available components, optionally by category

🎨 Supported Components

TemplUI provides 42 components across multiple categories:

Form Components

  • Button, Input, Textarea, Checkbox, Radio, Select Box
  • Date Picker, Time Picker, Input OTP, Tags Input
  • Form, Label, Switch, Rating, Slider

Layout Components

  • Card, Separator, Aspect Ratio, Accordion, Table
  • Collapsible, Sheet, Sidebar

Navigation Components

  • Breadcrumb, Pagination, Tabs

Overlay Components

  • Dialog, Dropdown, Popover, Tooltip

Feedback Components

  • Alert, Toast, Progress, Skeleton, Copy Button

Display Components

  • Avatar, Badge, Icon, Code, Chart, Carousel

🛠️ Installation & Setup

1. Install the Package

# Global installation (optional)
npm install -g templui-mcp-server

# Or use npx (recommended)
npx templui-mcp-server --help

2. Get GitHub Token (Recommended)

# Visit: https://github.com/settings/tokens
# Generate token with no scopes needed for public repositories
export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_your_token_here

3. Test the Server

# Run server
templui-mcp-server --github-api-key ghp_your_token_here

# Server will start and wait for MCP client connections

🔌 Integration with AI Tools

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "templui": {
      "command": "npx",
      "args": ["templui-mcp-server"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

VS Code with Continue.dev

Add to your Continue configuration:

{
  "mcpServers": [
    {
      "name": "templui",
      "command": "npx",
      "args": ["templui-mcp-server", "--github-api-key", "ghp_your_token_here"]
    }
  ]
}

Cursor

Configure in Cursor's MCP settings:

{
  "templui": {
    "command": "templui-mcp-server",
    "args": ["--github-api-key", "ghp_your_token_here"]
  }
}

📖 Usage Examples

Get Component Source Code

// AI Assistant can request:
use_tool("get_component", { "componentName": "button" })

// Returns Go templ source code with helpful comments

Get Component Documentation

// AI Assistant can request:
use_tool("get_component_docs", { "componentName": "dialog" })

// Returns formatted documentation with installation and examples

List Components by Category

// AI Assistant can request:
use_tool("list_components", { "category": "form" })

// Returns all form-related components

Get Component Examples

// AI Assistant can request:
use_tool("get_component_demo", { "componentName": "carousel" })

// Returns example implementations from the showcase

⚙️ Configuration

Command Line Options

templui-mcp-server [options]

Options:
  --github-api-key <token>    GitHub personal access token
  --use-cached-docs          Use cached documentation  
  --log-level <level>        Set log level (error, warn, info, debug)
  --help                     Show help message

Environment Variables

GITHUB_PERSONAL_ACCESS_TOKEN  # GitHub token for API access
TEMPLUI_DOCS_PATH            # Path to documentation files
TEMPLUI_CACHE_DIR            # Cache directory location
LOG_LEVEL                    # Logging level

🎯 Use Cases

  • 🤖 AI-Powered Development - Let AI assistants build UIs with TemplUI components
  • 📚 Component Discovery - Explore available components and their usage patterns
  • 🚀 Rapid Prototyping - Get complete component implementations quickly
  • 📝 Code Generation - Generate Go templ code with proper imports and structure
  • 🎓 Learning Go Templ - Understand component patterns and best practices

📁 Project Structure

templui-mcp-server/
├── src/
│   ├── index.ts              # CLI entry point
│   ├── server/               # MCP server implementation
│   ├── tools/                # Tool implementations
│   ├── utils/                # Utilities (GitHub, docs, cache)
│   ├── data/                 # Component metadata
│   └── cli/                  # Command line interface
├── samples/                  # Sample data (documentation)
├── package.json
└── README.md

🔧 Development

Building from Source

# Clone repository
git clone https://github.com/tggo/templui-mcp-server.git
cd templui-mcp-server

# Install dependencies
npm install

# Build TypeScript
npm run build

# Run development version
npm run dev

Updating Components

To sync with the latest TemplUI components:

# Automated update (recommended)
npm run update:components

# Dry run to see changes
npm run update:components:dry-run

# Update without publishing to npm
npm run update:components:no-publish

The update script will:

  • Discover new components from TemplUI repository
  • Update static component list
  • Bump version number
  • Update documentation
  • Commit, tag, and push to GitHub
  • Publish to npm (if logged in)

Adding Documentation

Place TemplUI documentation files in samples/templui-site-doc/:

samples/templui-site-doc/
├── templui.io_docs_components_button.md
├── templui.io_docs_components_dialog.md
└── ...

🐛 Troubleshooting

Common Issues

  1. Rate Limit Exceeded

    Error: API rate limit exceeded
    Solution: Provide GitHub token with --github-api-key
    
  2. Documentation Not Found

    Error: Documentation directory not found
    Solution: Ensure samples/templui-site-doc exists with markdown files
    
  3. Component Not Found

    Error: Component "xyz" not found
    Solution: Use list_components to see available components
    

Debug Mode

# Enable debug logging
templui-mcp-server --log-level debug --github-api-key ghp_your_token

📄 API Reference

Tool Schemas

All tools follow consistent parameter patterns:

interface ComponentRequest {
  componentName: string;  // Required for most tools
}

interface ListRequest {
  category?: string;      // Optional category filter
}

Response Format

Tools return content in MCP-standard format:

{
  content: [
    {
      type: "text",
      text: "Component source code or documentation"
    }
  ]
}

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📄 License

MIT License - see LICENSE for details.

🙏 Acknowledgments

  • TemplUI Team - For the amazing Go templ component library
  • Go Templ - For the excellent templating language
  • Anthropic - For the Model Context Protocol specification

Made with ❤️ for the Go and TemplUI community

Star ⭐ this repo if you find it helpful!

🔗 Links

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选