Skip to main content
Glama
Test Impact Analysis MCP Server

Test Impact Analysis MCP Server

🌐 Language / 语言 / 語言: English | 简体中文 | 繁體中文 | 日本語

我想...

看这里

快速把项目跑起来

🚀 快速开始

了解能做什么

🎯 项目定位

看有哪些工具可用

🛠️ 5 个 MCP 工具

接入外部分析引擎

🔬 分析引擎集成

配置 Claude Code / OpenCode

📥 安装方式

看完整设计蓝图

.claude/plans/ultimate-blueprint-v3.md


📦 包含内容

分类

内容

说明

🛠️ MCP 工具

repo_monitor / repo_clone / impact_analysis / test_recommendation / risk_assessment

5 个工具

🔌 Transport 双模

stdio(本地零配置)/ http(远程 IP 白名单)

双模

🌐 平台适配器

GitHub / Local / Generic REST API

3 种平台

🔬 分析引擎

codebase-memory-mcp(158 语言静态分析,方法级调用链)

1 个引擎

📊 影响分析

glob 规则匹配 + BFS 调用链追踪 + 四级置信度

Phase 2-4

🔒 安全分层

源码层(提交GitHub) ↔ 企业配置层(.gitignore)

双层

从初始 7 个工具合并为 3 个(精简 57%),Phase 2-4 新增 2 个分析工具(5 个)。安全认证从两层(API KEY + IP)精简为一层(IP 白名单)。简单、实用、免维护。


Related MCP server: testing-mcp

🎯 项目定位

┌──────────────────────────────────────────────────────┐
│ Claude Code / OpenCode / Codex (Host)                │
│  ├─ CronCreate → 定时触发 repo_monitor               │
│  ├─ /repo_xxx 斜杠命令 → 快捷操控                    │
│  └─ MCP Client (stdio / http transport)               │
└─────────┬──────────────┬──────────────────────────────┘
          │ stdio (本地)  │ http (远程)
┌─────────▼────────┐ ┌──▼───────────────────────────────┐
│ 直接进程通信      │ │ Express App (port 3100)          │
│ (零配置)          │ │  └─ IP 白名单 → 通过/403         │
│ 直接执行 git clone │ └──────────────────────────────────┘
└──────────────────┘

┌──────────────────────────────────────────────────────┐
│ TIA MCP Server                                       │
│                                                      │
│  ┌─────────────────────────────────────────────┐     │
│  │ 模块 1: Git Monitor                          │     │
│  │ repo_monitor + repo_clone                   │     │
│  │ GitHub / Local / Generic 三平台适配           │     │
│  └─────────────────────────────────────────────┘     │
│  ┌─────────────────────────────────────────────┐     │
│  │ 模块 2: Impact Analysis + 引擎增强            │     │
│  │ impact_analysis + codebase-memory-mcp        │     │
│  │ BFS 调用链逆向追踪 + glob 文件级兜底          │     │
│  └─────────────────────────────────────────────┘     │
│  ┌─────────────────────────────────────────────┐     │
│  │ 模块 3: Test Recommendation                  │     │
│  │ test_recommendation                         │     │
│  │ 推荐分 = 风险权重 × 置信度                    │     │
│  └─────────────────────────────────────────────┘     │
│  ┌─────────────────────────────────────────────┐     │
│  │ 模块 4: Risk Assessment                      │     │
│  │ risk_assessment                             │     │
│  │ 文件+模块+置信度 三维评分 (0-100)             │     │
│  └─────────────────────────────────────────────┘     │
└──────────────────────────────────────────────────────┘

🚀 快速开始

1️⃣ 克隆并安装

git clone git@github.com:WayneLiu519888/Test-Impact-Analysis-MCP.git
cd Test-Impact-Analysis-MCP
npm install          # 自动安装 git hooks

2️⃣ 配置你的仓库

cp examples/monitors.conf.example.json enterprise/monitors.conf.json
vim enterprise/monitors.conf.json   # 填入你要监控的仓库

3️⃣ 配置 MCP 连接

Stdio 本地模式(零配置):

// .claude/settings.local.json
{ "enabledMcpjsonServers": ["test-impact-analysis"] }

HTTP 远程模式(需先配置 IP 白名单):

{
  "mcpServers": {
    "test-impact-analysis": {
      "type": "http",
      "url": "http://your-server:3100/mcp"
    }
  }
}

4️⃣ 开始使用

/repo_status                              # 查看仓库水位
/repo_check module=用户中心                # 检查新提交
/repo_clone full module=用户中心           # 克隆代码
impact_analysis(name="backend")           # 变更影响分析
test_recommendation(name="backend")       # 测试推荐
risk_assessment(name="backend")           # 风险评估

