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 7dcc2c4fd..d8f424673 100644 --- a/pkg/github/pullrequests.go +++ b/pkg/github/pullrequests.go @@ -553,6 +553,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") @@ -567,12 +568,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 ghErrors.NewGitHubAPIErrorResponse(ctx, diff --git a/pkg/github/pullrequests_test.go b/pkg/github/pullrequests_test.go index 02575c439..e0966f805 100644 --- a/pkg/github/pullrequests_test.go +++ b/pkg/github/pullrequests_test.go @@ -576,6 +576,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 @@ -622,6 +624,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(
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: