Skip to content

init project #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: test1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM node:22.12-alpine AS builder

# 复制项目文件
COPY . /app
COPY tsconfig.json /tsconfig.json

WORKDIR /app

# 安装依赖并构建
RUN --mount=type=cache,target=/root/.npm npm install

# 添加构建步骤以生成 dist 目录
RUN npm run build

FROM node:22.12-alpine AS release

# 从构建阶段复制必要文件
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/package.json /app/package.json
COPY --from=builder /app/package-lock.json /app/package-lock.json

ENV NODE_ENV=production

WORKDIR /app

# 安装生产依赖
RUN npm ci --ignore-scripts --omit=dev

ENTRYPOINT ["node", "dist/index.js"]
45 changes: 45 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

<html>
<head>
<meta content="origin" name="referrer">
<title>Rate limit &middot; GitHub</title>
<meta name="viewport" content="width=device-width">
<style type="text/css" media="screen">
body {
background-color: #f6f8fa;
color: rgba(0, 0, 0, 0.5);
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
}
.c { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { color: #24292e; line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; }
p { margin: 20px 0 40px; }
#s { margin-top: 35px; }
#s a {
color: #666666;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
}
</style>
</head>
<body>
<div class="c">
<h1>Access has been restricted</h1>
<p>You have triggered a rate limit.<br><br>
Please wait a few minutes before you try again;<br>
in some cases this may take up to an hour.
</p>
<div id="s">
<a href="https://support.github.com">Contact Support</a> &mdash;
<a href="https://githubstatus.com">GitHub Status</a> &mdash;
<a href="https://twitter.com/githubstatus">@githubstatus</a>
</div>
</div>
</body>
</html>


103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# alibabacloud-devops-mcp-server
Yunxiao MCP Server provides AI assistants with the ability to interact with the Yunxiao platform, enabling them to read work item contents in projects, automatically write code after understanding requirements, and submit code merge requests. Enterprise development teams can use it to assist with code reviews, optimize task management, reduce repetitive operations, and thus focus on more important innovation and product delivery.

## Features

alibabacloud-devops-mcp-server provides the following capabilities for AI assistants:

* **Code Repository Management**: Query code repositories and their branches, create branches
* **File Operations**: Create, update, delete, and retrieve code file content
* **Code Review**: Create and manage code review processes
* **Project Management**: Search projects, get project details

## Tools

alibabacloud-devops-mcp-server integrates various tools, including:

### Organization
- `get_current_organization_Info`: Get current user's organization information
- `get_user_organizations`: Get the list of organizations the current user has joined

### Code Management Tools

- `create_branch`: Create a branch
- `delete_branch`: Delete a branch
- `get_branch`: Get branch information
- `list_branches`: Get branch list
- `create_file`: Create a file
- `delete_file`: Delete a file
- `get_file_blobs`: Get file content
- `list_files`: Query file tree
- `update_file`: Update file content
- `create_change_request`: Create a merge request
- `create_change_request_comment`: Create a comment on a merge request
- `get_change_request`: Query merge request
- `list_change_request_patch_sets`: Query merge request version list
- `list_change_request`: Query merge request list
- `list_change_request_comments`: Query merge request comment list
- `get_compare`: Compare code
- `get_repository`: Get repository details
- `list_repositories`: Get repository list

### Project Management Tools

- `get_project`: Get project details
- `search_projects`: Search projects
- `get_work_item`: Get work item details
- `search_workitems`: Search work items

## Usage

### Prerequisites
* node version >= 16.0.0
* Alibaba Cloud Yunxiao Personal Access Token, [click here to obtain](https://help.aliyun.com/zh/yunxiao/developer-reference/obtain-personal-access-token?spm=a2c4g.11186623.help-menu-150040.d_5_0_1.5dc72af2GnT64i). Grant read and write permissions to all APIs under organization management, project collaboration, and code management.

![The personal token authorization page](https://agent-install-beijing.oss-cn-beijing.aliyuncs.com/alibabacloud-devops-mcp-server/img_8.png)

### Run MCP Server via NPX
```json
{
"mcpServers": {
"yunxiao": {
"command": "npx",
"args": [
"-y",
"alibabacloud-devops-mcp-server"
],
"env": {
"YUNXIAO_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
```

### Run MCP Server via Docker Container
1. Docker build
```shell
docker build -t alibabacloud/alibabacloud-devops-mcp-server .
```
2. Configure MCP Server
```json
{
"mcpServers": {
"yunxiao": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"YUNXIAO_ACCESS_TOKEN",
"alibabacloud/alibabacloud-devops-mcp-server"
],
"env": {
"YUNXIAO_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
```

## Related Links
- [Alibaba Cloud Yunxiao](https://devops.aliyun.com)
102 changes: 102 additions & 0 deletions README.zh-ch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# alibabacloud-devops-mcp-server
云效mcp-server工具为 AI 助手提供了与云效平台交互的能力,能够让 AI 助手可以读取项目中工作项的内容,在理解需求后自动编写代码,并提交代码合并请求。企业研发团队可以使用它协助代码审查、优化任务管理、减少重复性操作,从而专注于更重要的创新和产品交付。

## 功能特性

alibabacloud-devops-mcp-server提供了以下功能,让AI助手能够:

* **代码仓库管理**:查询代码仓库及其分支、创建分支
* **文件操作**:创建、更新、删除和获取代码文件内容
* **代码评审**:创建和管理代码评审流程
* **项目管理**:搜索项目、获取项目详情

## 工具列表

alibabacloud-devops-mcp-server集成了多种工具,包括:

### 组织
- `get_current_organization_Info`: 获取当前用户所在组织信息
- `get_user_organizations`: 获取当前用户加入的组织列表

### 代码管理工具

- `create_branch`: 创建分支
- `delete_branch`: 删除分支
- `get_branch`: 获取分支信息
- `list_branches`: 获取分支列表
- `create_file`: 创建文件
- `delete_file`: 删除文件
- `get_file_blobs`: 获取文件内容
- `list_files`: 查询文件树
- `update_file`: 更新文件内容
- `create_change_request`: 创建合并请求
- `create_change_request_comment`: 创建合并请求评论
- `get_change_request`: 查询合并请求
- `list_change_request_patch_sets`: 查询合并请求版本列表
- `list_change_request`: 查询合并请求列表
- `list_change_request_comments`: 查询合并请求评论列表
- `get_compare`: 代码比较
- `get_repository`: 获取仓库详情
- `list_repositories`: 获取仓库列表

### 项目管理工具

- `get_project`: 获取项目详情
- `search_projects`: 搜索项目
- `get_work_item`: 获取工作项详情
- `search_workitems`: 搜索工作项

## 用法

### 先决条件
* node 版本 >= 16.0.0
* 阿里云云效个人访问令牌,[点击前往](https://help.aliyun.com/zh/yunxiao/developer-reference/obtain-personal-access-token?spm=a2c4g.11186623.help-menu-150040.d_5_0_1.5dc72af2GnT64i),授予组织管理、项目协作、代码管理下所有api的读写权限。

![个人令牌授权页面](https://agent-install-beijing.oss-cn-beijing.aliyuncs.com/alibabacloud-devops-mcp-server/img_8.png)

### 通过 NPX 运行 MCP 服务器
```json
{
"mcpServers": {
"yunxiao": {
"command": "npx",
"args": [
"-y",
"alibabacloud-devops-mcp-server"
],
"env": {
"YUNXIAO_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
```
### 通过 Docker 容器运行 MCP 服务器
1.Docker build
```shell
docker build -t alibabacloud/alibabacloud-devops-mcp-server .
```
2.配置 MCP 服务器
```json
{
"mcpServers": {
"yunxiao": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"YUNXIAO_ACCESS_TOKEN",
"alibabacloud/alibabacloud-devops-mcp-server"
],
"env": {
"YUNXIAO_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
```

## 相关链接
- [阿里云云效](https://devops.aliyun.com)
89 changes: 89 additions & 0 deletions common/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
export class YunxiaoError extends Error {
constructor(
message: string,
public readonly status: number,
public readonly response: unknown
) {
super(message);
this.name = "YunxiaoError";
}
}

export class YunxiaoValidationError extends YunxiaoError {
constructor(message: string, status: number, response: unknown) {
super(message, status, response);
this.name = "YunxiaoValidationError";
}
}

export class YunxiaoResourceNotFoundError extends YunxiaoError {
constructor(resource: string) {
super(`Resource not found: ${resource}`, 404, { message: `${resource} not found` });
this.name = "YunxiaoResourceNotFoundError";
}
}

export class YunxiaoAuthenticationError extends YunxiaoError {
constructor(message = "Authentication failed") {
super(message, 401, { message });
this.name = "YunxiaoAuthenticationError";
}
}

export class YunxiaoPermissionError extends YunxiaoError {
constructor(message = "Insufficient permissions") {
super(message, 403, { message });
this.name = "YunxiaoPermissionError";
}
}

export class YunxiaoRateLimitError extends YunxiaoError {
constructor(
message = "Rate limit exceeded",
public readonly resetAt: Date
) {
super(message, 429, { message, reset_at: resetAt.toISOString() });
this.name = "YunxiaoRateLimitError";
}
}

export class YunxiaoConflictError extends YunxiaoError {
constructor(message: string) {
super(message, 409, { message });
this.name = "YunxiaoConflictError";
}
}

export function isYunxiaoError(error: unknown): error is YunxiaoError {
return error instanceof YunxiaoError;
}

export function createYunxiaoError(status: number, response: any): YunxiaoError {
switch (status) {
case 401:
return new YunxiaoAuthenticationError(response?.message);
case 403:
return new YunxiaoPermissionError(response?.message);
case 404:
return new YunxiaoResourceNotFoundError(response?.message || "Resource");
case 409:
return new YunxiaoConflictError(response?.message || "Conflict occurred");
Comment on lines +68 to +70
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

createYunxiaoError(404) passes a message where a resource identifier is expected

YunxiaoResourceNotFoundError’s constructor parameter represents the missing resource, but the factory forwards the response message instead, resulting in error messages like “Resource not found: Not Found”. Consider extracting the resource name or pass a generic placeholder.

-    case 404:
-      return new YunxiaoResourceNotFoundError(response?.message || "Resource");
+    case 404:
+      return new YunxiaoResourceNotFoundError(
+        typeof response?.resource === "string" ? response.resource : "Resource"
+      );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return new YunxiaoResourceNotFoundError(response?.message || "Resource");
case 409:
return new YunxiaoConflictError(response?.message || "Conflict occurred");
case 404:
return new YunxiaoResourceNotFoundError(
typeof response?.resource === "string" ? response.resource : "Resource"
);
case 409:
return new YunxiaoConflictError(response?.message || "Conflict occurred");

case 422:
return new YunxiaoValidationError(
response?.message || "Validation failed",
status,
response
);
case 429:
return new YunxiaoRateLimitError(
response?.message,
new Date(response?.reset_at || Date.now() + 60000)
);
default:
return new YunxiaoError(
response?.message || "Yunxiao API error",
status,
response
);
}
}
Loading