Content-Length: 4222 | pFad | http://github.com/github/github-mcp-server/pull/561.patch
thub.com
From 168e7c6835085a6b0f4c63792fc07dfcf81c8488 Mon Sep 17 00:00:00 2001
From: Anant rustagi
Date: Fri, 20 Jun 2025 18:00:19 -0700
Subject: [PATCH] feat: add pagination support to get_pull_request_files tool
- 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 snapshot
Fixes #527
---
.../__toolsnaps__/get_pull_request_files.snap | 11 ++++++++++
pkg/github/pullrequests.go | 10 +++++++++-
pkg/github/pullrequests_test.go | 20 +++++++++++++++++++
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/pkg/github/__toolsnaps__/get_pull_request_files.snap b/pkg/github/__toolsnaps__/get_pull_request_files.snap
index c61f5f357..148053b17 100644
--- a/pkg/github/__toolsnaps__/get_pull_request_files.snap
+++ b/pkg/github/__toolsnaps__/get_pull_request_files.snap
@@ -10,6 +10,17 @@
"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"
diff --git a/pkg/github/pullrequests.go b/pkg/github/pullrequests.go
index b16920aa2..4e54bdd74 100644
--- a/pkg/github/pullrequests.go
+++ b/pkg/github/pullrequests.go
@@ -532,6 +532,7 @@ func GetPullRequestFiles(getClient GetClientFn, t translations.TranslationHelper
mcp.Required(),
mcp.Description("Pull request number"),
),
+ WithPagination(),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
owner, err := RequiredParam[string](request, "owner")
@@ -546,12 +547,19 @@ func GetPullRequestFiles(getClient GetClientFn, t translations.TranslationHelper
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
+ pagination, err := OptionalPaginationParams(request)
+ if err != nil {
+ return mcp.NewToolResultError(err.Error()), nil
+ }
client, err := getClient(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
}
- opts := &github.ListOptions{}
+ opts := &github.ListOptions{
+ PerPage: pagination.perPage,
+ Page: pagination.page,
+ }
files, resp, err := client.PullRequests.ListFiles(ctx, owner, repo, pullNumber, opts)
if err != nil {
return nil, fmt.Errorf("failed to get pull request files: %w", err)
diff --git a/pkg/github/pullrequests_test.go b/pkg/github/pullrequests_test.go
index 144c6b384..fef986d8e 100644
--- a/pkg/github/pullrequests_test.go
+++ b/pkg/github/pullrequests_test.go
@@ -568,6 +568,8 @@ func Test_GetPullRequestFiles(t *testing.T) {
assert.Contains(t, tool.InputSchema.Properties, "owner")
assert.Contains(t, tool.InputSchema.Properties, "repo")
assert.Contains(t, tool.InputSchema.Properties, "pullNumber")
+ assert.Contains(t, tool.InputSchema.Properties, "page")
+ assert.Contains(t, tool.InputSchema.Properties, "perPage")
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "pullNumber"})
// Setup mock PR files for success case
@@ -614,6 +616,24 @@ func Test_GetPullRequestFiles(t *testing.T) {
expectError: false,
expectedFiles: mockFiles,
},
+ {
+ name: "successful files fetch with pagination",
+ mockedClient: mock.NewMockedHTTPClient(
+ mock.WithRequestMatch(
+ mock.GetReposPullsFilesByOwnerByRepoByPullNumber,
+ mockFiles,
+ ),
+ ),
+ requestArgs: map[string]interface{}{
+ "owner": "owner",
+ "repo": "repo",
+ "pullNumber": float64(42),
+ "page": float64(2),
+ "perPage": float64(10),
+ },
+ expectError: false,
+ expectedFiles: mockFiles,
+ },
{
name: "files fetch fails",
mockedClient: mock.NewMockedHTTPClient(
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/github/github-mcp-server/pull/561.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy