灰尘.tt↔ GitLab MCP服务器
通过以下方式将Dust.tt AI代理连接到您的GitLab项目 98工具 全面的GitLab操作。使用自然语言查询问题、合并请求、文件、管道、wiki、里程碑等。
由...驱动 @zereight/mcp-gitlab -社区维护的GitLab MCP服务器,功能增强。快速设置(5分钟)
1.获取GitLab个人访问令牌
- 首选 GitLab→ 设置→ 访问令牌
- 点击 添加新令牌
- 姓名:
dust-mcp-server - 选择范围:
- ✅ api (API完全访问) - ✅ read_repository (读取文件)
- 点击 创建 并复制令牌(以开头
glpat-)
2.部署到铁路
Railway提供免费托管,没有超时限制(非常适合SSE连接)。
- 分叉此存储库 转到您的GitHub帐户
- 部署到铁路:
- 首选 railway应用程序 - 点击 新项目 → 从GitHub仓库部署 - 选择您的分叉 dust_gitlab 仓库 - 铁路将自动检测和部署
- 添加环境变量 在铁路仪表板中:
GITLAB_PERSONAL_ACCESS_TOKEN=glpat-xxxxxxxxxxxxx
GITLAB_API_URL=https://gitlab.com/api/v4
MCP_AUTH_SECRET=your-random-secret-here
NODE_ENV=production> 💡 对于 MCP_AUTH_SECRET,使用随机字符串(例如,来自 openssl rand -base64 32)
- 获取您的服务器URL:
- 铁路设置→ 网络→ 生成域 - 复制URL: https://your-project.up.railway.app
- 验证部署:
curl https://your-project.up.railway.app/health应返回: {"status":"ok","service":"dust-gitlab-mcp",...}
3.连接到Dust.tt
- 打开 灰尘.tt → 空间 → 工具 → 添加工具
- 选择 远程MCP服务器
- 配置:
- 名字: GitLab - 统一资源定位符: https://your-project.up.railway.app/sse - 身份验证类型: Bearer Token - 代币:您的 MCP_AUTH_SECRET 价值
- 点击 测试连接 (应在~5秒内成功)
- 点击 保存
4.测试一下!
在防尘剂中,尝试:
- “列出我的GitLab项目”
- “显示项目X中的未决问题”
- “从项目Y获取README”
- “Z项目最近提交了什么?”
可用的GitLab工具(98个工具)
此服务器使用 @zereight/mcp-gitlab 它提供 98工具 -明显多于官方的~40种工具。
核心工具(始终可用)
| 类别 | 工具 |
|---|---|
| 仓库 | get_file_contents, create_or_update_file, push_files, search_repositories, create_repository, fork_repository, create_branch, list_repository_tree |
| 问题 | create_issue, list_issues, get_issue, update_issue, create_issue_note, list_issue_links |
| 合并请求 | create_merge_request, list_merge_requests, get_merge_request, update_merge_request, merge_merge_request, list_merge_request_diffs |
| 用户和组 | get_user, list_project_members, list_group_members, get_project, list_projects |
| 提交 | list_commits, get_commit, list_commit_diffs |
| 分支和标签 | list_branches, get_branch, delete_branch, list_tags |
可选功能模块
通过环境变量为其他工具启用这些功能:
| 功能 | 环境变量 | 添加的工具 |
|---|---|---|
| 维基 | USE_GITLAB_WIKI=true | list_wiki_pages, get_wiki_page, create_wiki_page, update_wiki_page, delete_wiki_page |
| 管道 | USE_PIPELINE=true | list_pipelines, get_pipeline, create_pipeline, cancel_pipeline, retry_pipeline, list_jobs, get_job_log |
| 里程碑 | USE_MILESTONE=true | list_milestones, get_milestone, create_milestone, update_milestone, list_milestone_issues |
安全特性
| 特征 | 环境变量 | 描述 |
|---|---|---|
| 只读模式 | GITLAB_READ_ONLY_MODE=true | 禁用所有写入操作-适用于受限访问场景 |
✅ 现在支持目录列表!
与官方服务器不同, @zereight/mcp-gitlab 支持目录列表:
- ✅
list_repository_tree-浏览存储库文件结构 - ✅ 浏览目录并发现文件
- ✅ 完整的存储库探索
本地开发
想在部署前进行本地测试吗?
# Clone and install
git clone https://github.com/YourUsername/dust_gitlab.git
cd dust_gitlab
npm install
# Create .env file
cp .env.example .env
# Edit .env and add your credentials
# Run locally
npm run dev
# Server starts at http://localhost:3000
# Test
curl http://localhost:3000/health运作原理
┌─────────┐ HTTPS/SSE ┌─────────┐ stdio ┌──────────────┐
│ Dust.tt │ ←────────────→ │ Railway │ ←────────→ │ GitLab MCP │
└─────────┘ └─────────┘ │ Server │
└──────────────┘
↓
┌──────────────┐
│ GitLab API │
└──────────────┘此服务器连接社区 @zereight/mcp-gitlab MCP服务器(基于stdio)到Dust.tt所需的HTTP/SSE传输。zereight软件包提供98个工具,而官方服务器提供了约40个工具,并具有Wiki、Pipeline和Milestone管理等附加功能。
故障排除
连接问题
“身份验证失败”
- 验证您的GitLab令牌是否有效且未过期
- 检查令牌已
api和read_repository范围 - 测试令牌:
curl -H "PRIVATE-TOKEN: glpat-xxx" https://gitlab.com/api/v4/user
“连接超时”
- 确保您使用的是Railway(不是Vercel免费等级,有10秒的限制)
- 检查铁路日志是否有错误
“未发现工具”
- 确保SSE端点URL正确:
https://your-project.up.railway.app/sse - 验证Bearer令牌是否与您的匹配
MCP_AUTH_SECRET - 检查铁路日志中的连接错误
工具执行错误
“GitLab API错误:找不到”(404)
这意味着GitLab API找不到您所要求的内容。常见原因:
- 项目路径/ID或参数名称错误
- ✅ 对的: project_id: "group/project-name" 或 project_id: "12345678" - ❌ 错误: project-name (缺失组), group/repo (错误名称), project: "..." (参数名称错误) - 修复:转到您的GitLab项目→ 设置→ 将军→ 复制完整路径 - 备注:参数必须命名 project_id (包装器将自动修复 project 如果使用)
- 文件不存在
- ✅ 对的: README.md, src/index.ts - ❌ 错误: readme.md (错误情况), /src/index.ts (前斜线) - 修复:在GitLab中浏览项目,复制确切的文件路径
- 分支错误
- 默认分支通常为 main 或 master - 修复:在GitLab中检查项目的默认分支
- 无法访问项目
- 您的GitLab令牌只能访问您所属的项目 - 修复:确保你是项目/小组的成员
有效工具调用示例:
Tool: get_file_contents
Inputs:
- project_id: "mygroup/myproject" (or numeric ID: "12345678")
- file_path: "README.md"
- ref: "main" (optional, defaults to default branch)备注:参数被调用 project_id (不是 project).如果您使用,包装器将自动修复 project 相反。
调试提示:
- 检查铁路日志,查看发送的确切参数
- 直接测试GitLab API:
curl -H "PRIVATE-TOKEN: glpat-xxx" https://gitlab.com/api/v4/projects/group%2Fproject - 验证项目ID:
curl -H "PRIVATE-TOKEN: glpat-xxx" https://gitlab.com/api/v4/projects/group%2Fproject | jq .id
“GitLab API错误:未经授权”(401)
- GitLab令牌无效或已过期
- 令牌没有所需的作用域(
api,read_repository) - 修复:使用正确的作用域重新生成令牌
“GitLab API错误:禁止”(403)
- 令牌有效,但没有此操作的权限
- 修复:检查项目成员资格和权限
项目结构
dust_gitlab/
├── src/
│ ├── index.ts # HTTP/SSE server
│ └── mcp-wrapper.ts # stdio-to-SSE bridge
├── .env.example # Environment template
├── package.json # Dependencies
├── railway.json # Railway deployment config
└── tsconfig.json # TypeScript config安全
- 🔒 在Railway环境变量中加密的GitLab令牌
- 🔑 Dust.tt请求的承载令牌身份验证
- 🚀 仅HTTPS(铁路自动提供SSL)
- 👤 令牌范围为您的GitLab帐户权限
包装比较
此项目使用 @zereight/mcp-gitlab 而不是官方服务器。原因如下:
| 专题 | 官方(@modelcontextprotocol/server-gitlab) | 本项目(@zereight/mcp-gitlab) |
|---|---|---|
| 工具 | ~40 | 98 |
| 目录列表 | ❌ | ✅ list_repository_tree |
| 维基API | ❌ | ✅ (可选) |
| 管道管理 | ❌ | ✅ (可选) |
| 里程碑跟踪 | ❌ | ✅ (可选) |
| 速率限制 | ❌ | ✅ 内置 |
| 连接池 | ❌ | ✅ |
| 只读模式 | ❌ | ✅ |
| 本机HTTP/SSE | ❌ | ✅ (未使用-我们使用包装器) |
启用可选功能
要启用其他工具,请在Railway中设置环境变量:
# Enable Wiki tools
USE_GITLAB_WIKI=true
# Enable Pipeline management
USE_PIPELINE=true
# Enable Milestone tracking
USE_MILESTONE=true
# Restrict to read-only operations
GITLAB_READ_ONLY_MODE=true更改环境变量后,Railway将自动重新部署。
支持
- 📖 模型上下文协议文档
- 🔧 zereight/mcp gitlab来源
- 📦
- 💬 打开一个bug或问题的问题
许可证
麻省理工学院
