这是一个提供访问OriginUI组件的模型上下文协议(MCP)服务器,使Claude Code代理能够无缝地搜索、浏览和安装OriginUI组件。
pnpm dlx shadcn@latest add 命令TL;DR:在你的 ~/.claude-code/mcp.json 文件中添加以下内容:
{
"mcpServers": {
"origin-ui": {
"command": "npx",
"args": ["--yes", "github:kelvinchng/origin-ui-mcp"],
"env": {}
}
}
}
重启Claude Code并询问:"有哪些可用的OriginUI按钮组件?"
无需安装!你可以直接从GitHub仓库使用npx来使用MCP服务器。
git clone https://github.com/kelvinchng/origin-ui-mcp.git
cd origin-ui-mcp
npm install
npm run build
npm install -g origin-ui-mcp
创建或编辑位于 ~/.claude-code/mcp.json 的Claude Code MCP配置文件:
{
"mcpServers": {
"origin-ui": {
"command": "npx",
"args": ["--yes", "github:kelvinchng/origin-ui-mcp"],
"env": {}
}
}
}
{
"mcpServers": {
"origin-ui": {
"command": "node",
"args": ["/绝对路径/to/origin-ui-mcp/dist/index.js"],
"env": {}
}
}
}
注意:使用方案A(npx),不需要手动安装或路径配置!
添加MCP配置后,重启Claude Code以加载OriginUI MCP服务器。
你可以通过询问Claude Code来验证集成是否正常工作:
"有哪些可用的OriginUI按钮组件?"
Claude Code现在应该能够搜索、描述并提供安装命令给OriginUI组件。
一旦与Claude Code集成,你可以提出如下问题:
Claude Code将使用MCP服务器提供准确的信息和安装命令。
关键特性之一是能够获得组件的视觉预览,帮助LLMs做出更好的推荐:
"展示支付组件的样子"
"获取按钮组件的截图"
"我想看看导航组件的视觉风格"
MCP服务器将提供:
search_components按名称、类别或标签搜索OriginUI组件。
参数:
query(字符串,必需):搜索查询category(字符串,可选):按类别筛选limit(数字,可选):最大结果数(默认:10)示例:
search_components({
query: "支付",
category: "表单",
limit: 5
})
get_component_details获取特定组件的详细信息。
参数:
componentId(字符串,必需):组件ID(例如:"comp-163")示例:
get_component_details({
componentId: "comp-163"
})
list_components列出所有可用组件及其基本信息。
参数:
category(字符串,可选):按类别筛选limit(数字,可选):最大结果数(默认:50)get_install_command获取特定组件的安装命令。
参数:
componentId(字符串,必需):组件ID返回:
pnpm dlx shadcn@latest add https://originui.com/r/comp-163.json
get_component_preview获取带有样式信息和使用示例的组件预览。
参数:
componentId(字符串,必需):组件IDget_component_screenshot获取组件的视觉预览,以帮助评估其是否适合你的项目。
参数:
componentId(字符串,必需):组件IDtheme(字符串,可选):主题偏好("浅色","深色","两者")返回:
button - 按钮组件input - 输入和表单控件select - 选择和下拉组件navbar - 导航组件card - 卡片和容器组件form - 表单相关组件layout - 布局组件navigation - 导航元素feedback - 反馈和状态组件data-display - 数据展示组件overlay - 模态和覆盖层组件typography - 文本和排版组件media - 媒体组件// 搜索按钮组件
const buttons = await search_components({
query: "按钮",
category: "按钮",
limit: 10
});
// 获取特定组件的详细信息
const details = await get_component_details({
componentId: "comp-163"
});
// 获取安装命令
const installCmd = await get_install_command({
componentId: "comp-163"
});
// 获取视觉预览以评估适用性
const screenshot = await get_component_screenshot({
componentId: "comp-163",
theme: "两者"
});
// 安装组件
// pnpm dlx shadcn@latest add https://originui.com/r/comp-163.json
# 安装依赖
npm install
# 构建项目
npm run build
# 在开发模式下运行
npm run dev
# 启动MCP服务器
npm start
pnpm dlx shadcn@latest add 命令和正确的URLMIT许可证 - 查看LICENSE文件了解详情。