Skip to main content
Glama
AlanNiew

code-review-mcp

by AlanNiew

ai-code-review-mcp

面向 AI 编码助手的变更驱动代码审查引擎:MCP 服务器 + 配套 Skill。

它不是又一个 linter 报告生成器。review_changes 把一个 git 变更(分支、PR、未提交改动)变成一份审查证据包——改了哪些文件、哪些位置风险最高、新增行上有哪些规则命中、复杂度是否退化、依赖/迁移/接口/测试是否被动过——再由 skill 里的审查协议把它变成按影响排序、可落到 path:line、并声明覆盖范围的审查意见。

PyPI: https://pypi.org/project/ai-code-review-mcp/ GitHub: https://github.com/AlanNiew/code-review-mcp

设计原则

  1. 审变更,不审整个文件。 全文件扫描会把你早已存在的历史问题一起倒出来,淹没真正的新缺陷。

  2. 工具只给事实,不给结论。 工具输出 findings / signals / deltas;是否构成问题、什么级别,由审查者判断并验证。

  3. 输出有界。 默认每文件最多 10 条命中、整体最多 80 条、焦点最多 12 条,并用 limits 说明哪些被跳过或截断。

  4. 静态命中是线索。 每条 finding 带 confidence,误报(尤其测试夹具里的假密钥)由审查者排除。

  5. 诚实优先。 报告必须写明"没审什么",而不是假装全覆盖。

  6. 用自己审查自己。 v0.3.0 的改动本身由 review_changes 审过:初版旗舰文件被自己的复杂度规则命中,按发现拆函数后 findings 归零;唯一保留的参数个数提示用行级豁免标注并写明理由。

Related MCP server: code-review-mcp-server

特性

  • review_changes(旗舰) — 采集 working / staged / base...HEAD 三种范围的变更,产出结构化证据包

  • 只报新增行 — 命中过滤到 diff 新增行,历史问题不混入本次审查

  • 文件级风险信号 — tests_missing(改了 10+ 行却没有对应测试)、protection_bypass(# type: ignore / noqa / @ts-ignore / --no-verify 等)、large_file_change、deleted_test_assertions

  • 变更级信号 — 新增依赖、数据库迁移、CI/构建、API 契约(OpenAPI/proto/graphql)、测试变更、密钥(SEC005)/ 其他安全类 error、配置变更

  • 复杂度回归检测 — Python 变更文件的函数级圈复杂度与长度 before/after 对比

  • 审查焦点 — 把 error 级命中、高风险信号、复杂度回归聚合成 focus,优先深审

  • 22 条规则 — 12 条安全规则(SEC001-012)+ 5 条复杂度(COMPLEX001-005)+ 5 条风格(STYLE001-005)

  • 阈值真正可配置 — .code-review.yml 里的 thresholds 现在会真正传入规则引擎

  • 行级豁免 — # codereview: ignore / # codereview: ignore=SEC005

  • 多语言 — Python AST 深度分析;JS/TS/Java/Go/Rust 等 12 种语言的通用检查

  • 配套 Skill — 一套可执行的审查协议:定范围 → 读证据 → 读上下文 → 维度检查 → 验证门槛 → 定级报告

  • 零外部依赖 — 仅 mcp;YAML 配置可选装 PyYAML

安装

pip install ai-code-review-mcp

要求 Python 3.10+。

OpenCode(推荐)

在项目根目录的 opencode.json 中启用 MCP:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "code-review-mcp": {
      "type": "local",
      "command": ["ai-code-review-mcp"],
      "enabled": true
    }
  }
}

安装配套 Skill(把审查协议交给模型):

# 项目级
mkdir -p .opencode/skills/code-review
curl -o .opencode/skills/code-review/SKILL.md https://raw.githubusercontent.com/AlanNiew/code-review-mcp/main/skill/SKILL.md

# 全局级
mkdir -p ~/.config/opencode/skills/code-review
curl -o ~/.config/opencode/skills/code-review/SKILL.md https://raw.githubusercontent.com/AlanNiew/code-review-mcp/main/skill/SKILL.md

Windows PowerShell:

New-Item -ItemType Directory -Path ".opencode\skills\code-review" -Force
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/AlanNiew/code-review-mcp/main/skill/SKILL.md" -OutFile ".opencode\skills\code-review\SKILL.md"

