MCP Yeoman服务
一个模型上下文协议(MCP)服务器,它提供与 Yeoman 生成器的集成,允许人工智能代理以编程方式搜索和运行 Yeoman 模板。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"yeoman": {
"args": [
"@thirdstrandstudio/mcp-yeoman"
],
"command": "npx"
}
}
}
该服务需要配置环境变量:GENERATOR_DIR
服务介绍
MCP Yeoman 服务器
这是一个 Model Context Protocol (MCP) 服务器,它提供了与 Yeoman 生成器的集成,允许 AI 代理以编程方式搜索和运行 Yeoman 模板。
工具
此服务器实现了以下 MCP 工具:
模板搜索方法
yeoman_search_templates- 在 npm 上搜索 Yeoman 模板- 参数:
query(字符串): 用逗号分隔的搜索关键词pageSize(数字, 可选): 返回的结果数量 (默认: 20)
- 参数:
生成器方法
-
yeoman_get_generator_options- 获取 Yeoman 生成器所需的选项和参数- 参数:
generatorName(字符串): 生成器名称(不带 'generator-' 前缀)
- 参数:
-
yeoman_generate- 运行一个 Yeoman 生成器- 参数:
generatorName(字符串): 生成器名称(不带 'generator-' 前缀)cwd(字符串): 生成器应运行的工作目录appName(字符串): 要创建的应用程序名称version(字符串): 要创建的应用程序版本options(对象, 可选): 传递给生成器的选项args(数组, 可选): 传递给生成器的额外位置参数
- 参数:
安装
通过 Smithery 安装
要通过 Smithery 自动为 Claude Desktop 安装 mcp-yeoman:
npx @smithery/cli@latest install mcp-yeoman --client claude
先决条件
- Node.js (v16 或更高版本)
- npm 或 yarn
安装包
# Clone the repository
git clone https://github.com/thirdstrandstudio/mcp-yeoman.git
cd mcp-yeoman
# Install dependencies
npm install
# Build the package
npm run build
与 Claude Desktop 一起使用
在您的 claude_desktop_config.json 中添加以下内容:
使用 npx
{
"mcpServers": {
"yeoman": {
"command": "npx",
"args": ["@thirdstrandstudio/mcp-yeoman"]
}
}
}
直接使用 Node.js
{
"mcpServers": {
"yeoman": {
"command": "node",
"args": ["/path/to/mcp-yeoman/dist/index.js"]
}
}
}
将 /path/to/mcp-yeoman 替换为您存储库的实际路径。
命令行参数
该服务器支持以下命令行参数:
--generator-dir <path>: 指定用于安装 Yeoman 生成器的持久化目录。默认情况下,生成器安装在一个临时目录中,该目录在操作完成后会被删除。使用持久化目录可以提高对相同生成器重复操作的性能。
示例:
{
"mcpServers": {
"yeoman": {
"command": "node",
"args": ["/path/to/mcp-yeoman/dist/index.js", "--generator-dir", "/path/to/generator-storage"]
}
}
}
示例
搜索模板
// Search for React-related templates
const templates = await callTool("yeoman_search_templates", {
query: "react,typescript",
pageSize: 10
});
获取生成器选项
// Get options for the React generator
const options = await callTool("yeoman_get_generator_options", {
generatorName: "react"
});
运行生成器
// Run the React generator
const result = await callTool("yeoman_generate", {
generatorName: "react",
cwd: "/path/to/project",
appName: "my-react-app",
version: "1.0.0",
options: {
typescript: true,
sass: true
}
});
开发
# Install dependencies
npm install
# Start the server in development mode
npm start
# Build the server
npm run build
错误处理
该服务器包括全面的错误处理:
- 针对无效参数的验证错误
- 交互式提示检测和对所需选项的指导
- 详细的错误日志记录,便于调试
- 临时目录的自动清理(除非使用 --generator-dir)
- 通过 MCP 协议安全地传播错误
许可证
该MCP服务器依据MIT许可证发布。这意味着您可以在遵守MIT许可证的条款和条件的前提下自由使用、修改和分发该软件。更多详情,请参见项目仓库中的LICENSE文件。
贡献
欢迎贡献!请随时提交Pull Request。在贡献时,请:
- Fork 仓库
- 创建一个功能分支
- 提交带有清晰变更描述的拉取请求
- 确保所有测试通过并保持代码风格一致