diffchunk logo

diffchunk

Community
peteretelej

MCP server for chunking and navigating large diff files in AI-assisted code review

Publisherpeteretelej
Repositorydiffchunk
LanguagePython
Forks
1
Stars
8
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    diffchunk exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    8 stars and 1 forks from the linked repository.

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.

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:

json
{
  "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:

python
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:

python
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:

python
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:

python
# 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:

python
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:

python
# 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:

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

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "peteretelej-diffchunk": {
      "command": "",
      "args": []
    }
  }
}

Use diffchunk MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once diffchunk is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add diffchunk as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the diffchunk MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "peteretelej-diffchunk": {
      "command": "npx",
      "args": [
        "-y",
        "diffchunk"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the diffchunk MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the diffchunk MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use diffchunk to help me with this task?
diffchunk
Sure. I read it.
Here is what I found using diffchunk.

Frequently asked questions

What is the diffchunk MCP server used for?

diffchunk is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use diffchunk MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use diffchunk with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use diffchunk MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With diffchunk connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect diffchunk MCP to TypingMind?

diffchunk runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does diffchunk MCP provide in TypingMind?

diffchunk exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use diffchunk MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If diffchunk requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