Skip to main content
Glama

SemaMerge

npm version License: MIT

一个 MCP(模型上下文协议)服务器,通过 AST 级分析检测 Git 分支之间的语义合并冲突

当两个分支以 Git 可以干净合并但功能上不兼容的方式更改代码时,SemaMerge 会在合并破坏您的应用程序之前捕获它。

它能检测什么

冲突类型

示例

类型签名更改

分支 A 更改了 getUser() 的返回类型,分支 B 调用了 getUser().address

移除/重命名导出

分支 A 移除了 export function validate(),分支 B 添加了 import { validate }

参数更改

分支 A 为函数添加了必需参数,分支 B 使用旧签名进行调用

接口/契约破坏

分支 A 为接口添加了必需字段,分支 B 在实现时未包含该字段

枚举/常量更改

分支 A 移除了 Status.PENDING,分支 B 使用了 Status.PENDING

导入路径更改

分支 A 移动了文件,分支 B 从旧路径导入

Related MCP server: SYKE

安装

npx semamerge

或者全局安装:

npm install -g semamerge

或者克隆并从源码构建:

git clone https://github.com/vineethwilson15/semamerge.git
cd semamerge
npm install
npm run build

MCP 工具

check_merge_safety

快速合并前检查。返回风险评分(安全/警告/危险)。

{
  "repoPath": "/path/to/repo",
  "sourceBranch": "feature-x",
  "targetBranch": "main"
}

analyze_branches

深度分析,提供所有语义冲突的逐文件细分。

{
  "repoPath": "/path/to/repo",
  "branchA": "feature-x",
  "branchB": "feature-y",
  "baseBranch": "main"
}

list_semantic_changes

列出分支上的所有语义更改(函数、导出、类型等)。

{
  "repoPath": "/path/to/repo",
  "branch": "feature-x",
  "baseBranch": "main"
}

analyze_file_pair

深入分析两个分支之间特定文件的语义差异。

{
  "repoPath": "/path/to/repo",
  "filePath": "src/utils.ts",
  "branchA": "feature-x",
  "branchB": "main"
}

配置

VS Code (Copilot)

添加到您的 VS Code settings.json 中:

{
  "mcp": {
    "servers": {
      "semamerge": {
        "command": "node",
        "args": ["/path/to/semamerge/dist/index.js"]
      }
    }
  }
}

Claude Desktop

添加到 claude_desktop_config.json 中:

{
  "mcpServers": {
    "semamerge": {
      "command": "node",
      "args": ["/path/to/semamerge/dist/index.js"]
    }
  }
}

支持的语言

  • TypeScript / JavaScript (.ts, .tsx, .js, .jsx, .mjs, .cjs)

  • 计划支持 Python

工作原理

  1. Git 层 — 使用 git show 在不检出的情况下读取分支中的文件内容

  2. AST 解析 — 使用 tree-sitter (WASM) 将源代码解析为语法树

  3. 语义提取 — 遍历 AST 以提取函数签名、类型、导出、导入、枚举

  4. 三向比较 — 计算从共同祖先到每个分支的语义差异

  5. 冲突检测 — 交叉引用更改以查找不兼容性

开发

npm run build    # Compile TypeScript
npm run dev      # Watch mode
npm test         # Run tests

许可证

MIT

Available Tools

4 tools
analyze_branchesA

Deep semantic analysis between two branches. Returns a detailed per-file report of all semantic changes and conflicts, including cross-file dependency issues.

ParametersJSON Schema
NameRequiredDescriptionDefault
repoPathYesAbsolute path to the Git repository
branchAYesFirst branch to compare
branchBYesSecond branch to compare
baseBranchNoCommon base branch (auto-detected if not provided)

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations, the description provides some behavioral context (returns detailed report, includes conflicts and cross-file issues), but lacks details on potential side effects, performance, or required permissions.

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 is two sentences: one stating purpose and one describing output. No unnecessary words; efficient and front-loaded.

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?

Given no output schema, the description adequately explains the return value (per-file report of changes and conflicts). However, it could mention prerequisites like branch existence or edge cases.

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

Parameters3/5

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

The input schema has 100% description coverage, and the description does not add new meaning beyond the schema's parameter descriptions. It only reiterates the general purpose.

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 it performs deep semantic analysis between two branches and returns a per-file report of changes and conflicts, distinguishing it from sibling tools like 'analyze_file_pair' and 'check_merge_safety'.

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 semantic comparison but does not provide explicit guidance on when to use this tool versus alternatives like 'list_semantic_changes' or 'check_merge_safety'.

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

analyze_file_pairA

Deep-dive semantic diff of a single file between two branches. Shows exactly what each branch changed and where conflicts arise.

ParametersJSON Schema
NameRequiredDescriptionDefault
repoPathYesAbsolute path to the Git repository
filePathYesPath to the file within the repository
branchAYesFirst branch
branchBYesSecond branch

TDQS

A3.6/5.0
Behavior3/5

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

No annotations are provided, so the description must carry the full burden. It discloses the tool 'shows' results, implying a read-only operation, but does not explicitly state it has no side effects or any performance considerations.

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?

Description is a single sentence that is direct and front-loaded with the purpose. While concise, a second sentence on usage or output could improve completeness without harming conciseness.

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

Completeness3/5

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

