diffchunk
diffchunk
LLM이 대규모 diff 파일을 효율적으로 탐색할 수 있게 해주는 MCP 서버입니다. 전체 diff를 순차적으로 읽는 대신, LLM은 패턴 기반 탐색을 사용하여 관련 변경 사항으로 직접 이동할 수 있습니다.
문제점
대규모 diff는 LLM 컨텍스트 제한을 초과하며 관련 없는 변경 사항에 토큰을 낭비하게 합니다. 5만 줄 이상의 diff는 직접 처리할 수 없으며, 수동으로 분할하면 파일 간의 관계를 잃게 됩니다.
Related MCP server: Large File MCP Server
해결책
5가지 탐색 도구를 갖춘 MCP 서버:
load_diff- 사용자 지정 설정으로 diff 파일 파싱 (선택 사항)list_chunks- 파일 매핑 및 파일별 줄 수를 포함한 청크 개요 표시 (자동 로드)get_chunk- 특정 청크 내용 검색 (자동 로드)find_chunks_for_files- 파일 패턴으로 청크 위치 찾기 (자동 로드)get_file_diff- 단일 파일에 대한 전체 diff 추출 (자동 로드)
설정
전제 조건: uvx 명령을 제공하는 uv(매우 빠른 Python 패키지 관리자)를 설치하세요.
MCP 클라이언트 구성에 추가하세요:
{
"mcpServers": {
"diffchunk": {
"command": "uvx",
"args": ["--from", "diffchunk", "diffchunk-mcp"]
}
}
}사용법
이제 AI 어시스턴트는 Cline, Roocode, Cursor 및 기타 도구에서 이전에 실패를 유발했던 대규모 변경 사항을 처리할 수 있습니다.
AI 어시스턴트와 함께 사용하기
구성 후, AI 어시스턴트는 diffchunk를 사용하여 대규모 커밋, 브랜치 또는 diff를 분석할 수 있습니다.
다음은 몇 가지 예시 사용 사례입니다:
브랜치 비교:
"develop 브랜치에는 있지만 main 브랜치에는 없는 모든 변경 사항에서 버그를 검토해줘"
"아직 병합하지 않은 모든 변경 사항에 대해 알려줘"
"staging 브랜치에 어떤 새로운 기능이 추가되었어?"
"지난 2주 동안 이 저장소에 발생한 모든 변경 사항을 요약해줘"
코드 리뷰:
"diffchunk를 사용하여 내 기능 브랜치에서 보안 취약점을 확인해줘"
"diffchunk를 사용하여 프로덕션에 병합하기 전에 파괴적인 변경 사항이 있는지 찾아줘"
"diffchunk를 사용하여 이 대규모 리팩토링에서 잠재적인 문제를 검토해줘"
변경 사항 분석:
"diffchunk를 사용하여 실행해야 할 모든 데이터베이스 마이그레이션을 보여줘"
"diffchunk를 사용하여 모바일 앱에 영향을 줄 수 있는 API 변경 사항을 찾아줘"
"diffchunk를 사용하여 최근에 추가된 모든 새로운 종속성을 분석해줘"
직접 파일 분석:
"diffchunk를 사용하여 /tmp/changes.diff의 diff를 분석하고 버그를 찾아줘"
"커밋되지 않은 변경 사항의 diff를 생성하고 검토해줘"
"내 로컬 브랜치를 origin과 비교하고 충돌을 강조해줘"
팁: AI 어시스턴트 규칙
자동 사용을 위해 AI 어시스턴트의 사용자 지정 지침에 추가하세요:
When reviewing large changesets or git commits, use diffchunk to handle large diff files.
Create temporary diff files and tracking files as needed and clean up after analysis.작동 원리
AI 어시스턴트에게 변경 사항 분석을 요청하면, diffchunk의 도구를 전략적으로 사용합니다:
diff 파일 생성 (예:
git diff main..develop > /tmp/changes.diff) - 질문에 기반함list_chunks사용 -file_details를 통한 파일별 줄 수를 포함하여 diff 구조와 전체 범위를 파악find_chunks_for_files사용 - 특정 파일 유형에 대해 질문할 때 관련 섹션 찾기get_file_diff사용 - 전체 청크를 로드하지 않고 특정 파일에 대한 전체 diff 가져오기get_chunk사용 - 전체 diff를 컨텍스트에 로드하지 않고 특정 섹션 검사체계적인 진행 상황 추적 - 대규모 변경 사항을 청크 단위로 분석
임시 파일 정리 - 분석 완료 후
이를 통해 AI 어시스턴트는 다른 도구라면 충돌했을 대규모 diff를 처리하면서도 컨텍스트 손실 없이 철저한 분석을 제공할 수 있습니다.
도구 사용 패턴
개요 우선:
list_chunks("/tmp/changes.diff")
# -> 5 chunks across 12 files, 3,847 total lines, ~15,420 tokens
# Each chunk includes token_count and file_details with per-file line counts
# Response includes total_token_count for context-budget planning특정 파일 타겟팅:
find_chunks_for_files("/tmp/changes.diff", "*.py")
# → [1, 3, 5] - Python file chunks
get_chunk("/tmp/changes.diff", 1)
# → Content of first Python chunk단일 파일 diff:
get_file_diff("/tmp/changes.diff", "src/main.py")
# → Complete diff for src/main.py (header + all hunks)
# Glob patterns work when they match exactly one file
get_file_diff("/tmp/changes.diff", "*.config")
# → Complete diff for the single matching config file체계적인 분석:
# Process each chunk in sequence
get_chunk("/tmp/changes.diff", 1)
get_chunk("/tmp/changes.diff", 2)
# ... continue through all chunks구성
경로 요구 사항
절대 경로만 가능:
/home/user/project/changes.diff크로스 플랫폼: Windows (
C:\path) 및 Unix (/path)홈 확장:
~/project/changes.diff
자동 로드 기본값
도구는 최적화된 설정으로 자동 로드됩니다:
max_chunk_lines: 1000skip_trivial: true (공백만 있는 경우)skip_generated: true (잠금 파일, 빌드 아티팩트)
사용자 지정 설정
기본값이 아닌 동작을 위해 load_diff를 사용하세요:
load_diff(
"/tmp/large.diff",
max_chunk_lines=2000,
include_patterns="*.py,*.js",
exclude_patterns="*test*",
context_lines=2
)형식 옵션
LLM 소비를 위해 출력을 변환하려면 get_chunk에서 format 매개변수를 사용하세요:
# Default - raw diff output
get_chunk("/tmp/changes.diff", 1, format="raw")
# Annotated - structured with line numbers, file headers, hunk separation
get_chunk("/tmp/changes.diff", 1, format="annotated")
# Compact - token-efficient, only new hunks (context + added lines)
get_chunk("/tmp/changes.diff", 1, format="compact")Annotated 형식은 ## File: 헤더, 새 파일 줄 번호가 포함된 __new hunk__/__old hunk__ 섹션, 그리고 @@ 헤더의 함수 컨텍스트를 추가합니다.
Compact 형식은 추가되거나 유지된 내용만 표시하며, 제거된 줄과 __old hunk__ 섹션은 완전히 생략합니다. 최종 상태만 확인하면 될 때 유용합니다.
컨텍스트 축소
로드 시 헝크당 컨텍스트 줄을 줄이려면 load_diff에서 context_lines를 사용하세요:
# Keep only 2 lines of context around each change
load_diff("/tmp/large.diff", context_lines=2)
# Keep only changes, no context
load_diff("/tmp/large.diff", context_lines=0)이는 format과 결합됩니다. 로드 시 컨텍스트가 줄어들고, 표시 시 서식이 적용됩니다.
지원되는 형식
Git diff 출력 (
git diff,git show)Unified diff 형식 (
diff -u)단일 diff 내 여러 파일
바이너리 파일 변경 표시기
성능
10만 줄 이상의 diff를 효율적으로 처리
메모리 효율적인 스트리밍
파일 변경 시 자동 재로드
문서
라이선스
Available Tools
5 toolsfind_chunks_for_filesARead-only
Locate chunks containing files that match a specific glob pattern. Auto-loads the diff file if not already loaded. Essential for targeted analysis when you need to focus on specific file types, directories, or naming patterns (e.g., '.py' for Python files, 'test' for test files, 'src/' for source directory). Returns chunk numbers which you then examine using get_chunk. CRITICAL: You must use an absolute directory path - relative paths will fail. DO NOT attempt direct file reading. Use this for efficient navigation to relevant changes instead of processing entire large diffs sequentially.
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | Glob pattern to match file paths (e.g., '*.py', '*test*', 'src/*') | |
| absolute_file_path | Yes | Absolute path to the diff file |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond readOnlyHint=true annotation, description reveals auto-loading behavior and that output is chunk numbers. Warns about relative path failure. No contradictions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
5 sentences, front-loaded with purpose, each sentence adds unique value (purpose, auto-load, use case, examples, critical warnings). No redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 2 required parameters and no output schema, description covers all essential aspects: purpose, behavior, constraints, and next step (use get_chunk). Siblings listed for context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema covers 100% parameters, but description adds valuable context: pattern examples ('*.py'), and reiterates absolute path requirement with rationale.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clear verb+resource: 'Locate chunks containing files' with specific glob pattern. Distinguishes from siblings like get_chunk and list_chunks by focusing on file-pattern based searching.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly states when to use (targeted analysis instead of processing entire diffs), critical constraints (absolute path required, no direct file reading), and alternatives relative to sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_chunkARead-only
Retrieve the actual content of a specific numbered chunk from a diff file. Auto-loads the diff file if not already loaded. Use this for systematic analysis of changes chunk-by-chunk, or to examine specific chunks identified via list_chunks or find_chunks_for_files. CRITICAL: You must use an absolute directory path - relative paths will fail. DO NOT read diff files directly - they exceed LLM context windows. This tool provides manageable portions of large diffs. Track your progress through chunks when doing comprehensive analysis and clean up tracking documents before final results.
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format: 'raw' (default, standard diff), 'annotated' (line numbers, new/old hunk separation), 'compact' (line numbers, new hunks only) | raw |
| chunk_number | Yes | The chunk number to retrieve (1-indexed) | |
| include_context | No | Include chunk header with metadata | |
| absolute_file_path | Yes | Absolute path to the diff file |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations declare readOnlyHint=true, and the description adds that it auto-loads the diff file if not loaded and that it provides manageable portions. It correctly notes the absolute path requirement. No contradictions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is somewhat lengthy but every sentence adds value: purpose, usage, critical requirement, behavioral note, and progress tracking advice. Well-structured but could be slightly more concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite no output schema, the description covers all essential aspects: what the tool does, when to use it, critical requirements (absolute path), behavioral traits (auto-loading, manageable portions), and guidance for comprehensive analysis. No gaps identified.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with descriptions for each parameter, so baseline is 3. The description adds the critical constraint that 'absolute_file_path' must be an absolute path, which is not in the schema. It also implies chunk_number is 1-indexed. Adds meaningful value beyond schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool retrieves content of a specific chunk from a diff file. It distinguishes from siblings by mentioning it is for individual chunks identified via list_chunks or find_chunks_for_files, and explicitly warns against reading diff files directly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides clear when-to-use scenarios: systematic chunk-by-chunk analysis or examining specific chunks. Includes a critical note about absolute paths and a 'DO NOT' instruction for reading diff files directly. Slightly less explicit about alternatives but gives good context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_file_diffARead-only
Extract the complete diff for a single file from a loaded diff. Returns the diff --git header and all hunks for that file. Use this when you need changes for one specific file without fetching the entire chunk. Auto-loads the diff file if not already loaded. Supports exact file paths or glob patterns that match exactly one file. Use list_chunks with file_details to see per-file line counts and decide whether to use this tool or get_chunk. CRITICAL: You must use an absolute directory path - relative paths will fail.
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Exact file path or glob pattern matching a single file within the diff (e.g., 'src/main.py', '*.config') | |
| absolute_file_path | Yes | Absolute path to the diff file |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Beyond the readOnlyHint annotation, the description discloses auto-loading behavior and path requirement. No contradictions with annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Every sentence serves a purpose: purpose, usage guidance, behavioral note, error condition. Concise and front-loaded with essential information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema, the description explains return value. With good annotations and clear parameter semantics, it provides complete contextual information for correct usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema covers both parameters with descriptions, but the tool description adds valuable context: file_path can be exact path or glob, and absolute_file_path must be absolute. Adds nuance beyond schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('extract'), the resource ('complete diff for a single file'), and the output ('diff --git header and all hunks'). It distinguishes from sibling tools like get_chunk and list_chunks.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly tells when to use ('when you need changes for one specific file'), references sibling tools for decision-making ('Use list_chunks... decide whether to use this tool or get_chunk'), and includes a critical requirement ('absolute directory path - relative paths will fail').
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_chunksARead-only
Get an overview of all chunks in a diff file with file mappings and summaries. Auto-loads the diff file with optimal defaults if not already loaded. Use this as your first step to understand the scope and structure of changes before diving into specific chunks. CRITICAL: You must use an absolute directory path - relative paths will fail. DO NOT attempt to read the diff file directly as it will exceed context limits. This tool provides the roadmap for systematic chunk-by-chunk analysis. If using tracking documents to resume analysis, use this to orient yourself to remaining work. Each chunk includes a token_count estimate, and the response includes total_token_count for context-budget planning.
| Name | Required | Description | Default |
|---|---|---|---|
| absolute_file_path | Yes | Absolute path to the diff file |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already mark it as readOnlyHint=true. Description adds behavior: 'Auto-loads the diff file with optimal defaults if not already loaded' and mentions response includes 'total_token_count'. Does not contradict annotations. Could mention error behavior if file not found, but still adds significant context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Description is packed with useful information and front-loaded with purpose. While every sentence adds value, it is slightly verbose. Could be tightened but still clear and efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite having only one parameter and no output schema, the description covers all needed context: purpose, usage guidelines, critical requirements, and expected response (file mappings, summaries, token counts). No gaps identified.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with one parameter. The description adds critical semantic info beyond the schema: 'You must use an absolute directory path - relative paths will fail.' This ensures correct usage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Get an overview of all chunks in a diff file with file mappings and summaries.' It distinguishes itself from siblings like 'get_chunk' by positioning itself as the first step for understanding scope and structure.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly guides when to use: 'Use this as your first step' and 'If using tracking documents to resume analysis, use this to orient yourself.' Also provides critical warnings: absolute path required, do not read diff file directly. Includes alternatives implicitly by describing the tool's role.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
load_diffARead-only
Parse and load a diff file with custom chunking settings. Use this tool ONLY when you need non-default settings (custom chunk sizes, filtering patterns). Otherwise, use list_chunks, get_chunk, or find_chunks_for_files which auto-load with optimal defaults. CRITICAL: You must use an absolute directory path - relative paths will fail. The diff file will be too large for direct reading, so you MUST use diffchunk tools for navigation. When using tracking documents for analysis, remember to clean up tracking state before presenting final results. The response includes a files_excluded count showing how many files were removed by exclude_patterns.
| Name | Required | Description | Default |
|---|---|---|---|
| skip_trivial | No | Skip whitespace-only changes | |
| context_lines | No | Number of context lines around each change (default: keep all from diff file) | |
| skip_generated | No | Skip generated files and build artifacts | |
| max_chunk_lines | No | Maximum lines per chunk | |
| exclude_patterns | No | Comma-separated glob patterns for files to exclude | |
| include_patterns | No | Comma-separated glob patterns for files to include | |
| absolute_file_path | Yes | Absolute path to the diff file to load |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations indicate readOnlyHint=true, consistent with description. Description adds behavioral context: absolute path, file size limitation, and need to clean tracking state. However, does not detail error handling or response content.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Description is concise, front-loads purpose, and contains no redundant text. Slightly verbose with multiple sentences but still efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 7 parameters well-described in schema and text, no output schema, the description provides sufficient context for usage, warnings, and behavioral notes. Missing some details on return values, but overall adequate.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, baseline 3. Description adds extra meaning for parameters (e.g., 'whitespace-only changes' for skip_trivial, 'build artifacts' for skip_generated, 'comma-separated glob patterns' for exclude/include), justifying higher score.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states verb (parse/load) and resource (diff file), and distinguishes from siblings by specifying it is for non-default chunking settings.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly says when to use (custom settings) and when not to (use siblings for defaults). Provides critical warnings: absolute path required, file too large, cleanup of tracking state.
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.
5 tool updates
v0.1.5- Added
find_chunks_for_files - Added
get_chunk - Added
get_file_diff - Added
list_chunks - Added
load_diff
4 tool updates
v0.1.0- Removed
find_chunks_for_files - Removed
get_chunk - Removed
list_chunks - Removed
load_diff
4 tool updates
v0.1.7- First observed
find_chunks_for_files - First observed
get_chunk - First observed
list_chunks - First observed
load_diff
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: loading, listing, chunk retrieval, file-pattern search, and full file diff. No overlap or ambiguity.
All tool names follow the consistent snake_case verb_noun pattern (e.g., load_diff, list_chunks). Predictable and clear.
5 tools is well-scoped for a diff chunking server. Each tool serves a necessary function without being superfluous.
The toolset covers loading, listing, searching, and retrieving diff content. No obvious missing operations for the domain.
Maintenance
Related MCP Connectors
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Code-map tools for AI agents: see a repo's structure first, then edit only what matters.
11Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Change-aware CI validation and affected-test guidance for coding agents.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables pattern-based file editing operations using copy/paste functionality with text landmarks instead of exact string matching. Allows AI agents to efficiently manipulate file content by identifying code patterns and insertion points without consuming large amounts of context tokens.1MIT
- AlicenseAqualityBmaintenanceEnables intelligent handling of large files through smart chunking, search with regex support, line navigation, and streaming capabilities without loading entire files into memory.651 npm18MIT
- AlicenseAqualityAmaintenanceReduces token consumption by over 80% through intelligent file caching, returning only diffs for modified files and suppressing unchanged content. It features a suite of 12 tools for semantic search, batch reading, and efficient file editing to optimize LLM interactions with large codebases.142MIT
- AlicenseNot gradedqualityDmaintenanceProvides file caching and diff tracking for AI coding agents, reducing token usage by returning changes or confirming no changes instead of full file contents on repeated reads.82 npm220MIT