Metadata-Version: 2.4
Name: cann-gitcode-mcp
Version: 0.1.0
Summary: CANN GitCode MCP Server - GitCode platform tools for CANN developers
Project-URL: Homepage, https://gitcode.com/shengnan666/cann-gitcode-mcp
Project-URL: Repository, https://gitcode.com/shengnan666/cann-gitcode-mcp
Project-URL: Issues, https://gitcode.com/shengnan666/cann-gitcode-mcp/issues
Author-email: shengnan <shengnan1126@yeah.net>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: cann,gitcode,mcp,model-context-protocol
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27
Requires-Dist: mcp>=1.0
Provides-Extra: dev
Requires-Dist: build>=1.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: twine>=6.0; extra == 'dev'
Description-Content-Type: text/markdown

# cann-gitcode-mcp

[![PyPI version](https://img.shields.io/pypi/v/cann-gitcode-mcp)](https://pypi.org/project/cann-gitcode-mcp/)
[![Python](https://img.shields.io/pypi/pyversions/cann-gitcode-mcp)](https://pypi.org/project/cann-gitcode-mcp/)
[![License](https://img.shields.io/pypi/l/cann-gitcode-mcp)](https://github.com/shengnan666/cann-gitcode-mcp/blob/main/LICENSE)

CANN GitCode MCP 服务器 —— 为 CANN 开发者提供的 GitCode 平台 MCP 工具集。

## 简介

`cann-gitcode-mcp` 是一个基于 [MCP（Model Context Protocol）](https://modelcontextprotocol.io/) 的服务器，将 GitCode API 操作封装为 MCP 工具，供 Claude Code 及其他 MCP 客户端直接调用。

CANN 社区的代码托管在 GitCode 平台，本项目为 CANN 开发者提供在 AI 助手中操作 GitCode 仓库（Pull Request、流水线、Issue 等）的能力，无需离开对话界面即可完成常见研发工作流。

## 安装

```bash
pip install cann-gitcode-mcp
```

## 配置

### 1. 获取 GitCode API Token

在 [GitCode 用户设置](https://gitcode.com/profile/tokens) 中生成个人访问令牌。

### 2. 设置环境变量

```bash
export GITCODE_API_TOKEN=your_token_here
```

### 3. 与 Claude Code 集成

在 Claude Code 的 MCP 配置文件中添加：

```json
{
  "mcpServers": {
    "gitcode": {
      "command": "cann-gitcode-mcp",
      "env": {
        "GITCODE_API_TOKEN": "your_token_here"
      }
    }
  }
}
```

或使用模块方式：

```json
{
  "mcpServers": {
    "gitcode": {
      "command": "python",
      "args": ["-m", "cann_gitcode_mcp"],
      "env": {
        "GITCODE_API_TOKEN": "your_token_here"
      }
    }
  }
}
```

配置完成后重启 Claude Code，即可在对话中使用所有 GitCode 工具。

## 可用工具

### Pull Request

| 工具名 | 说明 |
|--------|------|
| `create_pull_request` | 创建 Pull Request |
| `list_pull_requests` | 列出仓库的 Pull Request（支持状态、排序等过滤） |
| `get_pull_request` | 获取指定 PR 的详细信息 |
| `merge_pull_request` | 合并 Pull Request |
| `comment_pull_request` | 在 PR 上发表评论 |
| `get_pull_request_files` | 获取 PR 的变更文件列表 |

## 环境变量

| 变量 | 必填 | 说明 |
|------|------|------|
| `GITCODE_API_TOKEN` | 是 | GitCode 个人访问令牌 |
| `GITCODE_API_BASE_URL` | 否 | API 地址覆盖（默认 `https://gitcode.com/api/v5`） |

## 路线图

- **Issue 工具**：Issue 增删改查、评论管理
- **仓库工具**：分支管理、文件读取、提交历史
- **流水线/CI 工具**：触发 CANN CI 流水线、查询流水线状态

## 开发

```bash
# 安装开发依赖
pip install -e ".[dev]"

# 运行测试
pytest

# 构建包
python -m build

# 上传到 PyPI
twine upload dist/*
```

## 版本规则

本项目遵循 [语义化版本](https://semver.org/lang/zh-CN/)：

- `0.x.y` — 早期开发阶段，接口可能不兼容变更
- `1.0.0` — 工具集稳定后的首个正式版本
- MAJOR.MINOR.PATCH — 不兼容变更.新功能.修复

## 许可证

[Apache License 2.0](LICENSE)
