@@ -333,6 +333,10 @@ func ListSubIssues(getClient GetClientFn, t translations.TranslationHelperFunc)
333333}
334334
335335// 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
336340func RemoveSubIssue (getClient GetClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
337341 return mcp .NewTool ("remove_sub_issue" ,
338342 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)
384388 requestBody := map [string ]interface {}{
385389 "sub_issue_id" : subIssueID ,
386390 }
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
390391 reqBodyBytes , err := json .Marshal (requestBody )
391392 if err != nil {
392393 return nil , fmt .Errorf ("failed to marshal request body: %w" , err )
393394 }
394395
396+ // Create the HTTP request
395397 url := fmt .Sprintf ("%srepos/%s/%s/issues/%d/sub_issue" ,
396398 client .BaseURL .String (), owner , repo , issueNumber )
397399 req , err := http .NewRequestWithContext (ctx , "DELETE" , url , strings .NewReader (string (reqBodyBytes )))
398400 if err != nil {
399401 return nil , fmt .Errorf ("failed to create request: %w" , err )
400402 }
401-
402403 req .Header .Set ("Accept" , "application/vnd.github+json" )
403404 req .Header .Set ("Content-Type" , "application/json" )
404405 req .Header .Set ("X-GitHub-Api-Version" , "2022-11-28" )
405406
406- // Use the same authentication as the GitHub client
407- httpClient := client .Client ()
407+ httpClient := client .Client () // Use authenticated GitHub client
408408 resp , err := httpClient .Do (req )
409409 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
411415 }
412416 defer func () { _ = resp .Body .Close () }()
413417
0 commit comments