✨ 完成! 代码变更自动感知 + 增量代码拉取 + 精准测试影响分析。


🛠️ 5 个 MCP 工具

我想...

使用此工具

说明

查看/检查/重置仓库水位

repo_monitor

三合一:action=status|check|reset,支持 name/module 筛选

克隆代码到本地

repo_clone

全量(mode=full)/ 增量 MR(mode=incremental),按 repoType 自动存储

分析变更对测试的影响

impact_analysis

glob 规则匹配 + 引擎调用链追踪 + 自动推断

推荐测试执行顺序

test_recommendation

推荐分 = 风险权重 × 置信度,生成最小可行测试集

评估变更风险

risk_assessment

文件+模块+置信度三维评分 (0-100),含缓解建议

所有 5 个工具在 stdio 和 HTTP 模式下均可用。


🔬 分析引擎集成

TIA 支持接入外部代码静态分析引擎,提供方法级精确调用链分析能力。首个支持的引擎是 codebase-memory-mcp。

codebase-memory-mcp 引擎

单一静态二进制(~36MB),基于 tree-sitter 支持 158 种编程语言,零运行时依赖。

# 安装(PowerShell,3 步)
mkdir D:\0_WayneArchiveFiles\MCP-Servers\codebase-memory-mcp
curl -o "$env:TEMP\cbm.zip" "https://github.com/DeusData/codebase-memory-mcp/releases/latest/download/codebase-memory-mcp-windows-amd64.zip"
Expand-Archive "$env:TEMP\cbm.zip" D:\0_WayneArchiveFiles\MCP-Servers\codebase-memory-mcp
.\codebase-memory-mcp.exe --version    # → codebase-memory-mcp 0.8.1

# 启用引擎
# 编辑 engines.conf.json → "enabled": true

工作流程

impact_analysis 调用
  └─ .java/.ts/.py 等 → codebase-memory-mcp CLI 子进程
      ├─ index_repository    → 索引代码到本地 SQLite
      ├─ get_architecture    → 提取方法/入口点
      ├─ query_graph         → 提取全部 CALLS 调用边
      └─ 翻译为 PanoramaIndex → BFS 调用链逆向遍历
          └─ 合并到 TIA 影响分析报告

✅ 代码分析 100% 本地 | 🔌 引擎不可用时静默降级到 glob 匹配 | 📖 完整配置指导


🌐 跨平台支持

同一套 MCP 工具,三个 AI 编程框架共享。

维度

Claude Code

OpenCode

Codex (OpenAI)

命令目录

.claude/commands/

.opencode/commands/

.codex/skills/

文件格式

.md (frontmatter + 指令)

.md ($NAME 占位符)

SKILL.md (YAML frontmatter)

调用方式

/命令名

Ctrl+K 命令面板

$技能名

MCP 配置

.claude/settings.local.json

.opencode.json

.codex/config.toml


📥 安装方式

Claude Code (stdio)

// .claude/settings.local.json
{ "enabledMcpjsonServers": ["test-impact-analysis"] }

Claude Code (HTTP 远程)

{
  "mcpServers": {
    "test-impact-analysis": {
      "type": "http",
      "url": "http://your-server:3100/mcp"
    }
  }
}
# 服务端启动
MCP_TRANSPORT=http MCP_PORT=3100 npx tsx src/index.ts

OpenCode / Codex

详见项目内 .opencode/commands/ 和 .codex/skills/ 目录。


📂 仓库目录

Test-Impact-Analysis-MCP/
│
├── src/
│   ├── index.ts                  # MCP Server 入口 + Transport 双模
│   ├── types.ts / state.ts       # 类型定义 / 配置状态管理
│   ├── security.ts               # IP 白名单
│   ├── paths.ts                  # 路径定位 + 企业配置层
│   ├── platforms/                # Git 平台适配器(GitHub/Local/Generic)
│   ├── tools/                    # MCP 工具模块(schemas + helpers + 3 handler)
│   ├── impact-analysis/          # 影响分析 / 推荐 / 风险评估
│   ├── engines/                  # 分析引擎框架
│   │   └── adapters/             # codebase-memory-mcp 适配器
│   └── tests/                    # 65 个单元测试
│
├── examples/                     # 配置模板(.example.json)
├── docs/                         # 多语言文档
├── .claude/commands/             # Claude Code 斜杠命令
├── .opencode/commands/           # OpenCode 命令
├── .codex/skills/               # Codex 技能
│
├── enterprise/                   # 🔒 企业配置层(.gitignore 排除)
│   ├── monitors.conf.json        #   仓库监控配置
│   ├── server.conf.json          #   IP 白名单配置
│   ├── impact-rules.conf.json    #   影响分析规则
│   └── engines.conf.json         #   引擎配置
│
└── Repository/                   # 🚫 克隆的代码(.gitignore 排除)

