@@ -20,31 +20,22 @@ func searchRepositories(client *github.Client, t translations.TranslationHelperF
2020 mcp .Required (),
2121 mcp .Description ("Search query" ),
2222 ),
23- mcp .WithNumber ("page" ,
24- mcp .Description ("Page number for pagination" ),
25- ),
26- mcp .WithNumber ("perPage" ,
27- mcp .Description ("Results per page (max 100)" ),
28- ),
23+ withPagination (),
2924 ),
3025 func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
3126 query , err := requiredParam [string ](request , "query" )
3227 if err != nil {
3328 return mcp .NewToolResultError (err .Error ()), nil
3429 }
35- page , err := optionalIntParamWithDefault (request , "page" , 1 )
36- if err != nil {
37- return mcp .NewToolResultError (err .Error ()), nil
38- }
39- perPage , err := optionalIntParamWithDefault (request , "perPage" , 30 )
30+ pagination , err := optionalPaginationParams (request )
4031 if err != nil {
4132 return mcp .NewToolResultError (err .Error ()), nil
4233 }
4334
4435 opts := & github.SearchOptions {
4536 ListOptions : github.ListOptions {
46- Page : page ,
47- PerPage : perPage ,
37+ Page : pagination . page ,
38+ PerPage : pagination . perPage ,
4839 },
4940 }
5041
@@ -86,15 +77,7 @@ func searchCode(client *github.Client, t translations.TranslationHelperFunc) (to
8677 mcp .Description ("Sort order ('asc' or 'desc')" ),
8778 mcp .Enum ("asc" , "desc" ),
8879 ),
89- mcp .WithNumber ("perPage" ,
90- mcp .Description ("Results per page (max 100)" ),
91- mcp .Min (1 ),
92- mcp .Max (100 ),
93- ),
94- mcp .WithNumber ("page" ,
95- mcp .Description ("Page number" ),
96- mcp .Min (1 ),
97- ),
80+ withPagination (),
9881 ),
9982 func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
10083 query , err := requiredParam [string ](request , "q" )
@@ -109,11 +92,7 @@ func searchCode(client *github.Client, t translations.TranslationHelperFunc) (to
10992 if err != nil {
11093 return mcp .NewToolResultError (err .Error ()), nil
11194 }
112- perPage , err := optionalIntParamWithDefault (request , "perPage" , 30 )
113- if err != nil {
114- return mcp .NewToolResultError (err .Error ()), nil
115- }
116- page , err := optionalIntParamWithDefault (request , "page" , 1 )
95+ pagination , err := optionalPaginationParams (request )
11796 if err != nil {
11897 return mcp .NewToolResultError (err .Error ()), nil
11998 }
@@ -122,8 +101,8 @@ func searchCode(client *github.Client, t translations.TranslationHelperFunc) (to
122101 Sort : sort ,
123102 Order : order ,
124103 ListOptions : github.ListOptions {
125- PerPage : perPage ,
126- Page : page ,
104+ PerPage : pagination . perPage ,
105+ Page : pagination . page ,
127106 },
128107 }
129108
@@ -166,15 +145,7 @@ func searchUsers(client *github.Client, t translations.TranslationHelperFunc) (t
166145 mcp .Description ("Sort order ('asc' or 'desc')" ),
167146 mcp .Enum ("asc" , "desc" ),
168147 ),
169- mcp .WithNumber ("perPage" ,
170- mcp .Description ("Results per page (max 100)" ),
171- mcp .Min (1 ),
172- mcp .Max (100 ),
173- ),
174- mcp .WithNumber ("page" ,
175- mcp .Description ("Page number" ),
176- mcp .Min (1 ),
177- ),
148+ withPagination (),
178149 ),
179150 func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
180151 query , err := requiredParam [string ](request , "q" )
@@ -189,11 +160,7 @@ func searchUsers(client *github.Client, t translations.TranslationHelperFunc) (t
189160 if err != nil {
190161 return mcp .NewToolResultError (err .Error ()), nil
191162 }
192- perPage , err := optionalIntParamWithDefault (request , "perPage" , 30 )
193- if err != nil {
194- return mcp .NewToolResultError (err .Error ()), nil
195- }
196- page , err := optionalIntParamWithDefault (request , "page" , 1 )
163+ pagination , err := optionalPaginationParams (request )
197164 if err != nil {
198165 return mcp .NewToolResultError (err .Error ()), nil
199166 }
@@ -202,8 +169,8 @@ func searchUsers(client *github.Client, t translations.TranslationHelperFunc) (t
202169 Sort : sort ,
203170 Order : order ,
204171 ListOptions : github.ListOptions {
205- PerPage : perPage ,
206- Page : page ,
172+ PerPage : pagination . perPage ,
173+ Page : pagination . page ,
207174 },
208175 }
209176
0 commit comments