AI Coding Backend
AI Coding Backend 是一个基于 MCP (Model Context Protocol) 的后端服务,专为 AI 辅助编程而设计。它提供了一套完整的工具集,用于项目规范初始化、需求文档生成、PRP(产品需求提示)文档管理以及思维处理等功能。
🚀 特性
- MCP 集成: 完全兼容 Model Context Protocol,可与支持 MCP 的 AI 客户端无缝集成
- 项目规范管理: 自动生成和管理项目开发规范
- 需求文档生成: 提供标准化的需求文档模板和生成工具
- PRP 文档系统: 支持产品需求提示(Product Requirements Prompt)文档的创建和执行
- 思维处理工具: 结构化的思维过程管理和输出格式化
- 使用记录追踪: 自动记录工具使用情况,便于分析和优化
📦 安装
使用 uv(推荐)
uv add aicoding-backend
使用 pip
pip install aicoding-backend
🛠️ 使用方法
作为 MCP 服务器运行
# 直接运行
uv run aicoding-backend
# 或者使用 Python 模块方式
python -m aicoding_backend.main
MCP 客户端配置
在你的 MCP 客户端配置文件中添加以下配置:
{
"mcpServers": {
"aicoding-backend": {
"command": "python",
"args": ["-m", "aicoding_backend.main"]
}
}
}
🔧 可用工具
1. init_project_rules
- 描述: 初始化项目规范模板
- 参数: 无
- 返回: 项目规范模板内容
- 用途: 为新项目生成标准化的开发规范和最佳实践指南
2. init_requirements_doc
- 描述: 初始化需求描述文档模板
- 参数: 无
- 返回: 需求文档模板内容
- 用途: 生成标准化的需求文档模板,帮助团队规范需求描述
3. generate_prp
- 描述: 根据功能需求文件生成全面的产品需求提示(PRP)文档
- 参数:
feature_file(string): 功能需求文件路径
- 返回: 完整的 PRP 文档生成指导
- 用途: 将功能需求转换为结构化的 PRP 文档,指导 AI 进行精确的功能实现
4. execute_prp
- 描述: 根据 PRP 文件生成执行指南
- 参数:
prpFile(string): PRP 文件路径
- 返回: 完整的执行步骤指南
- 用途: 为 PRP 文档提供详细的执行流程和验证步骤
5. process_thought
- 描述: 处理单一思维并返回格式化输出
- 参数:
thought(string): 思维内容thought_number(int): 当前思维编号total_thoughts(int): 预计总思维数量next_thought_needed(bool): 是否需要下一步思维stage(string): 思维阶段tags(array, optional): 思维标签axioms_used(array, optional): 使用的公理assumptions_challenged(array, optional): 挑战的假设
- 返回: 格式化的思维处理输出
- 用途: 结构化管理复杂的思维过程,提供清晰的思考路径
6. log_report
- 描述: 上报工具使用记录
- 参数:
work_dir(string): 工作目录路径tool_type(string): 使用的工具类型
- 返回: 记录确认信息
- 用途: 追踪工具使用情况,便于分析和优化
📁 项目结构
aicoding_backend/
├── __init__.py # 包初始化文件
├── main.py # MCP 服务器主程序
├── prompts/ # 提示词模板目录
│ ├── __init__.py
│ ├── CreateFeatureProjectRules.md
│ ├── init_project_rules.py
│ ├── init_requirements_doc.py
│ └── prp_base.md
├── tools/ # 工具实现目录
│ ├── __init__.py
│ ├── init_project_rules.py
│ └── init_requirements_doc.py
└── utils/ # 工具函数目录
├── __init__.py
├── file_reader.py
├── file_utils.py
├── git_info.py
├── loader.py
├── log.py
├── template.py
├── user_info.py
└── version.py
🔗 依赖项
- Python: >=3.13
- GitPython: >=3.1.45 (Git 操作支持)
- httpx: >=0.28.1 (HTTP 客户端)
- keyring: >=25.6.0 (密钥管理)
- mcp[cli]: >=1.18.0 (MCP 协议支持)
- pipx: >=1.8.0 (Python 应用管理)
- pydantic: >=2.0.0 (数据验证)
🚀 开发
环境设置
- 克隆仓库:
git clone <repository-url>
cd AICoding-backend
- 安装依赖:
uv sync
- 运行开发服务器:
uv run python -m aicoding_backend.main
测试
# 运行测试
uv run pytest
# 运行测试并生成覆盖率报告
uv run pytest --cov=aicoding_backend
📋 使用示例
1. 初始化项目规范
# 通过 MCP 客户端调用
{
"method": "tools/call",
"params": {
"name": "init_project_rules",
"arguments": {}
}
}
2. 生成 PRP 文档
# 通过 MCP 客户端调用
{
"method": "tools/call",
"params": {
"name": "generate_prp",
"arguments": {
"feature_file": "features/user-auth.md"
}
}
}
3. 处理思维过程
# 通过 MCP 客户端调用
{
"method": "tools/call",
"params": {
"name": "process_thought",
"arguments": {
"thought": "需要分析用户认证系统的安全性",
"thought_number": 1,
"total_thoughts": 3,
"next_thought_needed": true,
"stage": "分析",
"tags": ["安全", "认证"]
}
}
}
🤝 贡献
欢迎贡献代码!请遵循以下步骤:
- Fork 本仓库
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 开启 Pull Request
📄 许可证
本项目采用 MIT 许可证。详情请参阅 LICENSE 文件。
👨💻 作者
Chen Shuren
🔗 相关链接
- Model Context Protocol - 了解更多关于 MCP 协议
- uv - 现代 Python 包管理器
- FastMCP - 快速构建 MCP 服务器的框架
📊 版本历史
- v0.1.5 - 当前版本
- 完整的 MCP 工具集成
- PRP 文档系统
- 思维处理工具
- 使用记录追踪
- 增加JAR包工具调用
如果你觉得这个项目有用,请给它一个 ⭐️!
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aicoding_backend-0.1.23.tar.gz
(105.1 kB
view details)
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 aicoding_backend-0.1.23.tar.gz.
File metadata
- Download URL: aicoding_backend-0.1.23.tar.gz
- Upload date:
- Size: 105.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06eda6d5327170a0b9006e595cbf399d93839a03071d2bdf5f5f7d1e5bcb0676
|
|
| MD5 |
f918c5079760065a9d6f5fd0caa010c5
|
|
| BLAKE2b-256 |
4efbf03a49d7896ebd64fb140cd5653f717dca1918d32b1d683f87f994b67c38
|
File details
Details for the file aicoding_backend-0.1.23-py3-none-any.whl.
File metadata
- Download URL: aicoding_backend-0.1.23-py3-none-any.whl
- Upload date:
- Size: 65.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dceb967930bae9c43e1447b7f60a1779313409b5dbb3c9282156ce4f700e94f8
|
|
| MD5 |
6c4c842ffc4f721ba440e95ff2386ca9
|
|
| BLAKE2b-256 |
007df3afabe4a2e4b19f6cc7b8e0e0bba7d37e24a6e476b2d9bad30ac85d5c18
|