Skip to content

Commit d03e869

Browse files
committed
initial commit
0 parents  commit d03e869

40 files changed

+2593
-0
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
*.exe
2+
*.exe~
3+
*.dll
4+
*.so
5+
*.dylib
6+
/bin
7+
/dist
8+
/tmp
9+
10+
11+
*.test
12+
*.out
13+
coverage.html
14+
profile.cov
15+
16+
/vendor/
17+
18+
.idea/
19+
*.iml
20+
21+
.vscode/
22+
23+
.DS_Store
24+
*.log
25+
.env
26+
.env.local

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM golang:1.23-bullseye AS builder
2+
3+
# Set the working directory
4+
WORKDIR /app
5+
6+
# Copy go.mod and go.sum files
7+
COPY go.mod go.sum ./
8+
9+
# Download dependencies
10+
RUN go mod download
11+
12+
# Copy the source code
13+
COPY . .
14+
15+
# Build the application
16+
RUN go build -o mcp-gitee .
17+
18+
# Final stage
19+
FROM debian:bullseye-slim
20+
21+
# Install ca-certificates for HTTPS requests
22+
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
23+
24+
# Create a non-root user
25+
RUN useradd -r -u 1000 -m gitee
26+
27+
# Set the working directory
28+
WORKDIR /app
29+
30+
# Copy the binary from the builder stage
31+
COPY --from=builder --chown=1000:1000 /app/mcp-gitee /app/
32+
33+
# Use the non-root user
34+
USER gitee
35+
36+
# Expose the port the app runs on
37+
EXPOSE 8000
38+
39+
# Run the application
40+
ENTRYPOINT ["/app/mcp-gitee", "--transport", "sse", "--sse-address", "0.0.0.0:8000"]

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Makefile for cross-platform build
2+
GO = go
3+
4+
# Version information
5+
VERSION ?= 0.1.0
6+
7+
# Flags
8+
LDFLAGS = -ldflags "-X main.Version=$(VERSION)"
9+
BUILD_FLAGS = -o bin/mcp-gitee $(LDFLAGS)
10+
11+
define show_usage_info
12+
@echo "\033[32m\n🤖🤖 Build Success 🤖🤖\033[0m"
13+
@echo "\033[32mExecutable path: $(shell pwd)/bin/mcp-gitee\033[0m"
14+
@echo "\033[33m\nUsage: ./bin/mcp-gitee [options]\033[0m"
15+
@echo "\033[33mAvailable options:\033[0m"
16+
@echo "\033[33m --token= Gitee access token (or set GITEE_ACCESS_TOKEN env)\033[0m"
17+
@echo "\033[33m --api-base= Gitee API base URL (or set GITEE_API_BASE env)\033[0m"
18+
@echo "\033[33m --version Show version information\033[0m"
19+
@echo "\033[33mExample: ./bin/mcp-gitee --token=your_access_token\033[0m"
20+
@echo "\033[33mExample with env: GITEE_ACCESS_TOKEN=your_token ./bin/mcp-gitee\033[0m"
21+
endef
22+
23+
build:
24+
$(GO) build $(BUILD_FLAGS) -v main.go
25+
@echo "Build complete."
26+
$(call show_usage_info)
27+
28+
# Clean up generated binaries
29+
clean:
30+
rm -f bin/mcp-gitee
31+
@echo "Clean up complete."
32+
33+
# 显示版本信息
34+
version:
35+
@echo "Version: $(VERSION)"

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Gitee MCP Server
2+
3+
Gitee MCP Server is a Model Context Protocol (MCP) server implementation for Gitee. It provides a set of tools for interacting with Gitee's API, allowing AI assistants to manage repositories, issues, pull requests, and more.
4+
5+
## Features
6+
7+
- Interact with Gitee repositories, issues, pull requests, and notifications
8+
- Configurable API base URL to support different Gitee instances
9+
- Command-line flags for easy configuration
10+
- Supports both personal, organization, and enterprise operations
11+
12+
## Installation
13+
14+
### Prerequisites
15+
16+
- Go 1.23.0 or higher
17+
- Gitee account with an access token, [Go to get](https://gitee.com/profile/personal_access_tokens)
18+
19+
### Building from Source
20+
21+
1. Clone the repository:
22+
```bash
23+
git clone https://gitee.com/oschina/mcp-gitee.git
24+
cd mcp-gitee
25+
```
26+
27+
2. Build the project:
28+
```bash
29+
make build
30+
```
31+
32+
3. Use go install
33+
```bash
34+
go install gitee.com/oschina/mcp-gitee
35+
```
36+
37+
## Usage
38+
39+
Run the server with:
40+
41+
```bash
42+
./mcp-gitee -token=YOUR_GITEE_ACCESS_TOKEN
43+
```
44+
45+
### Command-line Options
46+
47+
- `-token`: Gitee access token
48+
- `-api-base`: Gitee API base URL (default: https://gitee.com/api/v5)
49+
- `-version`: Show version information
50+
- `-transport`: Transport type (stdio or sse, default: stdio)
51+
- `-sse-address`: The host and port to start the SSE server on (default: localhost:8000)
52+
53+
### Environment Variables
54+
55+
You can also configure the server using environment variables:
56+
57+
- `GITEE_ACCESS_TOKEN`: Gitee access token
58+
- `GITEE_API_BASE`: Gitee API base URL
59+
60+
## Available Tools
61+
62+
The server provides various tools for interacting with Gitee:
63+
64+
| Tool | Category | Description |
65+
|-----------------------------|----------|-------------|
66+
| **list_user_repos** | Repository | List user authorized repositories |
67+
| **get_file_content** | Repository | Get the content of a file in a repository |
68+
| **create_user_repo** | Repository | Create a user repository |
69+
| **create_org_repo** | Repository | Create an organization repository |
70+
| **create_enter_repo** | Repository | Create an enterprise repository |
71+
| **create_release** | Repository | Create a release for a repository |
72+
| **list_releases** | Repository | List repository releases |
73+
| **list_repo_pulls** | Pull Request | List pull requests in a repository |
74+
| **merge_pull** | Pull Request | Merge a pull request |
75+
| **create_pull** | Pull Request | Create a pull request |
76+
| **update_pull** | Pull Request | Update a pull request |
77+
| **get_pull_detail** | Pull Request | Get details of a pull request |
78+
| **comment_pull** | Pull Request | Comment on a pull request |
79+
| **list_pull_comments** | Pull Request | List all comments for a pull request |
80+
| **create_issue** | Issue | Create an issue |
81+
| **update_issue** | Issue | Update an issue |
82+
| **get_repo_issue_detail** | Issue | Get details of a repository issue |
83+
| **list_repo_issues** | Issue | List repository issues |
84+
| **comment_issue** | Issue | Comment on an issue |
85+
| **list_issue_comments** | Issue | List comments on an issue |
86+
| **list_user_notifications** | Notification | List user notifications |

README_CN.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Gitee MCP Server
2+
3+
Gitee MCP 服务器是一个用于 Gitee 的模型上下文协议(Model Context Protocol,MCP)服务器实现。它提供了一系列与 Gitee API 交互的工具,使 AI 助手能够管理仓库、问题、拉取请求等。
4+
5+
## 功能特点
6+
7+
- 与 Gitee 仓库、问题、拉取请求和通知进行交互
8+
- 可配置的 API 基础 URL,支持不同的 Gitee 实例
9+
- 命令行标志,便于配置
10+
- 支持个人、组织和企业操作
11+
12+
## 安装
13+
14+
### 前提条件
15+
16+
- Go 1.23.0 或更高版本
17+
- 拥有访问令牌的 Gitee 账户,[前往获取](https://gitee.com/profile/personal_access_tokens)
18+
19+
### 从源代码构建
20+
21+
1. 克隆仓库:
22+
```bash
23+
git clone https://gitee.com/oschina/mcp-gitee.git
24+
cd mcp-gitee
25+
```
26+
27+
2. 构建项目:
28+
```bash
29+
make build
30+
```
31+
32+
3. 使用 go install 安装
33+
```bash
34+
go install gitee.com/oschina/mcp-gitee
35+
```
36+
37+
## 使用方法
38+
39+
运行服务器:
40+
41+
```bash
42+
./mcp-gitee -token=你的_GITEE_访问令牌
43+
```
44+
45+
### 命令行选项
46+
47+
- `-token`:Gitee 访问令牌
48+
- `-api-base`:Gitee API 基础 URL(默认:https://gitee.com/api/v5)
49+
- `-version`:显示版本信息
50+
- `-transport`:传输类型(stdio 或 sse,默认:stdio)
51+
- `-sse-address`:启动 SSE 服务器的主机和端口(默认:localhost:8000)
52+
53+
### 环境变量
54+
55+
您也可以使用环境变量配置服务器:
56+
57+
- `GITEE_ACCESS_TOKEN`:Gitee 访问令牌
58+
- `GITEE_API_BASE`:Gitee API 基础 URL
59+
60+
## 可用工具
61+
62+
服务器提供了各种与 Gitee 交互的工具:
63+
64+
| 工具 | 类别 | 描述 |
65+
|-----------------------------|------|------------------|
66+
| **list_user_repos** | 仓库 | 列出用户授权的仓库 |
67+
| **get_file_content** | 仓库 | 获取仓库中文件的内容 |
68+
| **create_user_repo** | 仓库 | 创建用户仓库 |
69+
| **create_org_repo** | 仓库 | 创建组织仓库 |
70+
| **create_enter_repo** | 仓库 | 创建企业仓库 |
71+
| **create_release** | 仓库 | 为仓库创建发行版 |
72+
| **list_releases** | 仓库 | 列出仓库发行版 |
73+
| **list_repo_pulls** | Pull Request | 列出仓库中的拉取请求 |
74+
| **merge_pull** | Pull Request | 合并拉取请求 |
75+
| **create_pull** | Pull Request | 创建拉取请求 |
76+
| **update_pull** | Pull Request | 更新拉取请求 |
77+
| **get_pull_detail** | Pull Request | 获取拉取请求的详细信息 |
78+
| **comment_pull** | Pull Request | 评论拉取请求 |
79+
| **list_pull_comments** | Pull Request | 列出拉取请求的所有评论 |
80+
| **create_issue** | Issue | 创建 Issue |
81+
| **update_issue** | Issue | 更新 Issue |
82+
| **get_repo_issue_detail** | Issue | 获取仓库 Issue 的详细信息 |
83+
| **list_repo_issues** | Issue | 列出仓库 Issue |
84+
| **comment_issue** | Issue | 评论 Issue |
85+
| **list_issue_comments** | Issue | 列出 Issue 的评论 |
86+
| **list_user_notifications** | 通知 | 列出用户通知 |

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module gitee.com/oschina/mcp-gitee
2+
3+
go 1.23.0
4+
5+
require github.com/mark3labs/mcp-go v0.11.2
6+
7+
require github.com/google/uuid v1.6.0 // indirect

go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
4+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
5+
github.com/mark3labs/mcp-go v0.11.2 h1:mCxWFUTrcXOtJIn9t7F8bxAL8rpE/ZZTTnx3PU/VNdA=
6+
github.com/mark3labs/mcp-go v0.11.2/go.mod h1:cjMlBU0cv/cj9kjlgmRhoJ5JREdS7YX83xeIG9Ko/jE=
7+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
8+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
10+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
11+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
12+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)