Enables reading and managing Git repositories, supporting features like reading project structures and managing code files.
Provides interaction with GitHub repositories, allowing for project management and code operations within GitHub projects.
Handles reading and generating rule files in Markdown format, supporting content parsing and creation for project documentation.
Enables installation and management of the MCP package through PyPI, supporting package distribution and updates.
Provides Python-based functionality for rule generation and management, supporting Python environments and modules.
📋 Trae Rules Generator MCP
一个用于自动生成和管理 Trae AI 项目规则文件的 MCP (Model Context Protocol) 服务。
✨ 功能特性
- 🔍 读取现有规则: 扫描和分析现有的规则文件结构
- 🎯 智能生成规则: 根据项目类型和功能特性生成定制化规则
- 💾 规则文件管理: 保存、更新和备份规则文件
- 🌐 多语言支持: 支持中文和英文规则生成
- 🔧 灵活配置: 支持自定义规则路径和文件名
🚀 快速开始
方式一:使用已发布的包 (推荐)
1. 安装包
2. 在 Trae AI 中配置 MCP
在 Trae AI 的 MCP 配置中添加以下配置:
方式二:从源码运行
1. 环境要求
- Python 3.8+
- pip 或 uv 包管理器
2. 克隆项目
3. 安装依赖
4. 在 Trae AI 中配置 MCP
💡 注意: 请将
/path/to/trae-rules-mcp
替换为实际的项目路径。
5. 重启 Trae AI
配置完成后,重启 Trae AI 以加载新的 MCP 服务器。
🛠️ MCP 工具
1. read_existing_rules
读取现有的规则文件内容和结构信息。
参数:
rules_path
(str, 可选): 规则文件目录路径,默认为.trae/rules
返回:
- 规则文件的详细信息,包括文件列表、内容预览等
2. generate_project_rules
根据项目类型和功能特性生成新的项目规则文件。
参数:
project_type
(str): 项目类型 (如: web, mobile, ai, backend, frontend)features
(List[str]): 项目功能特性列表 (如: ["authentication", "database", "api"])language
(str, 可选): 规则文件语言,默认为中文
返回:
- 生成的规则文件内容 (Markdown 格式)
3. save_rules_file
保存规则文件到指定目录。
参数:
content
(str): 规则文件内容filename
(str, 可选): 文件名,默认为project_rules.md
rules_path
(str, 可选): 规则文件目录路径,默认为.trae/rules
返回:
- 保存操作的结果信息
4. update_existing_rules
更新现有的规则文件内容。
参数:
file_path
(str): 要更新的规则文件路径updates
(Dict[str, Any]): 更新内容的字典
返回:
- 更新操作的结果信息
📖 使用示例
示例 1: 生成 Web 项目规则
示例 2: 读取现有规则
示例 3: 保存生成的规则
生成的规则文件示例
📁 项目结构
🔧 配置说明
默认规则路径
服务默认在 .trae/rules
目录下查找和保存规则文件。你可以通过工具参数自定义路径。
支持的项目类型
web
/frontend
: 前端 Web 项目backend
/api
: 后端 API 项目ai
: AI/机器学习项目mobile
: 移动应用项目- 其他自定义类型
支持的功能特性
authentication
: 用户认证database
: 数据库操作api
: API 接口ui
: 用户界面testing
: 测试相关deployment
: 部署配置security
: 安全相关performance
: 性能优化- 其他自定义特性
🔧 故障排除
常见问题
1. "找不到命令: python" 错误
问题: 在 MCP 配置中遇到 "spawn python ENOENT" 错误。
解决方案:
- 使用完整的 Python 路径:
"command": "/usr/bin/python3"
- 或者确保 Python 在系统 PATH 中:
"command": "python3"
2. 模块导入失败
问题: "No module named 'trae_rules_mcp'" 错误。
解决方案:
3. MCP 服务器无法启动
问题: Trae AI 无法连接到 MCP 服务器。
解决方案:
- 检查配置文件格式是否正确
- 确认路径设置正确
- 重启 Trae AI
- 查看 Trae AI 的错误日志
4. 权限问题
问题: 无法创建或写入规则文件。
解决方案:
调试技巧
- 测试 MCP 连接:
- 检查包安装:
- 验证配置:
- 确保 JSON 格式正确
- 检查路径是否存在
- 验证环境变量设置
🤝 贡献指南
- Fork 本仓库
- 创建功能分支 (
git checkout -b feature/AmazingFeature
) - 提交更改 (
git commit -m 'Add some AmazingFeature'
) - 推送到分支 (
git push origin feature/AmazingFeature
) - 打开 Pull Request
📄 许可证
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。
🆘 支持
获取帮助
- 📖 文档: 查看本 README 和项目 Wiki
- 🐛 问题报告: GitHub Issues
- 💡 功能建议: GitHub Discussions
- 📦 PyPI 包: trae-rules-mcp
版本信息
- 当前版本: 1.0.1
- Python 支持: 3.8+
- MCP 协议: 兼容最新版本
更新日志
查看 CHANGELOG.md 了解详细的版本更新信息。
🎉 感谢使用 Trae Rules Generator MCP!
如果这个项目对你有帮助,请考虑给我们一个 ⭐ Star!
This server cannot be installed
An MCP service that automatically generates and manages rule files for Trae AI projects, allowing users to create, read, update, and customize project rules based on project type and features.
Related MCP Servers
- -securityAlicense-qualityAn MCP server that implements Claude Code-like functionality, allowing the AI to analyze codebases, modify files, execute commands, and manage projects through direct file system interactions.Last updated -224PythonMIT License
- -securityFlicense-qualityA custom MCP protocol service that enhances AI models by providing multilingual translation capabilities and resource management, allowing for automatic text extraction and translation through external APIs.Last updated -TypeScript
- AsecurityAlicenseAqualityAn MCP service that provides AI-powered development workflow tools including specification generation, code review, and project management with support for both OpenAI and Ollama models.Last updated -8TypeScriptMIT License
- -securityFlicense-qualityAn AI-powered MCP server that provides development tools for code analysis, documentation, and project management including code pattern extraction, humorous code reviews, TODO scanning, and PRD generation.Last updated -1JavaScript