Skip to main content

MCP server for navigating large diff files with intelligent chunking

Project description

diffchunk

CI codecov PyPI version Python 3.10+ License: MIT Ruff 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.

Solution

MCP server with 4 navigation tools:

  • load_diff - Parse diff file with custom settings (optional)
  • list_chunks - Show chunk overview with file mappings (auto-loads)
  • get_chunk - Retrieve specific chunk content (auto-loads)
  • find_chunks_for_files - Locate chunks by file patterns (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
  3. Uses find_chunks_for_files to locate relevant sections when you ask about specific file types
  4. Uses get_chunk to examine specific sections without loading the entire diff into context
  5. Tracks progress systematically through large changesets, analyzing chunk by chunk
  6. 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

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

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*"
)

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 - Development setup and workflows

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_peteretelej_diffchunk-0.1.7.tar.gz (5.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_peteretelej_diffchunk-0.1.7-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_peteretelej_diffchunk-0.1.7.tar.gz.

File metadata

  • Download URL: iflow_mcp_peteretelej_diffchunk-0.1.7.tar.gz
  • Upload date:
  • Size: 5.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_peteretelej_diffchunk-0.1.7.tar.gz
Algorithm Hash digest
SHA256 11882f14dfdbea932cbb97f77cd3536ea932fd8e550a7f9ed21c544d3d34263e
MD5 35076b68bfbd9c6462d704af4f40cbd9
BLAKE2b-256 bc0988ffef06942c8c241288d4b55bb0675d1c7124fda7371e2541482907f5d1

See more details on using hashes here.

File details

Details for the file iflow_mcp_peteretelej_diffchunk-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_peteretelej_diffchunk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_peteretelej_diffchunk-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 2e955ba8db1d9f82e0001200672fba992f0d90bd2e5fd040d704358b82519b28
MD5 bc58f9aad47cd0b311355cea67fbf4b0
BLAKE2b-256 d5e490d4e2f76530fdc03a204fbd8d93f6266dcf5c57b5b5f645e7a8a871c5a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page