Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add pagination support to get_pull_request_files tool#561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
anant-rustagi wants to merge1 commit intogithub:main
base:main
Choose a base branch
Loading
fromanant-rustagi:fix-527-add-pagination-to-get-pull-request-files

Conversation

anant-rustagi
Copy link

@anant-rustagianant-rustagi commentedJun 21, 2025
edited
Loading

Add pagination support toget_pull_request_files tool

Fixes#527

Problem

Theget_pull_request_files tool currently retrieves only the first 30 files with diffs of any PR that contains more than 30 files. This is a limitation because large PRs with many files cannot be fully analyzed.

Solution

Added pagination support to theget_pull_request_files tool by:

  • AddingWithPagination() to the tool definition
  • UsingOptionalPaginationParams(request) to handlepage andperPage parameters
  • Passing pagination parameters to the GitHub APIListFiles call
  • Following the same pattern used by other paginated tools in the codebase

Changes Made

1. Core Implementation (pkg/github/pullrequests.go)

// Added WithPagination() to tool definitionWithPagination(),// Added pagination parameter handlingpagination,err:=OptionalPaginationParams(request)iferr!=nil {returnmcp.NewToolResultError(err.Error()),nil}// Updated GitHub API call to use paginationopts:=&github.ListOptions{PerPage:pagination.perPage,Page:pagination.page,}

2. Test Updates (pkg/github/pullrequests_test.go)

  • Added verification that pagination parameters (page,perPage) are present in tool schema
  • Added test case for successful files fetch with pagination parameters
  • Updated tool schema snapshot to reflect new parameters

3. Schema Snapshot (pkg/github/__toolsnaps__/get_pull_request_files.snap)

  • Automatically updated to include new pagination parameters
  • Ensures schema changes are tracked and validated

Testing Done

1. Unit Tests

# All tests passgotest ./pkg/github -v

Test Results:

  • Test_GetPullRequestFiles - All test cases pass including new pagination test
  • ✅ Schema verification - Confirmspage andperPage parameters are present
  • ✅ Pagination functionality - Verifies tool works with pagination parameters

2. Integration Testing

# Verified tool schema includes pagination parametersGITHUB_PERSONAL_ACCESS_TOKEN=xxx ./mcpcurl --stdio-server-cmd="./github-mcp-server stdio --toolsets pull_requests" schema

Schema Verification:

{"name":"get_pull_request_files","inputSchema": {"properties": {"owner": {"description":"Repository owner","type":"string"},"page": {"description":"Page number for pagination (min 1)","minimum":1,"type":"number"},"perPage": {"description":"Results per page for pagination (min 1, max 100)","maximum":100,"minimum":1,"type":"number"},"pullNumber": {"description":"Pull request number","type":"number"},"repo": {"description":"Repository name","type":"string"}    },"required": ["owner","repo","pullNumber"]  }}

3. GitHub API Verification

# Verified GitHub API supports pagination for PR filescurl -H"Authorization: token xxx""https://api.github.com/repos/github/github-mcp-server/pulls/521/files?per_page=2&page=1"

API Response: Successfully returned paginated results with 2 files per page.

4. Build Verification

# Server builds successfully with changesgo build -o github-mcp-server cmd/github-mcp-server/main.go

Usage Examples

Default behavior (no pagination parameters):

{"owner":"github","repo":"github-mcp-server","pullNumber":123}

With pagination:

{"owner":"github","repo":"github-mcp-server","pullNumber":123,"page":2,"perPage":10}

Backward Compatibility

  • Fully backward compatible - Existing calls without pagination parameters work exactly as before
  • Optional parameters -page andperPage are optional with sensible defaults
  • Same response format - Returns the same JSON structure as before

Impact

  • Large PRs: Can now analyze PRs with more than 30 files
  • Performance: Users can control the number of files retrieved per request
  • Flexibility: Supports both default behavior and custom pagination

Files Changed

  • pkg/github/pullrequests.go - Core implementation
  • pkg/github/pullrequests_test.go - Test updates
  • pkg/github/__toolsnaps__/get_pull_request_files.snap - Schema snapshot

- Add WithPagination() to tool definition- Use OptionalPaginationParams to handle page and perPage parameters- Pass pagination parameters to GitHub API ListFiles call- Update tests to include pagination scenarios- Update tool schema snapshotFixesgithub#527
@anant-rustagianant-rustagi requested a review froma team as acode ownerJune 21, 2025 01:04
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add pagination support to theget_pull_request_files tool.
1 participant
@anant-rustagi

[8]ページ先頭

©2009-2025 Movatter.jp