🔒 信息安全

┌─────────────────────────────────┐
│ 开源层(提交 GitHub ✅)          │
│ src/ docs/ examples/ README     │
│ 不含企业 URL / 仓库 / 内网 IP    │
├─────────────────────────────────┤
│ 企业层(.gitignore 排除 ❌)      │
│ enterprise/ 整目录               │
│ 仓库地址 / IP 白名单 / 业务模块   │
└─────────────────────────────────┘

两层防护:.gitignore 排除 enterprise/ + Pre-commit hook 实时拦截。

HTTP 安全:IP 白名单(精确 IP + CIDR 子网),白名单内可直接连接全部 5 个工具。


❓ FAQ

  • Node.js >= 18 | TypeScript / ESM | Git CLI | tsx 运行时

npm start              # npx tsx src/index.ts
npm run dev            # tsx --watch(热重载)
npx tsc --noEmit       # 类型检查
npm test               # 65 个测试

TIA 运行在企业内网,网络隔离已由企业基础设施保障。IP 白名单作为唯一接入控制——简单、零维护、无密钥管理成本。

不会。 代码分析 100% 本地执行,语义向量模型编译进二进制,无外部 API 调用。启动时仅检查 GitHub Release 版本号(不含代码)。

自动静默降级到 TIA 内置的 glob 文件匹配规则。引擎失败不阻断分析流程。

GitLab / 华为 CodeHub / Gitee / 自建 GitLab / Gogs / Gitea — 通过 URL 模板适配,自动识别响应格式。

  • repo_clone mode=full — 首次拉取全量代码

  • repo_clone mode=incremental — 只拉迭代内的 MR 变更,需要平台支持 MR API


📋 环境要求

依赖

版本

Node.js

>= 18

TypeScript

5.x

tsx

>= 4

@modelcontextprotocol/sdk

>= 1.0

Git

任意


🔧 可用命令

命令

说明

npm start

启动 MCP Server(默认 stdio)

npm run dev

开发热重载(tsx --watch)

npm test

运行 65 个单元测试

npx tsc --noEmit

类型检查

npm run security-check

源码层安全自查


🗺️ 开发路线图

阶段

内容

状态

Phase 1

Git Monitor — 仓库变更感知与代码拉取

✅

Phase 1.5

Transport 双模 + IP 白名单

✅

Phase 1.6

repo_clone 远程模式

✅

Phase 2

Impact Analysis — 代码变更影响分析

✅

Phase 3

Test Recommendation — 智能测试推荐

✅

Phase 4

Risk Assessment — 变更风险量化

✅

Phase 5a

分析引擎框架 + codebase-memory-mcp 接入

✅

Phase 5c

更多分析引擎横向扩展

💡

Phase 6

信息安全分层重构

✅


📄 许可证

MIT — 自由使用,按需修改,欢迎回馈。


Available Tools

6 tools
impact_analysisA

分析代码变更对测试用例的影响。基于 impact-rules.conf.json 中配置的文件→测试映射规则, 自动匹配变更文件对应的测试模块,返回受影响测试用例的优先级排序列表。

使用方式: impact_analysis(name="gh-backend") — 分析从水位到 HEAD 的变更 impact_analysis(name="gh-backend", from="abc", to="def") — 指定 SHA 范围 impact_analysis(module="用户中心") — 按模块分析

前提:

  • 仓库已通过 repo_monitor(action='check') 初始化水位

  • 已编辑 impact-rules.conf.json 配置文件→测试映射规则(可选,未配置则自动推断)

Inputs: name, module, from, to.

repo_cloneA

克隆监控仓库的代码到本地。可用于初始化(首次拉取分支代码)或更新全量代码,也可增量拉取 MR。

定位方式(二选一):

  • name = 克隆单个仓库

  • module = 克隆该模块下的所有仓库(按 repoType 各自归位)

克隆模式(通过 mode 参数控制):

  • mode=full — 全量克隆分支代码(初始化 / 强制覆盖更新)

  • mode=incremental — 增量克隆 MR:sinceDate 拉取日期后合入的 MR / sinceMrId 拉取指定 MR 后合入的 MR

存储路径(由 repoType 决定):

  • frontend → Repository/Frontend repository/{repo-name}/

  • backend → Repository/Backend repository/{repo-name}/