装好后直接说:

审查一下我这个分支相对 main 的改动
审查已暂存的变更
帮我看看这个 PR

Claude Desktop / Cursor

{
  "mcpServers": {
    "code-review-mcp": {
      "command": "ai-code-review-mcp"
    }
  }
}

Cursor:Settings → MCP → 新增 command 类型服务器,命令 ai-code-review-mcp。

uvx(免安装)

{
  "mcp": {
    "code-review-mcp": {
      "type": "local",
      "command": ["uvx", "ai-code-review-mcp"],
      "enabled": true
    }
  }
}

从源码

git clone https://github.com/AlanNiew/code-review-mcp.git
cd code-review-mcp
pip install -e ".[dev]"
{
  "mcp": {
    "code-review-mcp": {
      "type": "local",
      "command": ["python", "-m", "code_review_mcp.server"],
      "enabled": true
    }
  }
}

工具

1. review_changes — 变更审查证据包(v0.3.0)

review_changes(scope="working", base=None, directory=".")

directory 可以是仓库内任意子目录:此时只审该子目录下的变更(会自动取仓库根做 diff,再按子目录过滤),不会静默扩大到整仓。目录不存在或不是目录时返回明确的 error,而不是误报"git 不可用"。

scope

含义

working(默认)

未提交的全部改动:未暂存 + 已暂存 + 未跟踪文件(含源码与配置)

staged

只审已暂存(git add 过的)

base

审 base...HEAD,用 git merge-base 取三点差异;base 必填,如 "main"

返回结构(省略部分字段):

{
  "scope": "base",
  "range": "main...HEAD",
  "base_commit": "a1b2c3d",
  "head_commit": "e4f5g6h",
  "stats": {"files": 5, "additions": 120, "deletions": 30,
            "by_status": {"modified": 3, "added": 1, "deleted": 1},
            "languages": {"python": 4, "typescript": 1}},
  "files": [
    {
      "path": "src/auth/session.py",
      "status": "modified",
      "additions": 20, "deletions": 4, "language": "python",
      "priority": "high",
      "signals": ["tests_missing", "protection_bypass"],
      "findings": [
        {"rule": "SEC005", "severity": "error", "category": "security",
         "line": 42, "confidence": "medium",
         "message": "可能的硬编码密钥: token"}
      ],
      "function_deltas": [
        {"name": "Session.verify", "line": 12,
         "complexity_before": 6, "complexity_after": 11,
         "length_before": 30, "length_after": 55}
      ]
    }
  ],
  "signals": [
    {"kind": "dependency_added", "path": "requirements.txt",
     "line": 7, "detail": "pyyaml==6.0", "priority": "high"}
  ],
  "focus": [
    "src/auth/session.py:42 — SEC005 hardcoded-secret (error)",
    "src/auth/session.py:12 — complexity 6→11 in Session.verify"
  ],
  "limits": {"skipped": [{"path": "logo.png", "reason": "binary"}],
             "truncated": false, "notes": []}
}

priority 规则:有 error 命中 / 有 high 级 signal / 复杂度增长 ≥5 为 high;有 warning、或 tests_missing / protection_bypass / large_file_change、或有复杂度/长度增长为 medium;其余 low。

signals[].kind 取值:dependency_added、database_schema、ci_or_build、api_contract、test_change、secret_added(只有硬编码密钥规则 SEC005)、security_finding(其他安全类 error,如 eval / pickle / shell 注入)、large_change、config_change。

文件级 signals 的判定:

  • tests_missing:源码文件新增 ≥10 行、仓库里找不到对应测试,且本次变更集没有改动任何会被审查的测试文件(已经动过测试就不再逐文件断言"缺测试";被 .gitignore / ignore_paths 排除的测试文件不算)。

  • protection_bypass:新增行出现 # type: ignore / noqa / @ts-ignore / pytest.mark.skip / --no-verify 等审查规避标记。只对生产源码判定:测试文件不算(测试里 skip / type: ignore 是常规操作),文档和配置里提到这些字样也不算;Python 只认真正的注释行,字符串字面量里出现不算。最多标注 3 个文件,超出部分在 limits.notes 说明并置 truncated。

  • large_file_change:单文件新增 >400 行。

  • deleted_test_assertions:删除的是测试文件,或删掉的行里含断言。

