Trae AI 规则文件生成器 MCP 服务 - 智能生成项目开发规则
Project description
📋 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 中提出。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trae_rules_mcp-1.0.1.tar.gz.
File metadata
- Download URL: trae_rules_mcp-1.0.1.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d33799699d03e61f67efa6ae602d5f220df5c6372bc77595d0087f77fdab334
|
|
| MD5 |
566bba5264033d5e670e14b19df59c3d
|
|
| BLAKE2b-256 |
6f088d592684c444b801539219db3cd47d7a5e490f04bb03a858d18f0d666162
|
File details
Details for the file trae_rules_mcp-1.0.1-py3-none-any.whl.
File metadata
- Download URL: trae_rules_mcp-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa097da5efc57325bf1cdf67aeffe0d9e07edb4124591856cf26e2850dedfd5a
|
|
| MD5 |
b36c7befe6d89f8acc5fe0b2502139ef
|
|
| BLAKE2b-256 |
659a39c2d2dda824ccedaee397449bdab9e0db969fa79e87e3d139ea5fe4eb88
|