Skip to content

Commit 4e88e65

Browse files
committed
fix issue with pagination in search_repositories
1 parent 270bbf7 commit 4e88e65

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pkg/github/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func searchRepositories(client *github.Client, t translations.TranslationHelperF
3636
if err != nil {
3737
return mcp.NewToolResultError(err.Error()), nil
3838
}
39-
perPage, err := optionalIntParamWithDefault(request, "per_page", 30)
39+
perPage, err := optionalIntParamWithDefault(request, "perPage", 30)
4040
if err != nil {
4141
return mcp.NewToolResultError(err.Error()), nil
4242
}

pkg/github/search_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,28 @@ func Test_SearchRepositories(t *testing.T) {
9999
expectError: false,
100100
expectedResult: mockSearchResult,
101101
},
102+
{
103+
name: "repository search with custom pagination",
104+
mockedClient: mock.NewMockedHTTPClient(
105+
mock.WithRequestMatchHandler(
106+
mock.GetSearchRepositories,
107+
expectQueryParams(t, map[string]string{
108+
"q": "golang test",
109+
"page": "2",
110+
"per_page": "5",
111+
}).andThen(
112+
mockResponse(t, http.StatusOK, mockSearchResult),
113+
),
114+
),
115+
),
116+
requestArgs: map[string]interface{}{
117+
"query": "golang test",
118+
"page": float64(2),
119+
"perPage": float64(5),
120+
},
121+
expectError: false,
122+
expectedResult: mockSearchResult,
123+
},
102124
{
103125
name: "search fails",
104126
mockedClient: mock.NewMockedHTTPClient(

0 commit comments

Comments
 (0)