变更审查只保留新增行上的规则命中;测试文件不报 COMPLEX* 复杂度命中——测试天然长、分支多,这类提示在审查里只是噪声。function_deltas 里的"长度回归"要求函数至少多出 10 行、且超过原长度 1.5 倍,避免小函数轻微变长就上报。

怎么用:先看 focus 和 priority=high 的文件,再按 signals 决定是否要读迁移/依赖/接口定义,最后回源码逐条验证。工具结果不是结论。

2. analyze_file — 单文件分析

analyze_file(file_path="src/main.py")

返回语言、代码/注释/空白行数、规则命中列表、多维评分(overall / security / maintainability,A-F)。用于单文件深挖,或非 git 仓库场景。

3. check_project — 项目概况

check_project(directory=".")

扫描项目内所有支持的语言文件,汇总文件数、行数、语言分布、问题最多的前 10 个文件、整体评分。用于不熟悉的仓库摸底,不是审查结论。

4. list_rules — 规则清单

返回所有规则的 ID、名称、描述、类别、默认严重级别、适用语言。用于向用户解释某条规则命中的含义。

5. review_diff — 已弃用

保留为兼容 shim,行为与 v0.2.x 一致(staged + unstaged 的 DIFF001-004 检查)。新代码请用 review_changes。

规则参考

安全规则(SEC001-SEC012,Python AST)

借鉴 bandit 的 AST 节点分发模式。

规则 ID

名称

严重级别

检测目标

SEC001

eval-exec

🔴 error

eval() / exec() 任意代码执行

SEC002

shell-injection

🔴 error

subprocess(shell=True) / os.system 命令注入

SEC003

unsafe-deserialize

🔴 error

pickle.loads / yaml.load 不安全反序列化

SEC004

weak-hash

🟡 warning

hashlib.md5 / sha1 弱哈希

SEC005

hardcoded-secret

🔴 error

硬编码密码 / API Key(含注解赋值与关键字参数)

SEC006

ssl-verify-false

🔴 error

requests(verify=False) 关闭 SSL 校验

SEC007

bare-except

🟡 warning

bare except / except: pass 吞异常

SEC008

sql-injection

🟡 warning

SQL 字符串拼接

SEC009

assert-in-production

🔵 info

生产代码中的 assert

SEC010

flask-debug

🔴 error

Flask debug=True

SEC011

jwt-no-verify

🔴 error

JWT 关闭签名校验

SEC012

weak-random

🟡 warning

安全场景使用 random 而非 secrets

复杂度规则(COMPLEX001-005)

规则 ID

名称

严重级别

默认阈值

COMPLEX001

function-too-long

🟡 warning

函数 > 50 行

COMPLEX002

cyclomatic-complexity

🟡 warning

圈复杂度 > 10

COMPLEX003

cognitive-complexity

🟡 warning

认知复杂度 > 15(SonarSource 白皮书)

COMPLEX004

too-many-params

🔵 info

参数 > 5 个

COMPLEX005

nesting-too-deep

🟡 warning

嵌套 > 4 层

风格规则(STYLE001-005)

规则 ID

名称

严重级别

检测目标

STYLE001

line-too-long

🟡 warning

单行 > 120 字符

STYLE002

todo-comment

🔵 info

注释中的 TODO/FIXME/HACK/XXX

STYLE003

trailing-whitespace

🔵 info

行末空白字符

STYLE004

debug-print

🔵 info

Python print 调试残留

STYLE005

console-log

🔵 info

JS/TS console.log 调试残留

配置

在项目根目录创建 .code-review.yml、.code-review.yaml 或 .code-review.json。 (YAML 需要 pip install ai-code-review-mcp[yaml])

{
  "rules": {
    "security": { "enabled": true },
    "complexity": { "enabled": true },
    "style": { "enabled": true }
  },
  "thresholds": {
    "max_function_length": 80,
    "max_cognitive_complexity": 20,
    "max_line_length": 100
  },
  "ignore_paths": ["tests/*", "vendor/", "migrations/", "*_pb2.py"],
  "severity_overrides": { "SEC009": "warning" }
}

字段

类型

说明

rules.<category>.enabled

bool

关闭整类规则

thresholds.<key>

int

自定义阈值,v0.3.0 起真正生效

ignore_paths

list

