Skip to main content
Glama

diffchunk

CI PyPI version Python 3.10+ License: MIT uv

MCP server that enables LLMs to navigate large diff files efficiently. Instead of reading entire diffs sequentially, LLMs can jump directly to relevant changes using pattern-based navigation.

Problem

Large diffs exceed LLM context limits and waste tokens on irrelevant changes. A 50k+ line diff can't be processed directly and manual splitting loses file relationships.

Related MCP server: Large File MCP Server

Solution

MCP server with 5 navigation tools:

  • load_diff - Parse diff file with custom settings (optional)

  • list_chunks - Show chunk overview with file mappings and per-file line counts (auto-loads)

  • get_chunk - Retrieve specific chunk content (auto-loads)

  • find_chunks_for_files - Locate chunks by file patterns (auto-loads)

  • get_file_diff - Extract the complete diff for a single file (auto-loads)

Setup

Prerequisite: Install uv (an extremely fast Python package manager) which provides the uvx command.

Add to your MCP client configuration:

{
  "mcpServers": {
    "diffchunk": {
      "command": "uvx",
      "args": ["--from", "diffchunk", "diffchunk-mcp"]
    }
  }
}

Usage

Your AI assistant can now handle massive changesets that previously caused failures in Cline, Roocode, Cursor, and other tools.

Using with AI Assistant

Once configured, your AI assistant can analyze large commits, branches, or diffs using diffchunk.

Here are some example use cases:

Branch comparisons:

  • "Review all changes in develop not in the main branch for any bugs"

  • "Tell me about all the changes I have yet to merge"

  • "What new features were added to the staging branch?"

  • "Summarize all changes to this repo in the last 2 weeks"

Code review:

  • "Use diffchunk to check my feature branch for security vulnerabilities"

  • "Use diffchunk to find any breaking changes before I merge to production"

  • "Use diffchunk to review this large refactor for potential issues"

Change analysis:

  • "Use diffchunk to show me all database migrations that need to be run"

  • "Use diffchunk to find what API changes might affect our mobile app"

  • "Use diffchunk to analyze all new dependencies added recently"

Direct file analysis:

  • "Use diffchunk to analyze the diff at /tmp/changes.diff and find any bugs"

  • "Create a diff of my uncommitted changes and review it"

  • "Compare my local branch with origin and highlight conflicts"

Tip: AI Assistant Rules

Add to your AI assistant's custom instructions for automatic usage:

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.

How It Works

When you ask your AI assistant to analyze changes, it uses diffchunk's tools strategically:

  1. Creates the diff file (e.g., git diff main..develop > /tmp/changes.diff) based on your question

  2. Uses list_chunks to get an overview of the diff structure and total scope, including per-file line counts via file_details

  3. Uses find_chunks_for_files to locate relevant sections when you ask about specific file types

  4. Uses get_file_diff to fetch the complete diff for one specific file without loading an entire chunk

  5. Uses get_chunk to examine specific sections without loading the entire diff into context

  6. Tracks progress systematically through large changesets, analyzing chunk by chunk

  7. Cleans up temporary files after completing the analysis

This lets your AI assistant handle massive diffs that would normally crash other tools, while providing thorough analysis without losing context.

Tool Usage Patterns

Overview first:

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

Target specific files:

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

Single-file 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

Systematic analysis:

# Process each chunk in sequence
get_chunk("/tmp/changes.diff", 1)
get_chunk("/tmp/changes.diff", 2)
# ... continue through all chunks

Configuration

Path Requirements

  • Absolute paths only: /home/user/project/changes.diff

  • Cross-platform: Windows (C:\path) and Unix (/path)

  • Home expansion: ~/project/changes.diff

Auto-Loading Defaults

Tools auto-load with optimized settings:

  • max_chunk_lines: 1000

  • skip_trivial: true (whitespace-only)

  • skip_generated: true (lock files, build artifacts)

Custom Settings

Use load_diff for non-default behavior:

load_diff(
    "/tmp/large.diff",
    max_chunk_lines=2000,
    include_patterns="*.py,*.js",
    exclude_patterns="*test*",
    context_lines=2
)

