Skip to content

Commit 71db89b

Browse files
committed
feat: Add fork repository tool and update documentation
- Added `fork_repository` tool to the server. - Updated the README and README_CN files to include the new tool. - Bumped the version to 0.1.8.
1 parent 164e7c8 commit 71db89b

File tree

6 files changed

+104
-47
lines changed

6 files changed

+104
-47
lines changed

README.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,32 +100,33 @@ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file
100100

101101
The server provides various tools for interacting with Gitee:
102102

103-
| Tool | Category | Description |
104-
|-----------------------------|----------|-------------|
105-
| **list_user_repos** | Repository | List user authorized repositories |
106-
| **get_file_content** | Repository | Get the content of a file in a repository |
107-
| **create_user_repo** | Repository | Create a user repository |
108-
| **create_org_repo** | Repository | Create an organization repository |
109-
| **create_enter_repo** | Repository | Create an enterprise repository |
110-
| **create_release** | Repository | Create a release for a repository |
111-
| **list_releases** | Repository | List repository releases |
112-
| **search_open_source_repositories**| Repository | Search open source repositories on Gitee |
113-
| **list_repo_pulls** | Pull Request | List pull requests in a repository |
114-
| **merge_pull** | Pull Request | Merge a pull request |
115-
| **create_pull** | Pull Request | Create a pull request |
116-
| **update_pull** | Pull Request | Update a pull request |
117-
| **get_pull_detail** | Pull Request | Get details of a pull request |
118-
| **comment_pull** | Pull Request | Comment on a pull request |
119-
| **list_pull_comments** | Pull Request | List all comments for a pull request |
120-
| **create_issue** | Issue | Create an issue |
121-
| **update_issue** | Issue | Update an issue |
122-
| **get_repo_issue_detail** | Issue | Get details of a repository issue |
123-
| **list_repo_issues** | Issue | List repository issues |
124-
| **comment_issue** | Issue | Comment on an issue |
125-
| **list_issue_comments** | Issue | List comments on an issue |
126-
| **get_user_info** | User | Get current authenticated user information |
127-
| **search_users** | User | Search for users |
128-
| **list_user_notifications** | Notification | List user notifications |
103+
| Tool | Category | Description |
104+
|-------------------------------------|----------|-------------|
105+
| **list_user_repos** | Repository | List user authorized repositories |
106+
| **get_file_content** | Repository | Get the content of a file in a repository |
107+
| **create_user_repo** | Repository | Create a user repository |
108+
| **create_org_repo** | Repository | Create an organization repository |
109+
| **create_enter_repo** | Repository | Create an enterprise repository |
110+
| **fork_repository** | Repository | Fork a repository |
111+
| **create_release** | Repository | Create a release for a repository |
112+
| **list_releases** | Repository | List repository releases |
113+
| **search_open_source_repositories** | Repository | Search open source repositories on Gitee |
114+
| **list_repo_pulls** | Pull Request | List pull requests in a repository |
115+
| **merge_pull** | Pull Request | Merge a pull request |
116+
| **create_pull** | Pull Request | Create a pull request |
117+
| **update_pull** | Pull Request | Update a pull request |
118+
| **get_pull_detail** | Pull Request | Get details of a pull request |
119+
| **comment_pull** | Pull Request | Comment on a pull request |
120+
| **list_pull_comments** | Pull Request | List all comments for a pull request |
121+
| **create_issue** | Issue | Create an issue |
122+
| **update_issue** | Issue | Update an issue |
123+
| **get_repo_issue_detail** | Issue | Get details of a repository issue |
124+
| **list_repo_issues** | Issue | List repository issues |
125+
| **comment_issue** | Issue | Comment on an issue |
126+
| **list_issue_comments** | Issue | List comments on an issue |
127+
| **get_user_info** | User | Get current authenticated user information |
128+
| **search_users** | User | Search for users |
129+
| **list_user_notifications** | Notification | List user notifications |
129130

130131
## Contribution
131132

README_CN.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,32 +101,33 @@ mcp-gitee --version
101101

102102
服务器提供了各种与 Gitee 交互的工具:
103103