路径忽略(fnmatch glob + 目录前缀);review_changes 同样遵守

severity_overrides

dict

覆盖单条规则的默认严重级别

可用阈值键:max_function_length、max_cyclomatic_complexity、max_cognitive_complexity、max_param_count、max_line_length、max_nesting_depth。

查找顺序:CODE_REVIEW_CONFIG 环境变量 → 从当前目录向上查找 .code-review.*(遇 .git 停)→ 内置默认。

行级豁免

# 豁免当前行所有规则
token = "hardcoded-for-dev-only-1234567890"  # codereview: ignore

# 只豁免指定规则
password = "test1234"  # codereview: ignore=SEC005

标记大小写不敏感,可出现在行内任意位置。

评分说明

analyze_file / check_project 仍返回 A-F 评分,用于快速了解文件/项目健康度:

维度

包含类别

overall

全部 issue

security

security

maintainability

complexity / style / debug_code / duplication

扣分权重:error 10 分、warning 3 分、info 0.5 分,基础 100,扣完为止;A ≥ 90、B ≥ 80、C ≥ 70、D ≥ 60、其余 F。

评分是健康度参考,不是审查结论。 审查结论来自 review_changes 证据 + skill 里的验证与定级流程。

审查协议(skill/SKILL.md)

配套 Skill 不是报告模板,而是一套审查协议:

  1. 定范围 — 明确是 working / staged / 哪个 base,把范围写进报告

  2. 读证据 — 按 focus → high 文件 → signals → limits 的顺序读 packet

  3. 读上下文 — 必须打开源码看改动周围的逻辑、调用方、类型、测试

  4. 维度检查 — 意图完整性 / 正确性 / 错误路径 / 安全 / 并发资源 / 数据兼容 / 性能 / 测试 / 可观测性 / 依赖 / 风格

  5. 验证门槛 — 每条候选必须说清触发条件、影响、为什么别处拦不住、是否本次引入;答不全就降级为"待确认"或丢弃

  6. 定级报告 — 阻塞 / 重要 / 次要,默认最多 8 条;附"已检查未发现问题"与"覆盖范围"

支持的语言

语言

文件分析

复杂度分析

Python (.py)

✅

✅ AST 深度分析

JavaScript (.js/.jsx)

✅

通用检查

TypeScript (.ts/.tsx)

✅

通用检查

Java (.java)

✅

通用检查

Go (.go)

✅

通用检查

Rust (.rs)

✅

通用检查

C/C++ (.c/.cpp/.h)

✅

通用检查

Ruby (.rb)

✅

通用检查

PHP (.php)

✅

通用检查

Swift (.swift)

✅

通用检查

Kotlin (.kt)

✅

通用检查

Scala (.scala)

✅

通用检查

项目结构

code-review-mcp/
├── pyproject.toml
├── README.md
├── CHANGELOG.md
├── .github/workflows/           # CI(多版本矩阵 + ruff + pytest)与 PyPI 发布
├── skill/
│   └── SKILL.md                 # 审查协议(OpenCode Skill)
├── tests/
│   ├── conftest.py
│   ├── test_security_rules.py   # SEC001-SEC012 正反例
│   ├── test_complexity.py       # 认知/圈复杂度算法 + 规则
│   ├── test_style_rules.py
│   ├── test_config.py           # 配置加载 + 行级豁免
│   ├── test_scoring.py
│   ├── test_engine_hardening.py # 阈值接线 + 算法修复回归
│   ├── test_change_analysis.py  # 变更证据引擎(临时 git 仓库)
│   └── test_tools.py            # MCP 工具端到端
└── src/code_review_mcp/
    ├── server.py                # MCP 入口(5 个工具)
    ├── models.py                # Issue / Severity / Category / Confidence
    ├── config.py                # 配置加载 + 行级豁免
    ├── scoring.py               # 多维评分
    ├── utils.py
    ├── analyzers/
    │   ├── context.py           # 规则运行入口
    │   ├── change.py            # 变更证据引擎(v0.3.0)
    │   ├── diff.py              # 旧版 diff 检查(review_diff 兼容)
    │   └── project.py           # 项目扫描
    └── rules/
        ├── base.py
        ├── registry.py
        ├── security.py
        ├── complexity.py
        └── style.py

常见问题

Q: 启动时报错 "command not found: ai-code-review-mcp"

