Labsco
peteretelej logo

Diffchunk

โ˜… 8

from peteretelej

Navigate large diff files with intelligent chunking and navigation tools.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

diffchunk

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.

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)

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

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