@@ -333,6 +333,10 @@ func ListSubIssues(getClient GetClientFn, t translations.TranslationHelperFunc)
333
333
}
334
334
335
335
// RemoveSubIssue creates a tool to remove a sub-issue from a parent issue.
336
+ // Unlike other sub-issue tools, this currently uses a direct HTTP DELETE request
337
+ // because of a bug in the go-github library.
338
+ // Once the fix is released, this can be updated to use the library method.
339
+ // See: https://github.com/google/go-github/pull/3613
336
340
func RemoveSubIssue (getClient GetClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
337
341
return mcp .NewTool ("remove_sub_issue" ,
338
342
mcp .WithDescription (t ("TOOL_REMOVE_SUB_ISSUE_DESCRIPTION" , "Remove a sub-issue from a parent issue in a GitHub repository." )),
@@ -384,30 +388,30 @@ func RemoveSubIssue(getClient GetClientFn, t translations.TranslationHelperFunc)
384
388
requestBody := map [string ]interface {}{
385
389
"sub_issue_id" : subIssueID ,
386
390
}
387
-
388
- // Since the go-github library might not have sub-issues support yet,
389
- // we'll make a direct HTTP request using the client's HTTP client
390
391
reqBodyBytes , err := json .Marshal (requestBody )
391
392
if err != nil {
392
393
return nil , fmt .Errorf ("failed to marshal request body: %w" , err )
393
394
}
394
395
396
+ // Create the HTTP request
395
397
url := fmt .Sprintf ("%srepos/%s/%s/issues/%d/sub_issue" ,
396
398
client .BaseURL .String (), owner , repo , issueNumber )
397
399
req , err := http .NewRequestWithContext (ctx , "DELETE" , url , strings .NewReader (string (reqBodyBytes )))
398
400
if err != nil {
399
401
return nil , fmt .Errorf ("failed to create request: %w" , err )
400
402
}
401
-
402
403
req .Header .Set ("Accept" , "application/vnd.github+json" )
403
404
req .Header .Set ("Content-Type" , "application/json" )
404
405
req .Header .Set ("X-GitHub-Api-Version" , "2022-11-28" )
405
406
406
- // Use the same authentication as the GitHub client
407
- httpClient := client .Client ()
407
+ httpClient := client .Client () // Use authenticated GitHub client
408
408
resp , err := httpClient .Do (req )
409
409
if err != nil {
410
- return nil , fmt .Errorf ("failed to remove sub-issue: %w" , err )
410
+ return ghErrors .NewGitHubAPIErrorResponse (ctx ,
411
+ "failed to remove sub-issue" ,
412
+ & github.Response {Response : resp },
413
+ err ,
414
+ ), nil
411
415
}
412
416
defer func () { _ = resp .Body .Close () }()
413
417
0 commit comments