gitlab-mcp-code-review: Instructions file for Claude Code

CLAUDE.md

gitlab-mcp-code-review CLAUDE.md is an instructions file for Claude Code from ffpy/gitlab-mcp-code-review. It costs 1,145 tokens per session, scanned A, original, MIT.

An MCP server that connects an AI assistant to GitLab merge requests, which are proposed code changes awaiting review. It can retrieve changes and manage comments, discussions, approvals, and review rules.

In plain words
What is it for?
Use it to inspect merge requests, compare branches or commits, add or resolve review discussions, approve changes, search projects, or fetch team review rules.
Why use it?
It removes the need to switch between an assistant and GitLab while reviewing and discussing code changes.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md; mentions Claude Code.

This is ffpy/gitlab-mcp-code-review's own configuration. It tells Claude Code how to work on gitlab-mcp-code-review itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything gitlab-mcp-code-review configures →

Reuse

Borrowing it

Nothing to install: this file belongs to ffpy/gitlab-mcp-code-review. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/ffpy/gitlab-mcp-code-review/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/ffpy/gitlab-mcp-code-review

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for gitlab-mcp-code-review CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/ffpy/gitlab-mcp-code-review/claude-md/github.svg)](https://agentmods.dev/instructions/ffpy/gitlab-mcp-code-review/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/ffpy/gitlab-mcp-code-review/claude-md"><img src="https://agentmods.dev/badge/instructions/ffpy/gitlab-mcp-code-review/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for gitlab-mcp-code-review CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/ffpy/gitlab-mcp-code-review/claude-md"><img src="https://agentmods.dev/badge/instructions/ffpy/gitlab-mcp-code-review/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,145 This file is loaded in full into every session.
When invoked 1,145 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01145 $0.01145
Opus 5.5 $0.00458 $0.00458
Sonnet 5.5 $0.00229 $0.00229
Haiku 4.5 $0.00114 $0.00114

Measured 2mo ago against content hash ebaede9ff504, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

gitlab-mcp-code-review CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 102 lines

How it starts

The opening of the file, as written. The whole thing — 102 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

项目概述

这是一个 MCP (Model Context Protocol) 服务器,用于将 AI 助手与 GitLab 的合并请求集成。它允许 AI 助手通过 GitLab API 直接审查代码变更、添加评论和管理审批流程。

核心架构

主要文件

  • server.py: MCP 服务器的主入口文件,包含所有工具定义和 GitLab API 集成逻辑
  • config.toml: 配置文件,定义代码审查时需要忽略的文件模式
  • pyproject.toml: Python 项目配置,包含依赖和工具配置

关键组件

  1. FastMCP 服务器: 使用 mcp.server.fastmcp.FastMCP 创建 MCP 服务器
  2. GitLab 客户端: 通过 python-gitlab 库与 GitLab API 交互
  3. 生命周期管理: 使用 gitlab_lifespan 异步上下文管理器管理 GitLab 连接

MCP 工具列表

服务器暴露以下工具(位于 server.py):

  • fetch_merge_request: 获取合并请求的完整信息(包括变更、提交和讨论)
  • compare_versions: 比较两个提交/分支/标签之间的差异
  • add_merge_request_comment: 添加常规评论到合并请求
  • add_merge_request_discussion: 在文件特定位置添加讨论
  • reply_to_merge_request_discussion: 回复讨论
  • resolve_merge_request_discussion: 解决或取消解决讨论
  • delete_merge_request_discussion: 删除讨论
  • approve_merge_request: 批准合并请求
  • unapprove_merge_request: 取消批准合并请求
  • get_project_merge_requests: 获取项目的合并请求列表
  • search_projects: 按名称搜索 GitLab 项目
  • fetch_code_review_rules: 通过 SSH 从远程服务器获取团队的代码审查规范

数据过滤机制

fetch_merge_request 工具实现了智能数据过滤:

  • 使用 config.toml 中的 exclude_patterns 过滤不需要审查的文件
  • 精简 API 响应数据,只返回必要字段,减少 token 使用
  • 支持通配符模式和目录模式匹配(见 is_path_excluded 函数)

环境变量

必需的环境变量(可以在 .env 文件中设置):

  • GITLAB_HOST: GitLab 实例的主机名(默认: gitlab.com)
  • GITLAB_TOKEN: GitLab 个人访问令牌(必需,需要 api 和 read_api 权限)

可选的环境变量(用于代码审查规范功能):

  • CODE_REVIEW_SSH_HOST: SSH 服务器地址
  • CODE_REVIEW_SSH_PORT: SSH 端口(默认: 22)
  • CODE_REVIEW_SSH_USERNAME: SSH 用户名
  • CODE_REVIEW_SSH_PASSWORD: SSH 密码
  • CODE_REVIEW_RULE_FILE: 规范文件在服务器上的绝对路径

常用命令

运行服务器

uv run server.py

安装依赖

uv sync

开发依赖(可选)

uv sync --extra dev

修改代码时的注意事项

  1. 添加新的 MCP 工具: 使用 @mcp.tool() 装饰器,第一个参数必须是 ctx: Context
  2. 访问 GitLab 客户端: 通过 ctx.request_context.lifespan_context 获取 GitLab 客户端实例
  3. 数据精简: 当从 GitLab API 获取数据时,应该只返回必要的字段以减少响应大小
  4. 文件过滤: 修改 config.toml 中的 exclude_patterns 来调整忽略的文件类型
  5. 错误处理: 使用 logger 记录错误,遵循现有的日志模式
  6. 返回类型: 所有工具函数都应该返回可序列化的 Dict 或 List

Read the full file on GitHub · 102 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 102 lines · 1,145 tokens per session scan A ebaede9ff504

Subscribe to this mod's changes

gitlab-mcp-code-review CLAUDE.md is an instructions file published in the GitHub repository ffpy/gitlab-mcp-code-review (4 stars, last pushed 11mo ago), licensed MIT. It adds 1,145 tokens to every session, about $0.0046 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 9,715 tokens

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,461 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, cache eligibility and rollout and applying the notice (cutover).

microsoft/vscode · 5,262 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,680 tokens

vscode copilot-instructions.md

Copilot instructions for microsoft/vscode, covering vs code copilot instructions, project overview, root folders, core architecture (src/ folder) and built-in extensions (extensions/ folder).

microsoft/vscode · 2,750 tokens

deepseek-harness AGENTS.md

AGENTS.md instructions for deepseek-ai/deepseek-harness, covering agents.md, pre-stable apis and released session data, repository layout, commands and host sandbox failures.

deepseek-ai/deepseek-harness · 4,261 tokens