确认 Python 的 Scripts 目录在 PATH 中:

pip show ai-code-review-mcp
where ai-code-review-mcp    # Windows
which ai-code-review-mcp    # macOS/Linux

Q: MCP 工具没有出现在 AI 助手中

  1. 确认配置文件路径正确

  2. 确认 ai-code-review-mcp 能在终端直接运行

  3. 重启 AI 助手应用

Q: review_changes 报不是 git 仓库 / 没有 commit

review_changes 依赖 git。非 git 仓库请对单文件用 analyze_file;空仓库(还没有 commit)只支持 working/staged,base 模式需要至少一个 commit。

Q: 为什么依赖锁在 mcp<2?

mcp 2.x 移除了 mcp.server.fastmcp(改名 MCPServer 且 API 有变更),当前代码基于 1.x 的 FastMCP 接口。安装时会自动选 1.x;迁移到 2.x 后会放开这个上限。若你手动把 mcp 升到 2.x,启动会报 ModuleNotFoundError: No module named 'mcp.server.fastmcp',回退到 mcp<2 即可。

Q: 只想用 MCP,不装 Skill 可以吗?

可以。Skill 是可选的:MCP 工具本身就能返回完整的变更证据包;Skill 的价值是让模型按审查协议验证、定级并如实报告覆盖范围。

Q: 工具报的命中一定是问题吗?

不一定。规则是启发式的,每条命中都带 confidence。测试夹具里的假密钥、确实需要 shell=True 的场景都可能命中。skill 的验证门槛要求逐条回源码确认。

License

MIT © AlanNiew

Available Tools

5 tools
analyze_fileA

分析单个文件的代码质量、复杂度和安全问题。

会运行所有适用的规则:

  • 安全规则(SEC001-SEC012):eval/exec、shell 注入、pickle、弱哈希、硬编码密钥、SSL 关闭等

  • 复杂度规则(COMPLEX001-005):函数长度、圈复杂度、认知复杂度、参数个数、嵌套深度

  • 风格规则(STYLE001-005):行长、TODO、末尾空白、Python print / JS console.log 调试残留

返回语言、代码/注释/空白行数、issues(含 rule id、severity、category、confidence、 suggestion)与多维评分(overall / security / maintainability,A-F)。 评分是文件健康度参考,不是审查结论。

Args: file_path: 要分析的文件路径(相对于项目根目录或绝对路径)

ParametersJSON Schema
NameRequiredDescriptionDefault
file_pathYes

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does well: it enumerates the exact rule families and IDs executed (SEC001-012, COMPLEX001-005, STYLE001-005), so the agent knows the analysis is automatic and non-configurable, and it adds the important caveat that scores are a health reference, not an audit verdict. It still does not state that the operation is read-only or how it behaves on very large/unsupported files.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the one-line purpose, then bulleted rule families, then the return payload and the scoring caveat — every block is scannable and earns its place. The rule-ID enumeration is the longest element but is useful signal rather than filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description must describe the return payload, and it does: language, code/comment/blank line counts, issues with rule id/severity/category/confidence/suggestion, and overall/security/maintainability grades A-F. It also frames the score's meaning, leaving nothing essential for correct invocation or result interpretation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema gives only a bare 'File Path' string with 0% description coverage, and the description compensates by specifying that the path may be relative to the project root or absolute. That is genuine added meaning beyond the schema, though no error behavior for invalid paths is described.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource ('分析单个文件') and immediately narrows scope to a single file, which distinguishes it from the project-wide sibling check_project and the diff-oriented review_diff/review_changes. An agent can identify this as the per-file static analysis tool without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Scope ('单个文件') plus 'runs all applicable rules automatically' implies when this tool applies versus a project-wide scan, but no sibling is named and no when-not condition or prerequisite is stated. Usage is inferable rather than explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

check_projectA

扫描项目目录的代码质量概况。

遍历项目下所有支持的源代码文件(Python/JS/TS/Java/Go/Rust 等), 对每个文件运行完整规则集,最后汇总:

  • 总文件数和总行数

  • 语言分布统计

  • 错误/警告/提示计数

  • 问题最多的前 10 个文件

  • 整体质量评分(A-F 等级)

适合在不熟悉的仓库里摸底,不要把它当审查结论。

Args: directory: 要扫描的项目目录路径,默认为当前目录