104-
| 工具 | 类别 | 描述 |
105-
|-----------------------------|------|------------------|
106-
| **list_user_repos** | 仓库 | 列出用户授权的仓库 |
107-
| **get_file_content** | 仓库 | 获取仓库中文件的内容 |
108-
| **create_user_repo** | 仓库 | 创建用户仓库 |
109-
| **create_org_repo** | 仓库 | 创建组织仓库 |
110-
| **create_enter_repo** | 仓库 | 创建企业仓库 |
111-
| **create_release** | 仓库 | 为仓库创建发行版 |
112-
| **list_releases** | 仓库 | 列出仓库发行版 |
113-
| **search_open_source_repositories** | 仓库 | 搜索开源仓库 |
104+
| 工具 | 类别 | 描述 |
105+
|-----------------------------|--------------|------------------|
106+
| **list_user_repos** | 仓库 | 列出用户授权的仓库 |
107+
| **get_file_content** | 仓库 | 获取仓库中文件的内容 |
108+
| **create_user_repo** | 仓库 | 创建用户仓库 |
109+
| **create_org_repo** | 仓库 | 创建组织仓库 |
110+
| **create_enter_repo** | 仓库 | 创建企业仓库 |
111+
| **fork_repository** | 仓库 | Fork 仓库 |
112+
| **create_release** | 仓库 | 为仓库创建发行版 |
113+
| **list_releases** | 仓库 | 列出仓库发行版 |
114+
| **search_open_source_repositories** | 仓库 | 搜索开源仓库 |
114115
| **list_repo_pulls** | Pull Request | 列出仓库中的拉取请求 |
115116
| **merge_pull** | Pull Request | 合并拉取请求 |
116117
| **create_pull** | Pull Request | 创建拉取请求 |
117118
| **update_pull** | Pull Request | 更新拉取请求 |
118119
| **get_pull_detail** | Pull Request | 获取拉取请求的详细信息 |
119120
| **comment_pull** | Pull Request | 评论拉取请求 |
120121
| **list_pull_comments** | Pull Request | 列出拉取请求的所有评论 |
121-
| **create_issue** | Issue | 创建 Issue |
122-
| **update_issue** | Issue | 更新 Issue |
123-
| **get_repo_issue_detail** | Issue | 获取仓库 Issue 的详细信息 |
124-
| **list_repo_issues** | Issue | 列出仓库 Issue |
125-
| **comment_issue** | Issue | 评论 Issue |
126-
| **list_issue_comments** | Issue | 列出 Issue 的评论 |
127-
| **get_user_info** | 用户 | 获取当前认证用户信息 |
128-
| **search_users** | 用户 | 搜索用户 |
129-
| **list_user_notifications** | 通知 | 列出用户通知 |
122+
| **create_issue** | Issue | 创建 Issue |
123+
| **update_issue** | Issue | 更新 Issue |
124+
| **get_repo_issue_detail** | Issue | 获取仓库 Issue 的详细信息 |
125+
| **list_repo_issues** | Issue | 列出仓库 Issue |
126+
| **comment_issue** | Issue | 评论 Issue |
127+
| **list_issue_comments** | Issue | 列出 Issue 的评论 |
128+
| **get_user_info** | 用户 | 获取当前认证用户信息 |
129+
| **search_users** | 用户 | 搜索用户 |
130+
| **list_user_notifications** | 通知 | 列出用户通知 |
130131

131132
## 贡献
132133

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func addTools(s *server.MCPServer) {
4040
s.AddTool(repository.CreateReleaseTool, repository.CreateReleaseHandleFunc)
4141
s.AddTool(repository.ListReleasesTool, repository.ListReleasesHandleFunc)
4242
s.AddTool(repository.SearchReposTool, repository.SearchOpenSourceReposHandler)
43+
s.AddTool(repository.ForkRepositoryTool, repository.ForkRepositoryHandler)
4344

4445
// Pulls Tools
4546
s.AddTool(pulls.NewListPullsTool(pulls.ListRepoPullsToolName), pulls.ListPullsHandleFunc(pulls.ListRepoPullsToolName))

operations/pulls/create_pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var CreatePullTool = func() mcp.Tool {
2929
),
3030
mcp.WithString(
3131
"head",
32-
mcp.Description("The source branch of the pull request"),
32+
mcp.Description("The source branch of the pull request, Format: branch (master) or: path_with_namespace:branch (oschina/gitee:master)"),
3333
mcp.Required(),
3434
),
3535
mcp.WithString(
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package repository
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"gitee.com/oschina/mcp-gitee/operations/types"
7+
"gitee.com/oschina/mcp-gitee/utils"
8+
"github.com/mark3labs/mcp-go/mcp"
9+
)
10+
11+
const (
12+
ForkRepositoryToolName = "fork_repository"
13+
)
14+
15+
var ForkRepositoryTool = mcp.NewTool(
16+
ForkRepositoryToolName,
17+
mcp.WithDescription("Fork a repository"),
18+
mcp.WithString(
19+
"owner",
20+
mcp.Description("The space address to which the repository belongs (the address path of the enterprise, organization or individual)"),
21+
mcp.Required(),
22+
),
23+
mcp.WithString(
24+
"repo",
25+
mcp.Description("The path of the repository"),
26+
mcp.Required(),
27+
),
28+
mcp.WithString(
29+
"organization",
30+
mcp.Description("The full address of the organization space to which the repository belongs, default for current user"),
31+
),
32+
mcp.WithString(
33+
"name",
34+
mcp.Description("The name of the forked repository, default is the same as the original repository"),
35+
),
36+
mcp.WithString(
37+
"path",
38+
mcp.Description("The path of the forked repository, default is the same as the original repository"),
39+
),
40+
)
41+
42+
func ForkRepositoryHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
43+
if checkResult, err := utils.CheckRequired(request.Params.Arguments, "owner", "repo"); err != nil {
44+
return checkResult, err
45+
}
46+
owner := request.Params.Arguments["owner"].(string)
47+
repo := request.Params.Arguments["repo"].(string)
48+
49+
apiUrl := fmt.Sprintf("/repos/%s/%s/forks", owner, repo)
50+
giteeClient := utils.NewGiteeClient("POST", apiUrl, utils.WithPayload(request.Params.Arguments))
51+
52+
data := &types.Project{}
53+
return giteeClient.HandleMCPResult(data)
54+
}

utils/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package utils
22

33
var (
44
// Version gitee mcp server version
5-
Version = "0.1.7"
5+
Version = "0.1.8"
66
)

0 commit comments

Comments
 (0)