Gitee

by normal-coder
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Enables AI to interact with Gitee repositories, including creating/managing repositories, branches, files, issues, and pull requests. Supports operations like pushing code, creating issues, managing PRs, and performing user-related actions on Gitee's platform.

Gitee MCP 服务器

让 AI 通过 MCP 为您操作 Gitee 仓库/Issues/Pull Requests


支持的AI操作

类别MCP 工具描述
存储库操作create_repository创建 Gitee 存储库
fork_repository派生一个 Gitee 存储库
分支机构运营create_branch在 Gitee 存储库中创建新分支
list_branches列出 Gitee 存储库中的分支
get_branch获取 Gitee 存储库中特定分支的详细信息
文件操作get_file_contents获取 Gitee 存储库中文件或目录的内容
create_or_update_file在 Gitee 存储库中创建或更新文件
push_files将多个文件推送到 Gitee 存储库
发行操作create_issue在 Gitee 仓库中创建问题
list_issues列出 Gitee 存储库中的问题
get_issue获取 Gitee 存储库中特定问题的详细信息
update_issue更新 Gitee 存储库中的问题
add_issue_comment向 Gitee 存储库中的问题添加评论
拉取请求操作create_pull_request在 Gitee 存储库中创建 Pull 请求
list_pull_requests列出 Gitee 存储库中的 Pull 请求
get_pull_request获取 Gitee 存储库中特定 Pull 请求的详细信息
update_pull_request更新 Gitee 存储库中的 Pull 请求
merge_pull_request在 Gitee 存储库中合并拉取请求
用户操作get_user获取Gitee用户信息
get_current_user获取已认证的Gitee用户信息

用法

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Gitee MCP 服务器:

npx -y @smithery/cli install @normal-coder/gitee-mcp-server --client claude

配置

  • GITEE_API_BASE_URL :可选,Gitee OpenAPI Endpoint,默认为https://gitee.com/api/v5
  • GITEE_PERSONAL_ACCESS_TOKEN :必需,Gitee 帐户个人访问令牌(PAT),可从 Gitee 帐户设置个人访问令牌中获取
  • DEBUG :可选,设置为true以启用调试日志记录,默认为禁用

通过 NPX 运行 MCP 服务器

{ "mcpServers": { "Gitee": { "command": "npx", "args": [ "-y", "gitee-mcp-server" ], "env": { "GITEE_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>" } } } }

通过 Docker 容器运行 MCP 服务器

  1. 获取 Docker 镜像
# Get from DockerHub docker pull normalcoder/gitee-mcp-server # Build locally docker build -t normalcoder/gitee-mcp-server .
  1. 配置 MCP 服务器
{ "mcpServers": { "Gitee": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "GITEE_PERSONAL_ACCESS_TOKEN", "normalcoder/gitee-mcp-server" ], "env": { "GITEE_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>" } } } }

开发指南

安装依赖项

npm install

建造

npm run build

成功构建后, /dist将包含可运行的 MCP 服务器。

运行服务器

npm start

MCP 服务器将在 stdio 上运行,允许 MCP 客户端将其用作子进程。

构建 Docker 镜像

您还可以使用 Docker 运行服务器:

docker build -t normalcoder/gitee-mcp-server .

使用 Docker 运行 MCP 服务器:

docker run -e GITEE_PERSONAL_ACCESS_TOKEN=<YOUR_TOKEN> normalcoder/gitee-mcp-server

调试 MCP 服务器

您可以使用@modelcontextprotocol/inspector进行调试:

在根目录中创建一个.env文件用于环境变量:

GITEE_API_BASE_URL=https://gitee.com/api/v5 GITEE_PERSONAL_ACCESS_TOKEN=<YOUR_TOKEN>

运行调试工具,启动服务和Web调试界面:

npx @modelcontextprotocol/inspector npm run start --env-file=.env

项目包含一个debug()函数,用于打印调试信息,用法:

import { debug } from './common/utils.js'; debug('Message to log'); debug('Message with data:', { key: 'value' });

仅当DEBUG环境变量设置为true时才会打印调试日志。

依赖项

  • @modelcontextprotocol/sdk :用于服务器实现的 MCP SDK
  • universal-user-agent :用于生成用户代理字符串
  • zod :用于模式验证
  • zod-to-json-schema :用于将 Zod 模式转换为 JSON 模式

执照

本软件遵循 MIT 许可证。您可以自由使用、修改和分发本软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目代码库中的LICENSE文件。

相关链接

ID: cck9xigm1d