Skip to content

Add pagination support for get_pull_request_diff to handle large PRs #625

Open
@kaovilai

Description

@kaovilai

Problem

The get_pull_request_diff function currently fails when attempting to fetch diffs for large pull requests that exceed the token limit. This makes it impossible to analyze changes in PRs with substantial modifications.

Example Error

Error: MCP tool "get_pull_request_diff" response (36464 tokens) exceeds maximum allowed tokens (25000). 
Please use pagination, filtering, or limit parameters to reduce the response size.

This error was encountered when trying to fetch the diff for vmware-tanzu/velero#9019

Proposed Solution

Add pagination support to the get_pull_request_diff function to handle large diffs by:

  1. Implementing pagination parameters (e.g., page, per_page, or file-based pagination)
  2. Adding options to filter by specific files or paths
  3. Supporting partial diff retrieval with offset/limit parameters

Use Case

This enhancement would enable users to:

  • Analyze large pull requests without hitting token limits
  • Retrieve diffs incrementally for better performance
  • Focus on specific files or directories within a PR

Alternative Workarounds

Currently, users must resort to other methods like:

  • Using get_pull_request_files to list changed files
  • Fetching individual file contents
  • Using the GitHub CLI or API directly

Having built-in pagination would provide a more seamless experience for MCP users working with large codebases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions