初版gitlab合并test mcp
This commit is contained in:
1 parent
227d77f586
commit
0ccc8b625b
6 files changed
+2866
-35
No files matched your search
@@ -1,41 +1,53 @@
|
||||
# Qwen Code Context: Node.js MCP Server
|
||||
# Qwen Code Context: GitLab MCP 服务器
|
||||
|
||||
## Project Overview
|
||||
This is a Node.js-based Model Context Protocol (MCP) server implementation that provides tools for external clients to interact with. The server uses the `@modelcontextprotocol/sdk` to implement the MCP specification and offers tools like greeting and weather information retrieval.
|
||||
## 项目概述
|
||||
这是一个 Node.js 实现的 Model Context Protocol (MCP) 服务器,专门用于与 GitLab 交互。主要功能包括创建和合并 Merge Request,获取 MR 详情以及关闭 MR。项目基于 `@modelcontextprotocol/sdk` 实现 MCP 规范,并提供了一组工具供外部客户端调用。
|
||||
|
||||
## Project Structure
|
||||
- `index.js`: Main server implementation containing tool registrations and server startup logic
|
||||
- `package.json`: Project metadata and dependencies
|
||||
- `package-lock.json`: Dependency lock file
|
||||
- `node_modules/`: Project dependencies
|
||||
## 项目结构
|
||||
- `gitlab-index.js`: GitLab 专用的 MCP 服务器实现,包含所有 GitLab 相关的工具
|
||||
- `index.js`: 原始的通用 MCP 服务器示例实现(包含打招呼工具)
|
||||
- `package.json`: 项目依赖和脚本配置
|
||||
- `package-lock.json`: 依赖版本锁定文件
|
||||
- `README.md`: 项目说明文档
|
||||
- `test.js`: 测试文件
|
||||
- `.git/`: Git 版本控制目录
|
||||
- `.qwen/`: Qwen 工作空间配置目录
|
||||
- `node_modules/`: 项目依赖包目录
|
||||
|
||||
## Key Dependencies
|
||||
- `@modelcontextprotocol/sdk`: Core SDK for MCP implementation
|
||||
- `zod`: For runtime type checking and validation of tool parameters
|
||||
## 核心依赖
|
||||
- `@modelcontextprotocol/sdk`: 核心 MCP SDK,用于实现协议规范
|
||||
- `zod`: 用于运行时类型检查和验证工具参数
|
||||
- `@modelcontextprotocol/inspector`: 用于开发和调试 MCP 服务器的开发工具
|
||||
|
||||
## Architecture
|
||||
The server implements the Model Context Protocol and registers two tools:
|
||||
1. `say_hello`: A simple greeting tool that takes a name and returns a personalized greeting
|
||||
2. `get_weather`: A weather information tool that fetches current weather data for a given city using WeatherAPI
|
||||
## 架构设计
|
||||
该项目采用模块化设计,使用一个封装的 `gitlabApiClient` 对象处理所有与 GitLab API 的交互。API 客户端包含以下方法:
|
||||
- `createMergeRequest`: 创建 Merge Request
|
||||
- `mergeMergeRequest`: 合并 Merge Request
|
||||
- `getMergeRequest`: 获取 Merge Request 详情
|
||||
- `closeMergeRequest`: 关闭 Merge Request
|
||||
|
||||
## Building and Running
|
||||
- To run the server: `node index.js`
|
||||
- The server uses stdio transport for communication with clients
|
||||
- For the weather tool to work, a `WEATHER_API_KEY` environment variable must be set
|
||||
服务器实现通过 `server.registerTool` 方法注册不同的工具,每个工具都使用 Zod 定义了严格的输入参数模式和验证规则。所有工具通过标准输入/输出(stdio)与客户端通信。
|
||||
|
||||
## Development Conventions
|
||||
- Uses ES modules (indicated by "type": "module" in package.json)
|
||||
- Implements async/await for handling asynchronous operations
|
||||
- Uses Zod for parameter validation
|
||||
- Includes proper error handling for robust operation
|
||||
- Logs important messages to stderr to separate them from data output
|
||||
- Follows MCP specification for return value formatting
|
||||
## 功能工具
|
||||
1. `create_merge_request`: 在指定的 GitLab 项目中创建一个新的 Merge Request
|
||||
2. `merge_merge_request`: 合并指定的 GitLab Merge Request
|
||||
3. `get_merge_request`: 获取指定 Merge Request 的详细信息
|
||||
4. `close_merge_request`: 关闭指定的 GitLab Merge Request 而不合并
|
||||
|
||||
## Configuration
|
||||
The weather tool requires a `WEATHER_API_KEY` environment variable to be set to access the weather API service.
|
||||
## 构建和运行
|
||||
- 要启动 GitLab 专用的 MCP 服务器:`npm run gitlab`
|
||||
- 要启动原始示例服务器:`npm start`
|
||||
- 开发模式运行:`npm run dev`
|
||||
|
||||
## Purpose
|
||||
This project serves as an example MCP server implementation that demonstrates how to register and implement tools that can be called by MCP-compatible clients. It's designed to be extensible for adding more tools as needed.
|
||||
服务器需要通过设置 `GITLAB_ACCESS_TOKEN` 环境变量来配置 GitLab 访问令牌,并可选择性地设置 `GITLAB_API_BASE_URL` 以支持自托管的 GitLab 实例。
|
||||
|
||||
## 开发约定
|
||||
- 使用 ES 模块(由 package.json 中 "type": "module" 指定)
|
||||
- 实现 async/await 处理异步操作
|
||||
- 使用 Zod 进行参数验证
|
||||
- 包含适当的错误处理机制
|
||||
- 将日志输出到 stderr 以与数据输出分离
|
||||
- 遵循 MCP 规范的返回值格式
|
||||
|
||||
Always respond in 中文
|
||||
## 项目目的
|
||||
该项目提供了一个 GitLab 的 MCP 服务器实现,展示了如何使用 Model Context Protocol 创建可扩展的工具服务器。它可以作为基础,用于实现更多 GitLab 相关的自动化操作功能。
|
||||
Reference in new issue
Block a user