ParametersJSON Schema
NameRequiredDescriptionDefault
directoryNo.

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does well: it discloses that all supported source files are traversed, that the complete rule set runs per file, and exactly what the aggregation contains (counts, top-10 files, letter grade). It stops short of stating read-only safety, runtime cost on large repositories, or pagination/truncation behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose is front-loaded in the first line, followed by a tightly scoped bullet list of what the aggregate contains, then the usage caveat, then the argument. Every element earns its place and nothing is repeated from structured fields.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a one-parameter, read-only scan with no output schema and no annotations, the description is nearly self-sufficient: it explains both behavior and the shape of the return value in lieu of an output schema. It lacks only operational caveats such as expected runtime on large repos or handling of unreadable/unsupported files.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, and it does: it explains the single 'directory' parameter as the project directory to scan and states the default is the current directory. Only one parameter is required, and its meaning is fully covered, though path format/relative-vs-absolute semantics are not addressed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a concrete verb+resource: it scans a project directory and returns an aggregate code-quality overview (file/line counts, language distribution, severity counts, top-10 problem files, A-F grade). Its project-wide aggregate scope implicitly separates it from the per-file/per-change siblings (analyze_file, review_diff, review_changes), though no sibling is named explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It states a clear use case ('适合在不熟悉的仓库里摸底') and an explicit caution/kill-criterion ('不要把它当审查结论'), which steers the agent away from treating output as a review verdict. It does not name the alternative tools for when narrow, file-level, or diff-level analysis is needed.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_rulesA

列出所有已注册的代码审查规则,便于 AI 选择性调用。

返回每条规则的 ID、名称、描述、类别和默认严重级别。

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It clearly indicates this is a read-only listing operation and describes the return fields (ID, name, description, category, default severity). However, it does not disclose potential ordering, filtering, or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description consists of two concise sentences with the purpose front-loaded. Every word adds value, no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given zero parameters and no output schema, the description fully explains what the tool does and what it returns. It is complete for a simple listing tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are no parameters, and schema description coverage is 100% (vacuous). The description adds context about what the tool returns, but since there are no parameters, it is not deficient. The baseline of 3 is exceeded because the description still provides helpful output information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists all registered code review rules, using the verb '列出' (list) and resource '代码审查规则' (code review rules). It distinguishes from sibling tools (analyze_file, check_project, review_diff) which involve analysis or checking rather than listing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for AI selective calling but does not explicitly state when to use this tool versus alternatives or provide exclusions. Usage is implied as a prerequisite for selecting rules.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

review_changesA

审查一个 git 变更,返回「审查证据包」:改了哪些文件、风险在哪、新增行命中了什么。

这是本服务器的旗舰工具。它只返回事实,不返回审查结论——每一条 findings/signal 都需要审查者回到源码确认后再决定是否成立、什么级别。

Args: scope: 审查范围。 - "working"(默认):所有未提交改动 = 未暂存 + 已暂存 + 未跟踪文件(含源码与配置) - "staged":只审已暂存(git add 过的) - "base":审 base...HEAD(git merge-base 三点差异),必须同时给 base base: 基线分支/提交,如 "main"、"origin/main"、commit sha;仅 scope="base" 时使用 directory: 仓库目录(也可以是仓库内子目录,此时只审该子目录下的变更), 默认当前工作目录

返回: - scope / range / base_commit / head_commit - stats:文件数、增删行、按状态分组、语言分布 - files[]:每个变更文件含 path、status、additions、deletions、language、 priority(high/medium/low)、signals、findings(只含新增行命中,按行号排序)、 function_deltas(Python 函数圈复杂度/长度前后对比) - signals[]:变更级信号(dependency_added / database_schema / ci_or_build / api_contract / test_change / secret_added / security_finding / large_change / config_change);只有 SEC005(硬编码密钥)记为 secret_added,其余安全命中记为 security_finding - focus[]:按风险排序的深审入口(形如 "path:line — 描述") - limits:skipped(被跳过的文件及原因)、truncated、notes

使用顺序:focus → priority=high 的文件 → signals → limits。 需要看调用方、类型定义、测试时直接读文件;不要只凭本工具输出下结论。 非 git 仓库会返回 {"error", "hint"},单文件场景请改用 analyze_file。