Format Options

Use the format parameter on get_chunk to transform output for LLM consumption:

# 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 format adds ## File: headers, __new hunk__/__old hunk__ sections with new-file line numbers, and function context from @@ headers.

Compact format shows only what was added or kept, omitting removed lines and __old hunk__ sections entirely. Useful when you only need to see the final state.

Context Reduction

Use context_lines on load_diff to reduce context lines per hunk at load time:

# 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)

This composes with format - context is reduced at load time, then formatting is applied at display time.

Supported Formats

  • Git diff output (git diff, git show)

  • Unified diff format (diff -u)

  • Multiple files in single diff

  • Binary file change indicators

Performance

  • Efficiently handles 100k+ line diffs

  • Memory efficient streaming

  • Auto-reload on file changes

Documentation

  • Design - Architecture and implementation details

  • Contributing - Contributing guidelines and development setup

License

MIT

Available Tools

5 tools
find_chunks_for_filesA
Read-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.

ParametersJSON Schema
NameRequiredDescriptionDefault
patternYesGlob pattern to match file paths (e.g., '*.py', '*test*', 'src/*')
absolute_file_pathYesAbsolute path to the diff file

TDQS

A5/5.0
Behavior5/5

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.

Conciseness5/5

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.

Completeness5/5

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.

Parameters5/5

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.

Purpose5/5

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.

Usage Guidelines5/5

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_chunkA
Read-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.

ParametersJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format: 'raw' (default, standard diff), 'annotated' (line numbers, new/old hunk separation), 'compact' (line numbers, new hunks only)raw
chunk_numberYesThe chunk number to retrieve (1-indexed)
include_contextNoInclude chunk header with metadata
absolute_file_pathYesAbsolute path to the diff file

TDQS

A4.4/5.0
Behavior4/5

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.

Conciseness4/5

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.

Completeness5/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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_diffA
Read-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.

ParametersJSON Schema
NameRequiredDescriptionDefault
file_pathYesExact file path or glob pattern matching a single file within the diff (e.g., 'src/main.py', '*.config')
absolute_file_pathYesAbsolute path to the diff file

TDQS

A4.9/5.0
Behavior5/5

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.

Conciseness5/5

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.

Completeness5/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 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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines5/5

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_chunksA
Read-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.

ParametersJSON Schema
NameRequiredDescriptionDefault
absolute_file_pathYesAbsolute path to the diff file

TDQS

A4.7/5.0
Behavior4/5

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.

Conciseness4/5

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.

Completeness5/5

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.

Parameters5/5

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.

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: '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.

Usage Guidelines5/5

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_diffA
Read-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.

ParametersJSON Schema
NameRequiredDescriptionDefault
skip_trivialNoSkip whitespace-only changes
context_linesNoNumber of context lines around each change (default: keep all from diff file)
skip_generatedNoSkip generated files and build artifacts
max_chunk_linesNoMaximum lines per chunk
exclude_patternsNoComma-separated glob patterns for files to exclude
include_patternsNoComma-separated glob patterns for files to include
absolute_file_pathYesAbsolute path to the diff file to load

TDQS

A4.5/5.0
Behavior4/5

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.

Conciseness4/5

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.

Completeness4/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines5/5

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.

TDQS

A4.7/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: loading, listing, chunk retrieval, file-pattern search, and full file diff. No overlap or ambiguity.

Naming Consistency5/5

All tool names follow the consistent snake_case verb_noun pattern (e.g., load_diff, list_chunks). Predictable and clear.

Tool Count5/5

5 tools is well-scoped for a diff chunking server. Each tool serves a necessary function without being superfluous.

Completeness5/5

The toolset covers loading, listing, searching, and retrieving diff content. No obvious missing operations for the domain.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    Enables 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.
    1
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Reduces 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.
    13
    2
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides 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.
    66
    218
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/peteretelej/diffchunk'

If you have feedback or need assistance with the MCP directory API, please join our Discord server