@@ -20,31 +20,22 @@ func searchRepositories(client *github.Client, t translations.TranslationHelperF
20
20
mcp .Required (),
21
21
mcp .Description ("Search query" ),
22
22
),
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 (),
29
24
),
30
25
func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
31
26
query , err := requiredParam [string ](request , "query" )
32
27
if err != nil {
33
28
return mcp .NewToolResultError (err .Error ()), nil
34
29
}
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 )
40
31
if err != nil {
41
32
return mcp .NewToolResultError (err .Error ()), nil
42
33
}
43
34
44
35
opts := & github.SearchOptions {
45
36
ListOptions : github.ListOptions {
46
- Page : page ,
47
- PerPage : perPage ,
37
+ Page : pagination . page ,
38
+ PerPage : pagination . perPage ,
48
39
},
49
40
}
50
41
@@ -86,15 +77,7 @@ func searchCode(client *github.Client, t translations.TranslationHelperFunc) (to
86
77
mcp .Description ("Sort order ('asc' or 'desc')" ),
87
78
mcp .Enum ("asc" , "desc" ),
88
79
),
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 (),
98
81
),
99
82
func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
100
83
query , err := requiredParam [string ](request , "q" )
@@ -109,11 +92,7 @@ func searchCode(client *github.Client, t translations.TranslationHelperFunc) (to
109
92
if err != nil {
110
93
return mcp .NewToolResultError (err .Error ()), nil
111
94
}
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 )
117
96
if err != nil {
118
97
return mcp .NewToolResultError (err .Error ()), nil
119
98
}
@@ -122,8 +101,8 @@ func searchCode(client *github.Client, t translations.TranslationHelperFunc) (to
122
101
Sort : sort ,
123
102
Order : order ,
124
103
ListOptions : github.ListOptions {
125
- PerPage : perPage ,
126
- Page : page ,
104
+ PerPage : pagination . perPage ,
105
+ Page : pagination . page ,
127
106
},
128
107
}
129
108
@@ -166,15 +145,7 @@ func searchUsers(client *github.Client, t translations.TranslationHelperFunc) (t
166
145
mcp .Description ("Sort order ('asc' or 'desc')" ),
167
146
mcp .Enum ("asc" , "desc" ),
168
147
),
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 (),
178
149
),
179
150
func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
180
151
query , err := requiredParam [string ](request , "q" )
@@ -189,11 +160,7 @@ func searchUsers(client *github.Client, t translations.TranslationHelperFunc) (t
189
160
if err != nil {
190
161
return mcp .NewToolResultError (err .Error ()), nil
191
162
}
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 )
197
164
if err != nil {
198
165
return mcp .NewToolResultError (err .Error ()), nil
199
166
}
@@ -202,8 +169,8 @@ func searchUsers(client *github.Client, t translations.TranslationHelperFunc) (t
202
169
Sort : sort ,
203
170
Order : order ,
204
171
ListOptions : github.ListOptions {
205
- PerPage : perPage ,
206
- Page : page ,
172
+ PerPage : pagination . perPage ,
173
+ Page : pagination . page ,
207
174
},
208
175
}
209
176
0 commit comments