Skip to main content

AI Coding Backend - A backend service for AI-assisted coding with MCP (Model Context Protocol) integration

Project description

AI Coding Backend

Python Version License: MIT MCP Compatible

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 (数据验证)

🚀 开发

环境设置

  1. 克隆仓库:
git clone <repository-url>
cd AICoding-backend
  1. 安装依赖:
uv sync
  1. 运行开发服务器:
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": ["安全", "认证"]
    }
  }
}

🤝 贡献

欢迎贡献代码!请遵循以下步骤:

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启 Pull Request

📄 许可证

本项目采用 MIT 许可证。详情请参阅 LICENSE 文件。

👨‍💻 作者

Chen Shuren

🔗 相关链接

📊 版本历史

  • v0.1.5 - 当前版本
    • 完整的 MCP 工具集成
    • PRP 文档系统
    • 思维处理工具
    • 使用记录追踪
    • 增加JAR包工具调用

如果你觉得这个项目有用,请给它一个 ⭐️!

Project details


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.20.tar.gz (102.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aicoding_backend-0.1.20-py3-none-any.whl (64.9 kB view details)

Uploaded Python 3

File details

Details for the file aicoding_backend-0.1.20.tar.gz.

File metadata

  • Download URL: aicoding_backend-0.1.20.tar.gz
  • Upload date:
  • Size: 102.6 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

Hashes for aicoding_backend-0.1.20.tar.gz
Algorithm Hash digest
SHA256 09f6e16da9fa9040ed4d7d17e2873034302f251adc1794e06ea0800edd713cd3
MD5 da076395907d9adce6fa1e927c8f6cc6
BLAKE2b-256 db35e516bce6cc7e1db29470752fb26015a91129dcdb3e2ba9d554ec873bc9db

See more details on using hashes here.

File details

Details for the file aicoding_backend-0.1.20-py3-none-any.whl.

File metadata

  • Download URL: aicoding_backend-0.1.20-py3-none-any.whl
  • Upload date:
  • Size: 64.9 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

Hashes for aicoding_backend-0.1.20-py3-none-any.whl
Algorithm Hash digest
SHA256 7daa90f2271e9f4498bfa40912db1c256c7d82ad719260029d79f60f3ef803d2
MD5 9c6f0c45ec4b3128c259515df00e4cbd
BLAKE2b-256 252c47d7f8b4d72d170b183af226c1ddbb83d4e04f93dfcdcbace75c069b47b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page