行为模式(自动判断,无需用户干预):

  • stdio transport → 本地模式:MCP Server 直接执行 git clone

  • http transport → 远程模式:返回结构化 git 指令,由客户端在自己本地执行 远程模式下可通过 clientBaseDir 指定客户端本地存储路径

增量模式前提:

  • 仓库必须配置了 repoType

  • 需要平台支持 MR 查询(GitHub / Generic 需 mrApiTemplate)

  • local 平台仅支持 sinceDate 模式

Inputs: mode (required), name, module, sinceDate, +3 more.

repo_monitorA

统一仓库监控工具。仓库列表在 monitors.conf.json 中配置(直接编辑即可,无需 MCP 工具)。

三种操作(通过 action 参数选择):

  • status — 查看仓库水位、快照、上次检查时间

  • check — 检查新提交(首次自动初始化水位),驱动水位更新 + seenShas 去重

  • reset — 重置水位到指定 MR/日期。sinceDate 模式自动定位迭代第一个 MR 的 base commit

范围定位(二选一,不传则遍历全部):

  • name — 仓库别名

  • module — 模块名(批量操作该模块下所有仓库)

配合 CronCreate 定时监控: /cron "*/15 * * * *" "repo_monitor(action='check')"

敏捷迭代重置: repo_monitor(action="reset", module="订单系统", label="Sprint 25 kickoff", sinceDate="2026-06-13")

Inputs: action (required), name, module, label, +1 more.

risk_assessmentA

量化代码变更风险,生成风险评分(0-100)与缓解建议。 综合文件变更数量、受影响模块的风险等级分布、置信度三个维度计算。

risk_assessment(name="gh-backend") — 评估从水位到 HEAD 的风险 risk_assessment(module="用户中心") — 按模块评估

评分: files(0-60) + modules(0-40) + confidencePenalty(0-20) = 0-100 等级: 0-30=低风险 | 31-60=中等 | 61-85=高风险 | 86-100=严重

Inputs: name, module, from, to.

test_recommendationA

基于代码变更智能推荐测试用例执行顺序。在 Phase 2 影响分析结果上计算推荐分, 按优先级排序测试用例,生成最小可行测试集(覆盖所有高风险模块的最少测试)。

test_recommendation(name="gh-backend") — 分析从水位到 HEAD test_recommendation(module="用户中心") — 按模块分析

推荐分 = 风险权重(h=100/m=50/l=20) × 置信度(0-100) 强烈建议(≥7000) | 建议(≥2000) | 可选(<2000)

Inputs: name, module, from, to.

TIA-initA

【首次使用必调】TIA (Test Impact Analysis) 初始化引导工具。

远程 HTTP 客户端在接入 TIA MCP Server 后,必须先调用此工具完成初始化:

  1. 自动签发 API KEY(写入客户端 MCP 配置)

  2. 自动判断客户端 Agent 类型(X-Agent-Type 请求头 > agentType 参数) ClaudeCode → Claude Code 命令文件 CodeX → Codex (OpenAI) 技能文件 OpenCode → OpenCode 命令文件

  3. 自动返回 TIA 命令文件内容,由客户端 LLM 写入本地

调用前提:客户端 IP 已在服务端白名单中。 IP 不在白名单 → 403 + 联系人信息。

可重复调用:已持有效 API KEY 时跳过签发步骤,仅返回命令文件。

Inputs: agentType.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 6 tools

    Disambiguation5/5

    All six tools have clearly distinct purposes: impact analysis, repo cloning, repo monitoring, risk assessment, test recommendation, and initialization. No overlap in functionality.

    Naming Consistency3/5

    Most tools use snake_case (impact_analysis, repo_clone, etc.), but TIA-init introduces a hyphen and different casing, breaking the pattern. Also, verb placement varies: some are noun_verb, some noun_noun.

    Tool Count5/5

    Six tools cover the workflow of test impact analysis without being excessive or insufficient. Each tool fulfills a necessary role.

    Completeness4/5

    The tool set covers initialization, monitoring, cloning, analysis, risk assessment, and recommendations. Only minor gaps like configuration management exist, but they are noted as manual edits.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      MCP server for test impact analysis and code intelligence. Maps tests to code and git history to determine impacted tests, risk scores, and ownership for AI coding agents.
      8
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      MCP server that provides tools for architecture analysis, risk diagnosis, quality metrics, and regression guarding to support AI-driven code review and incremental refactoring workflows.
      5
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      MCP server for AI-powered QA analysis. It enables analyzing test failures, identifying root causes, suggesting fixes, classifying defects, detecting flaky tests, and generating test cases and bug reports.
      10
      ISC