Given no output schema and 4 parameters, the description explains the tool's purpose and high-level output (changes and conflicts), but lacks details on return format or how results are presented, which is important for a diff tool.

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

Parameters3/5

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

Schema coverage is 100%, so the schema already documents all parameters. The description adds no extra meaning beyond the schema descriptions.

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 performs a 'deep-dive semantic diff of a single file between two branches' and shows changes and conflicts. This distinguishes it from siblings like analyze_branches which likely covers multiple files.

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?

No explicit guidance on when to use this tool vs alternatives (e.g., analyze_branches for broader diffs). The context is implied but not stated.

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

check_merge_safetyA

Quick pre-merge safety check. Analyzes two branches for semantic conflicts that Git would miss (signature changes, removed exports, parameter mismatches, etc.). Returns a risk score: safe/warning/danger.

ParametersJSON Schema
NameRequiredDescriptionDefault
repoPathYesAbsolute path to the Git repository
sourceBranchYesThe branch being merged (source)
targetBranchYesThe branch being merged into (target)

TDQS

A4/5.0
Behavior3/5

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

No annotations are provided, so the description must bear the full burden. It discloses the return risk score (safe/warning/danger), but does not mention side effects (e.g., read-only nature) or execution time. Adequate but could add more detail.

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?

Two sentences, concise and well-structured. No unnecessary words, and the key information is front-loaded (quick pre-merge safety check).

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?

With 3 required parameters and no output schema, the description provides a clear purpose and return risk score. It lacks details on the exact format of the risk score or any additional output, but is mostly complete.

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

Parameters3/5

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

Schema description coverage is 100% (all three parameters have descriptions). The description adds that the tool analyzes branches for semantic conflicts, but this is implied by the overall purpose and does not significantly enhance parameter understanding beyond the schema.

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's purpose: a quick pre-merge safety check analyzing two branches for semantic conflicts. It specifies what it catches (signature changes, etc.) and distinguishes it from sibling tools like analyze_branches and list_semantic_changes.

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?

The description implies use before merging by stating 'Quick pre-merge safety check'. It mentions conflicts Git would miss, but does not explicitly state when not to use it or compare with alternatives.

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

list_semantic_changesA

Lists all semantic changes on a branch (function additions/removals, export changes, type changes, etc.) relative to a base. Useful for understanding what semantically changed.

ParametersJSON Schema
NameRequiredDescriptionDefault
repoPathYesAbsolute path to the Git repository
branchYesBranch to analyze
baseBranchNoBase branch to compare against (defaults to merge-base with HEAD)

TDQS

A3.5/5.0
Behavior2/5

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

No annotations provided, so the description must carry the burden. It states 'Lists all semantic changes' suggesting read-only behavior, but lacks details on return structure, pagination, side effects, or error conditions. Incomplete for a tool with no annotation support.

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?

Two sentences, front-loaded with action and examples. No wasted words, efficient and clear.

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

Completeness3/5

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

Given 3 parameters, no output schema, and no annotations, the description explains purpose and examples but lacks details on return format, error handling, or performance. Adequate but with gaps.

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

Parameters3/5

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

Schema description coverage is 100% (3 parameters all described). The description adds little beyond the schema: it mentions 'relative to a base' which aligns with baseBranch, but no deeper semantics. Baseline 3 is appropriate.

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?

Clearly states the tool lists semantic changes on a branch relative to a base, with specific examples like function additions/removals, export changes, type changes. Distinguishes itself from sibling tools (analyze_branches, analyze_file_pair, check_merge_safety) which have different purposes.

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 says 'Useful for understanding what semantically changed,' implying when to use it, but no explicit guidance on alternatives or when not to use it. No exclusions or comparisons with sibling tools.

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. 4 tool updatesv0.1.1
    • First observedanalyze_branches
    • First observedanalyze_file_pair
    • First observedcheck_merge_safety
    • First observedlist_semantic_changes

TDQS

A4/5.0

Scored across 4 tools

Disambiguation4/5

Each tool targets a distinct analysis granularity: quick safety check, deep branch analysis, change listing, and single-file diff. The only minor overlap is between check_merge_safety and analyze_branches, but their quick-vs-detailed distinction is clear.

Naming Consistency5/5

All tool names consistently follow a verb_noun pattern: check_merge_safety, analyze_branches, list_semantic_changes, analyze_file_pair. The naming style is uniform and predictable.

Tool Count5/5

Four tools is well-scoped for a semantic merge analysis server. Each tool covers a distinct level of analysis without redundancy or unnecessary bloat.

Completeness5/5

The tools cover the full analysis workflow: quick safety triage, comprehensive branch-level analysis, semantic change listing, and per-file deep dives. No obvious gaps exist for the stated analysis-focused purpose.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    AI code impact analysis MCP server that monitors file changes, maps dependency graphs, detects cascading breakage, and gates builds before damage spreads.
    113 npm
    2
    Elastic 2.0
  • A
    license
    Not graded
    quality
    A
    maintenance
    an MCP server that auto-resolves Git merge conflicts so agents only touch the complex hunks — deterministic pattern engine with confidence scores and a full decision trace, plus merge/rebase preview and hunk-level resolution tools
    175
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Multi-language code intelligence MCP server providing structured code analysis including symbol search, references, hierarchies, and change impact. Supports 25 languages with persistent indexing and LSP integration.
    32 npm
    MIT