ParametersJSON Schema
NameRequiredDescriptionDefault
baseNo
scopeNoworking
directoryNo.

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations the description carries the full burden, and it does substantial work: it discloses that output is facts-only and not review verdicts, that every finding needs source confirmation, that limits include skipped/truncated files, that non-git repos return an error+hint, and it defines signal classification (SEC005 vs security_finding). The one gap is that it never explicitly states the tool is read-only and has no side effects on the repository.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and organized into Args / Returns / usage-order blocks, so it is easy to scan. It is nonetheless long, and the Returns enumeration is dense; it earns most of its length because no output schema exists, but it could be slightly tighter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 3-param flagship tool with no annotations and no output schema, the description covers parameters, return structure, traversal order, error paths, and sibling routing. An agent has everything needed to call it correctly and interpret the result.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate fully and does: scope enumerates all three accepted values with precise meanings, base is documented with examples and gated to scope='base', and directory explains both the default (cwd) and the subdirectory-scoping behavior. This is more informative than the schema itself.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('审查一个 git 变更') and names the concrete deliverable ('审查证据包'), then enumerates exactly what that pack contains. It also distinguishes itself from a sibling by routing single-file work to analyze_file: '单文件场景请改用 analyze_file'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit defaults and selection conditions for each scope ('working' default = unstaged+staged+untracked, 'staged', 'base' requires base), plus an explicit alternative for the single-file case. It further specifies the recommended traversal order (focus → priority=high files → signals → limits) and the non-git-repo fallback.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

review_diffA

[已弃用] 审查当前 git 仓库中未提交的变更(staged + unstaged)。

保留仅为兼容 v0.2.x 调用方;新代码请使用 review_changes,它提供变更级信号、 只报新增行、复杂度回归与风险焦点,且覆盖 working/staged/base 三种范围。

本工具对 diff 新增行做以下检测(DIFF001-DIFF004):

  • 硬编码的密钥或密码(严重)

  • 遗留的 print/console.log 调试语句

  • 新增的 TODO/FIXME/HACK 标记

  • 过长的新增行

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does disclose scope (staged + unstaged) and the exact detection set DIFF001-DIFF004 with severity for secrets. It does not describe the return format or how findings are reported, which is a gap for a no-output-schema tool, but the behavioral profile is otherwise well covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the deprecation notice and migration path before the detection list, so the most decision-relevant fact is first. The bulleted detection rules are scannable, though the deprecation paragraph and rules list make it longer than strictly necessary.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-param, no-annotation, no-output-schema tool, the description covers purpose, deprecation status, migration target, and detection scope. The only notable omission is what the response looks like, which the agent must infer.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes zero parameters, so the baseline is 4 and the description does not need to explain any input. It correctly implies operation against the current repository context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (审查/review) and resource (当前 git 仓库中未提交的变更, staged + unstaged), and explicitly contrasts itself with the sibling review_changes. An agent can distinguish it from review_changes and analyze_file without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly marks itself deprecated for v0.2.x callers only and names review_changes as the replacement, with the concrete reasons (变更级信号, 只报新增行, 复杂度回归, working/staged/base 三种范围). When-to-use and when-not-to-use are both stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev0.3.1
    • Addedreview_changes
  2. 4 tool updatesv0.2.0
    • First observedanalyze_file
    • First observedcheck_project
    • First observedlist_rules
    • First observedreview_diff

TDQS

A4.2/5.0

Scored across 5 tools

Disambiguation3/5

review_changes and the deprecated review_diff substantially overlap, both auditing uncommitted git changes, so an agent could misselect despite the explicit deprecation note. analyze_file, check_project, and list_rules are clearly distinct from each other and from the review tools.

Naming Consistency5/5

All five tools follow a consistent snake_case verb_noun pattern (review_changes, analyze_file, review_diff, check_project, list_rules). No mixed conventions or vague verbs.

Tool Count4/5

Five tools is a well-scoped set for a code-review server covering diff review, single-file analysis, project scan, and rule discovery. The count is slightly inflated by one deprecated tool kept only for backward compatibility.

Completeness4/5

The domain (local code review/quality analysis) is well covered: change review with scope options, file analysis, project-wide scanning, and rule enumeration. Minor gaps exist, e.g. no way to configure or filter rules or to compare against a saved baseline report, but core workflows are complete.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers