📋 Trae Rules Generator MCP
一个用于自动生成和管理 Trae AI 项目规则文件的 MCP (Model Context Protocol) 服务。
✨ 功能特性
- 🔍 读取现有规则: 扫描和分析现有的规则文件结构
- 🎯 智能生成规则: 根据项目类型和功能特性生成定制化规则
- 💾 规则文件管理: 保存、更新和备份规则文件
- 🌐 多语言支持: 支持中文和英文规则生成
- 🔧 灵活配置: 支持自定义规则路径和文件名
🚀 快速开始
环境要求
- Python 3.8+
- pip 或 uv 包管理器
安装依赖
# 使用 uv (推荐)
uv sync
# 或使用 pip
pip install -e .
启动服务
# 方式一:直接运行 Python 脚本
python main.py
# 方式二:使用 uvicorn
uvicorn main:app --host 0.0.0.0 --port 8080 --reload
🛠️ 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.mdrules_path(str, 可选): 规则文件目录路径,默认为.trae/rules
返回:
- 保存操作的结果信息
4. update_existing_rules
更新现有的规则文件内容。
参数:
file_path(str): 要更新的规则文件路径updates(Dict[str, Any]): 更新内容的字典
返回:
- 更新操作的结果信息
📁 项目结构
trae-rules-mcp/
├── main.py # MCP 服务主文件
├── pyproject.toml # 项目配置文件
├── README.md # 项目说明文档
└── .gitignore # Git 忽略文件
🔧 配置说明
默认规则路径
服务默认在 .trae/rules 目录下查找和保存规则文件。你可以通过工具参数自定义路径。
支持的项目类型
web/frontend: 前端 Web 项目backend/api: 后端 API 项目ai: AI/机器学习项目mobile: 移动应用项目- 其他自定义类型
支持的功能特性
authentication: 用户认证database: 数据库操作api: API 接口- 其他自定义特性
🤝 贡献指南
- Fork 本仓库
- 创建功能分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 打开 Pull Request
📄 许可证
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。
🆘 支持
如果你遇到任何问题或有功能建议,请在 Issues 中提出。
Metadata
Release files for trae-rules-mcp 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trae_rules_mcp-1.0.1.tar.gz | 16.8 kB | Without provenance | Details for trae_rules_mcp-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trae_rules_mcp-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for trae_rules_mcp-1.0.1-py3-none-any.whl |
Total release size: 24.0 kB
Release files / trae_rules_mcp-1.0.1.tar.gz
| Download URL | trae_rules_mcp-1.0.1.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d33799699d03e61f67efa6ae602d5f220df5c6372bc77595d0087f77fdab334
|
|
BLAKE2b-256 checksum How to use checksums |
6f088d592684c444b801539219db3cd47d7a5e490f04bb03a858d18f0d666162
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / trae_rules_mcp-1.0.1-py3-none-any.whl
| Download URL | trae_rules_mcp-1.0.1-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa097da5efc57325bf1cdf67aeffe0d9e07edb4124591856cf26e2850dedfd5a
|
|
BLAKE2b-256 checksum How to use checksums |
659a39c2d2dda824ccedaee397449bdab9e0db969fa79e87e3d139ea5fe4eb88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Security for trae-rules-mcp 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.