@@ -163,29 +163,41 @@ func GetDefaultToolsetIDs() []string {
163163func DefaultToolsetGroup (readOnly bool , getClient GetClientFn , getGQLClient GetGQLClientFn , getRawClient raw.GetRawClientFn , t translations.TranslationHelperFunc , contentWindowSize int , flags FeatureFlags , cache * lockdown.RepoAccessCache ) * toolsets.ToolsetGroup {
164164 tsg := toolsets .NewToolsetGroup (readOnly )
165165
166+ // Create the dependencies struct that will be passed to all tool handlers
167+ deps := toolsets.ToolDependencies {
168+ GetClient : getClient ,
169+ GetGQLClient : getGQLClient ,
170+ GetRawClient : getRawClient ,
171+ RepoAccessCache : cache ,
172+ T : t ,
173+ Flags : flags ,
174+ ContentWindowSize : contentWindowSize ,
175+ }
176+
166177 // Define all available features with their default state (disabled)
167178 // Create toolsets
168179 repos := toolsets .NewToolset (ToolsetMetadataRepos .ID , ToolsetMetadataRepos .Description ).
180+ SetDependencies (deps ).
169181 AddReadTools (
170- toolsets .NewServerTool (SearchRepositories (getClient , t )),
171- toolsets .NewServerTool (GetFileContents (getClient , getRawClient , t )),
172- toolsets .NewServerTool (ListCommits (getClient , t )),
173- toolsets .NewServerTool (SearchCode (getClient , t )),
174- toolsets .NewServerTool (GetCommit (getClient , t )),
175- toolsets .NewServerTool (ListBranches (getClient , t )),
176- toolsets .NewServerTool (ListTags (getClient , t )),
177- toolsets .NewServerTool (GetTag (getClient , t )),
178- toolsets .NewServerTool (ListReleases (getClient , t )),
179- toolsets .NewServerTool (GetLatestRelease (getClient , t )),
180- toolsets .NewServerTool (GetReleaseByTag (getClient , t )),
182+ toolsets .NewServerToolLegacy (SearchRepositories (getClient , t )),
183+ toolsets .NewServerToolLegacy (GetFileContents (getClient , getRawClient , t )),
184+ toolsets .NewServerToolLegacy (ListCommits (getClient , t )),
185+ toolsets .NewServerToolLegacy (SearchCode (getClient , t )),
186+ toolsets .NewServerToolLegacy (GetCommit (getClient , t )),
187+ toolsets .NewServerToolLegacy (ListBranches (getClient , t )),
188+ toolsets .NewServerToolLegacy (ListTags (getClient , t )),
189+ toolsets .NewServerToolLegacy (GetTag (getClient , t )),
190+ toolsets .NewServerToolLegacy (ListReleases (getClient , t )),
191+ toolsets .NewServerToolLegacy (GetLatestRelease (getClient , t )),
192+ toolsets .NewServerToolLegacy (GetReleaseByTag (getClient , t )),
181193 ).
182194 AddWriteTools (
183- toolsets .NewServerTool (CreateOrUpdateFile (getClient , t )),
184- toolsets .NewServerTool (CreateRepository (getClient , t )),
185- toolsets .NewServerTool (ForkRepository (getClient , t )),
186- toolsets .NewServerTool (CreateBranch (getClient , t )),
187- toolsets .NewServerTool (PushFiles (getClient , t )),
188- toolsets .NewServerTool (DeleteFile (getClient , t )),
195+ toolsets .NewServerToolLegacy (CreateOrUpdateFile (getClient , t )),
196+ toolsets .NewServerToolLegacy (CreateRepository (getClient , t )),
197+ toolsets .NewServerToolLegacy (ForkRepository (getClient , t )),
198+ toolsets .NewServerToolLegacy (CreateBranch (getClient , t )),
199+ toolsets .NewServerToolLegacy (PushFiles (getClient , t )),
200+ toolsets .NewServerToolLegacy (DeleteFile (getClient , t )),
189201 ).
190202 AddResourceTemplates (
191203 toolsets .NewServerResourceTemplate (GetRepositoryResourceContent (getClient , getRawClient , t )),
@@ -195,166 +207,184 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG
195207 toolsets .NewServerResourceTemplate (GetRepositoryResourcePrContent (getClient , getRawClient , t )),
196208 )
197209 git := toolsets .NewToolset (ToolsetMetadataGit .ID , ToolsetMetadataGit .Description ).
210+ SetDependencies (deps ).
198211 AddReadTools (
199- toolsets .NewServerTool (GetRepositoryTree (getClient , t )),
212+ toolsets .NewServerToolLegacy (GetRepositoryTree (getClient , t )),
200213 )
201214 issues := toolsets .NewToolset (ToolsetMetadataIssues .ID , ToolsetMetadataIssues .Description ).
215+ SetDependencies (deps ).
202216 AddReadTools (
203- toolsets .NewServerTool (IssueRead (getClient , getGQLClient , cache , t , flags )),
204- toolsets .NewServerTool (SearchIssues (getClient , t )),
205- toolsets .NewServerTool (ListIssues (getGQLClient , t )),
206- toolsets .NewServerTool (ListIssueTypes (getClient , t )),
207- toolsets .NewServerTool (GetLabel (getGQLClient , t )),
217+ toolsets .NewServerToolLegacy (IssueRead (getClient , getGQLClient , cache , t , flags )),
218+ toolsets .NewServerToolLegacy (SearchIssues (getClient , t )),
219+ toolsets .NewServerToolLegacy (ListIssues (getGQLClient , t )),
220+ toolsets .NewServerToolLegacy (ListIssueTypes (getClient , t )),
221+ toolsets .NewServerToolLegacy (GetLabel (getGQLClient , t )),
208222 ).
209223 AddWriteTools (
210- toolsets .NewServerTool (IssueWrite (getClient , getGQLClient , t )),
211- toolsets .NewServerTool (AddIssueComment (getClient , t )),
212- toolsets .NewServerTool (AssignCopilotToIssue (getGQLClient , t )),
213- toolsets .NewServerTool (SubIssueWrite (getClient , t )),
224+ toolsets .NewServerToolLegacy (IssueWrite (getClient , getGQLClient , t )),
225+ toolsets .NewServerToolLegacy (AddIssueComment (getClient , t )),
226+ toolsets .NewServerToolLegacy (AssignCopilotToIssue (getGQLClient , t )),
227+ toolsets .NewServerToolLegacy (SubIssueWrite (getClient , t )),
214228 ).AddPrompts (
215229 toolsets .NewServerPrompt (AssignCodingAgentPrompt (t )),
216230 toolsets .NewServerPrompt (IssueToFixWorkflowPrompt (t )),
217231 )
218232 users := toolsets .NewToolset (ToolsetMetadataUsers .ID , ToolsetMetadataUsers .Description ).
233+ SetDependencies (deps ).
219234 AddReadTools (
220- toolsets .NewServerTool (SearchUsers (getClient , t )),
235+ toolsets .NewServerToolLegacy (SearchUsers (getClient , t )),
221236 )
222237 orgs := toolsets .NewToolset (ToolsetMetadataOrgs .ID , ToolsetMetadataOrgs .Description ).
238+ SetDependencies (deps ).
223239 AddReadTools (
224- toolsets .NewServerTool (SearchOrgs (getClient , t )),
240+ toolsets .NewServerToolLegacy (SearchOrgs (getClient , t )),
225241 )
226242 pullRequests := toolsets .NewToolset (ToolsetMetadataPullRequests .ID , ToolsetMetadataPullRequests .Description ).
243+ SetDependencies (deps ).
227244 AddReadTools (
228- toolsets .NewServerTool (PullRequestRead (getClient , cache , t , flags )),
229- toolsets .NewServerTool (ListPullRequests (getClient , t )),
230- toolsets .NewServerTool (SearchPullRequests (getClient , t )),
245+ toolsets .NewServerToolLegacy (PullRequestRead (getClient , cache , t , flags )),
246+ toolsets .NewServerToolLegacy (ListPullRequests (getClient , t )),
247+ toolsets .NewServerToolLegacy (SearchPullRequests (getClient , t )),
231248 ).
232249 AddWriteTools (
233- toolsets .NewServerTool (MergePullRequest (getClient , t )),
234- toolsets .NewServerTool (UpdatePullRequestBranch (getClient , t )),
235- toolsets .NewServerTool (CreatePullRequest (getClient , t )),
236- toolsets .NewServerTool (UpdatePullRequest (getClient , getGQLClient , t )),
237- toolsets .NewServerTool (RequestCopilotReview (getClient , t )),
250+ toolsets .NewServerToolLegacy (MergePullRequest (getClient , t )),
251+ toolsets .NewServerToolLegacy (UpdatePullRequestBranch (getClient , t )),
252+ toolsets .NewServerToolLegacy (CreatePullRequest (getClient , t )),
253+ toolsets .NewServerToolLegacy (UpdatePullRequest (getClient , getGQLClient , t )),
254+ toolsets .NewServerToolLegacy (RequestCopilotReview (getClient , t )),
238255 // Reviews
239- toolsets .NewServerTool (PullRequestReviewWrite (getGQLClient , t )),
240- toolsets .NewServerTool (AddCommentToPendingReview (getGQLClient , t )),
256+ toolsets .NewServerToolLegacy (PullRequestReviewWrite (getGQLClient , t )),
257+ toolsets .NewServerToolLegacy (AddCommentToPendingReview (getGQLClient , t )),
241258 )
242259 codeSecurity := toolsets .NewToolset (ToolsetMetadataCodeSecurity .ID , ToolsetMetadataCodeSecurity .Description ).
260+ SetDependencies (deps ).
243261 AddReadTools (
244- toolsets .NewServerTool (GetCodeScanningAlert (getClient , t )),
245- toolsets .NewServerTool (ListCodeScanningAlerts (getClient , t )),
262+ toolsets .NewServerToolLegacy (GetCodeScanningAlert (getClient , t )),
263+ toolsets .NewServerToolLegacy (ListCodeScanningAlerts (getClient , t )),
246264 )
247265 secretProtection := toolsets .NewToolset (ToolsetMetadataSecretProtection .ID , ToolsetMetadataSecretProtection .Description ).
266+ SetDependencies (deps ).
248267 AddReadTools (
249- toolsets .NewServerTool (GetSecretScanningAlert (getClient , t )),
250- toolsets .NewServerTool (ListSecretScanningAlerts (getClient , t )),
268+ toolsets .NewServerToolLegacy (GetSecretScanningAlert (getClient , t )),
269+ toolsets .NewServerToolLegacy (ListSecretScanningAlerts (getClient , t )),
251270 )
252271 dependabot := toolsets .NewToolset (ToolsetMetadataDependabot .ID , ToolsetMetadataDependabot .Description ).
272+ SetDependencies (deps ).
253273 AddReadTools (
254- toolsets .NewServerTool (GetDependabotAlert (getClient , t )),
255- toolsets .NewServerTool (ListDependabotAlerts (getClient , t )),
274+ toolsets .NewServerToolLegacy (GetDependabotAlert (getClient , t )),
275+ toolsets .NewServerToolLegacy (ListDependabotAlerts (getClient , t )),
256276 )
257277
258278 notifications := toolsets .NewToolset (ToolsetMetadataNotifications .ID , ToolsetMetadataNotifications .Description ).
279+ SetDependencies (deps ).
259280 AddReadTools (
260- toolsets .NewServerTool (ListNotifications (getClient , t )),
261- toolsets .NewServerTool (GetNotificationDetails (getClient , t )),
281+ toolsets .NewServerToolLegacy (ListNotifications (getClient , t )),
282+ toolsets .NewServerToolLegacy (GetNotificationDetails (getClient , t )),
262283 ).
263284 AddWriteTools (
264- toolsets .NewServerTool (DismissNotification (getClient , t )),
265- toolsets .NewServerTool (MarkAllNotificationsRead (getClient , t )),
266- toolsets .NewServerTool (ManageNotificationSubscription (getClient , t )),
267- toolsets .NewServerTool (ManageRepositoryNotificationSubscription (getClient , t )),
285+ toolsets .NewServerToolLegacy (DismissNotification (getClient , t )),
286+ toolsets .NewServerToolLegacy (MarkAllNotificationsRead (getClient , t )),
287+ toolsets .NewServerToolLegacy (ManageNotificationSubscription (getClient , t )),
288+ toolsets .NewServerToolLegacy (ManageRepositoryNotificationSubscription (getClient , t )),
268289 )
269290
270291 discussions := toolsets .NewToolset (ToolsetMetadataDiscussions .ID , ToolsetMetadataDiscussions .Description ).
292+ SetDependencies (deps ).
271293 AddReadTools (
272- toolsets .NewServerTool (ListDiscussions (getGQLClient , t )),
273- toolsets .NewServerTool (GetDiscussion (getGQLClient , t )),
274- toolsets .NewServerTool (GetDiscussionComments (getGQLClient , t )),
275- toolsets .NewServerTool (ListDiscussionCategories (getGQLClient , t )),
294+ toolsets .NewServerToolLegacy (ListDiscussions (getGQLClient , t )),
295+ toolsets .NewServerToolLegacy (GetDiscussion (getGQLClient , t )),
296+ toolsets .NewServerToolLegacy (GetDiscussionComments (getGQLClient , t )),
297+ toolsets .NewServerToolLegacy (ListDiscussionCategories (getGQLClient , t )),
276298 )
277299
278300 actions := toolsets .NewToolset (ToolsetMetadataActions .ID , ToolsetMetadataActions .Description ).
301+ SetDependencies (deps ).
279302 AddReadTools (
280- toolsets .NewServerTool (ListWorkflows (getClient , t )),
281- toolsets .NewServerTool (ListWorkflowRuns (getClient , t )),
282- toolsets .NewServerTool (GetWorkflowRun (getClient , t )),
283- toolsets .NewServerTool (GetWorkflowRunLogs (getClient , t )),
284- toolsets .NewServerTool (ListWorkflowJobs (getClient , t )),
285- toolsets .NewServerTool (GetJobLogs (getClient , t , contentWindowSize )),
286- toolsets .NewServerTool (ListWorkflowRunArtifacts (getClient , t )),
287- toolsets .NewServerTool (DownloadWorkflowRunArtifact (getClient , t )),
288- toolsets .NewServerTool (GetWorkflowRunUsage (getClient , t )),
303+ toolsets .NewServerToolLegacy (ListWorkflows (getClient , t )),
304+ toolsets .NewServerToolLegacy (ListWorkflowRuns (getClient , t )),
305+ toolsets .NewServerToolLegacy (GetWorkflowRun (getClient , t )),
306+ toolsets .NewServerToolLegacy (GetWorkflowRunLogs (getClient , t )),
307+ toolsets .NewServerToolLegacy (ListWorkflowJobs (getClient , t )),
308+ toolsets .NewServerToolLegacy (GetJobLogs (getClient , t , contentWindowSize )),
309+ toolsets .NewServerToolLegacy (ListWorkflowRunArtifacts (getClient , t )),
310+ toolsets .NewServerToolLegacy (DownloadWorkflowRunArtifact (getClient , t )),
311+ toolsets .NewServerToolLegacy (GetWorkflowRunUsage (getClient , t )),
289312 ).
290313 AddWriteTools (
291- toolsets .NewServerTool (RunWorkflow (getClient , t )),
292- toolsets .NewServerTool (RerunWorkflowRun (getClient , t )),
293- toolsets .NewServerTool (RerunFailedJobs (getClient , t )),
294- toolsets .NewServerTool (CancelWorkflowRun (getClient , t )),
295- toolsets .NewServerTool (DeleteWorkflowRunLogs (getClient , t )),
314+ toolsets .NewServerToolLegacy (RunWorkflow (getClient , t )),
315+ toolsets .NewServerToolLegacy (RerunWorkflowRun (getClient , t )),
316+ toolsets .NewServerToolLegacy (RerunFailedJobs (getClient , t )),
317+ toolsets .NewServerToolLegacy (CancelWorkflowRun (getClient , t )),
318+ toolsets .NewServerToolLegacy (DeleteWorkflowRunLogs (getClient , t )),
296319 )
297320
298321 securityAdvisories := toolsets .NewToolset (ToolsetMetadataSecurityAdvisories .ID , ToolsetMetadataSecurityAdvisories .Description ).
322+ SetDependencies (deps ).
299323 AddReadTools (
300- toolsets .NewServerTool (ListGlobalSecurityAdvisories (getClient , t )),
301- toolsets .NewServerTool (GetGlobalSecurityAdvisory (getClient , t )),
302- toolsets .NewServerTool (ListRepositorySecurityAdvisories (getClient , t )),
303- toolsets .NewServerTool (ListOrgRepositorySecurityAdvisories (getClient , t )),
324+ toolsets .NewServerToolLegacy (ListGlobalSecurityAdvisories (getClient , t )),
325+ toolsets .NewServerToolLegacy (GetGlobalSecurityAdvisory (getClient , t )),
326+ toolsets .NewServerToolLegacy (ListRepositorySecurityAdvisories (getClient , t )),
327+ toolsets .NewServerToolLegacy (ListOrgRepositorySecurityAdvisories (getClient , t )),
304328 )
305329
306330 // // Keep experiments alive so the system doesn't error out when it's always enabled
307- experiments := toolsets .NewToolset (ToolsetMetadataExperiments .ID , ToolsetMetadataExperiments .Description )
331+ experiments := toolsets .NewToolset (ToolsetMetadataExperiments .ID , ToolsetMetadataExperiments .Description ).
332+ SetDependencies (deps )
308333
309334 contextTools := toolsets .NewToolset (ToolsetMetadataContext .ID , ToolsetMetadataContext .Description ).
335+ SetDependencies (deps ).
310336 AddReadTools (
311- toolsets .NewServerTool (GetMe (getClient , t )),
312- toolsets .NewServerTool (GetTeams (getClient , getGQLClient , t )),
313- toolsets .NewServerTool (GetTeamMembers (getGQLClient , t )),
337+ toolsets .NewServerToolLegacy (GetMe (getClient , t )),
338+ toolsets .NewServerToolLegacy (GetTeams (getClient , getGQLClient , t )),
339+ toolsets .NewServerToolLegacy (GetTeamMembers (getGQLClient , t )),
314340 )
315341
316342 gists := toolsets .NewToolset (ToolsetMetadataGists .ID , ToolsetMetadataGists .Description ).
343+ SetDependencies (deps ).
317344 AddReadTools (
318- toolsets .NewServerTool (ListGists (getClient , t )),
319- toolsets .NewServerTool (GetGist (getClient , t )),
345+ toolsets .NewServerToolLegacy (ListGists (getClient , t )),
346+ toolsets .NewServerToolLegacy (GetGist (getClient , t )),
320347 ).
321348 AddWriteTools (
322- toolsets .NewServerTool (CreateGist (getClient , t )),
323- toolsets .NewServerTool (UpdateGist (getClient , t )),
349+ toolsets .NewServerToolLegacy (CreateGist (getClient , t )),
350+ toolsets .NewServerToolLegacy (UpdateGist (getClient , t )),
324351 )
325352
326353 projects := toolsets .NewToolset (ToolsetMetadataProjects .ID , ToolsetMetadataProjects .Description ).
354+ SetDependencies (deps ).
327355 AddReadTools (
328- toolsets .NewServerTool (ListProjects (getClient , t )),
329- toolsets .NewServerTool (GetProject (getClient , t )),
330- toolsets .NewServerTool (ListProjectFields (getClient , t )),
331- toolsets .NewServerTool (GetProjectField (getClient , t )),
332- toolsets .NewServerTool (ListProjectItems (getClient , t )),
333- toolsets .NewServerTool (GetProjectItem (getClient , t )),
356+ toolsets .NewServerToolLegacy (ListProjects (getClient , t )),
357+ toolsets .NewServerToolLegacy (GetProject (getClient , t )),
358+ toolsets .NewServerToolLegacy (ListProjectFields (getClient , t )),
359+ toolsets .NewServerToolLegacy (GetProjectField (getClient , t )),
360+ toolsets .NewServerToolLegacy (ListProjectItems (getClient , t )),
361+ toolsets .NewServerToolLegacy (GetProjectItem (getClient , t )),
334362 ).
335363 AddWriteTools (
336- toolsets .NewServerTool (AddProjectItem (getClient , t )),
337- toolsets .NewServerTool (DeleteProjectItem (getClient , t )),
338- toolsets .NewServerTool (UpdateProjectItem (getClient , t )),
364+ toolsets .NewServerToolLegacy (AddProjectItem (getClient , t )),
365+ toolsets .NewServerToolLegacy (DeleteProjectItem (getClient , t )),
366+ toolsets .NewServerToolLegacy (UpdateProjectItem (getClient , t )),
339367 )
340368 stargazers := toolsets .NewToolset (ToolsetMetadataStargazers .ID , ToolsetMetadataStargazers .Description ).
369+ SetDependencies (deps ).
341370 AddReadTools (
342- toolsets .NewServerTool (ListStarredRepositories (getClient , t )),
371+ toolsets .NewServerToolLegacy (ListStarredRepositories (getClient , t )),
343372 ).
344373 AddWriteTools (
345- toolsets .NewServerTool (StarRepository (getClient , t )),
346- toolsets .NewServerTool (UnstarRepository (getClient , t )),
374+ toolsets .NewServerToolLegacy (StarRepository (getClient , t )),
375+ toolsets .NewServerToolLegacy (UnstarRepository (getClient , t )),
347376 )
348377 labels := toolsets .NewToolset (ToolsetLabels .ID , ToolsetLabels .Description ).
378+ SetDependencies (deps ).
349379 AddReadTools (
350380 // get
351- toolsets .NewServerTool (GetLabel (getGQLClient , t )),
381+ toolsets .NewServerToolLegacy (GetLabel (getGQLClient , t )),
352382 // list labels on repo or issue
353- toolsets .NewServerTool (ListLabels (getGQLClient , t )),
383+ toolsets .NewServerToolLegacy (ListLabels (getGQLClient , t )),
354384 ).
355385 AddWriteTools (
356386 // create or update
357- toolsets .NewServerTool (LabelWrite (getGQLClient , t )),
387+ toolsets .NewServerToolLegacy (LabelWrite (getGQLClient , t )),
358388 )
359389
360390 // Add toolsets to the group
@@ -391,9 +421,9 @@ func InitDynamicToolset(s *mcp.Server, tsg *toolsets.ToolsetGroup, t translation
391421 // Need to add the dynamic toolset last so it can be used to enable other toolsets
392422 dynamicToolSelection := toolsets .NewToolset (ToolsetMetadataDynamic .ID , ToolsetMetadataDynamic .Description ).
393423 AddReadTools (
394- toolsets .NewServerTool (ListAvailableToolsets (tsg , t )),
395- toolsets .NewServerTool (GetToolsetsTools (tsg , t )),
396- toolsets .NewServerTool (EnableToolset (s , tsg , t )),
424+ toolsets .NewServerToolLegacy (ListAvailableToolsets (tsg , t )),
425+ toolsets .NewServerToolLegacy (GetToolsetsTools (tsg , t )),
426+ toolsets .NewServerToolLegacy (EnableToolset (s , tsg , t )),
397427 )
398428
399429 dynamicToolSelection .Enabled = true
0 commit comments