@@ -13,56 +13,6 @@ import (
13
13
"github.com/shurcooL/githubv4"
14
14
)
15
15
16
- // GetAllDiscussionCategories retrieves all discussion categories for a repository
17
- // by paginating through all pages and returns them as a map where the key is the
18
- // category name and the value is the category ID.
19
- func GetAllDiscussionCategories (ctx context.Context , client * githubv4.Client , owner , repo string ) (map [string ]string , error ) {
20
- categories := make (map [string ]string )
21
- var after string
22
- hasNextPage := true
23
-
24
- for hasNextPage {
25
- // Prepare GraphQL query with pagination
26
- var q struct {
27
- Repository struct {
28
- DiscussionCategories struct {
29
- Nodes []struct {
30
- ID githubv4.ID
31
- Name githubv4.String
32
- }
33
- PageInfo struct {
34
- HasNextPage githubv4.Boolean
35
- EndCursor githubv4.String
36
- }
37
- } `graphql:"discussionCategories(first: 100, after: $after)"`
38
- } `graphql:"repository(owner: $owner, name: $repo)"`
39
- }
40
-
41
- vars := map [string ]interface {}{
42
- "owner" : githubv4 .String (owner ),
43
- "repo" : githubv4 .String (repo ),
44
- "after" : githubv4 .String (after ),
45
- }
46
-
47
- if err := client .Query (ctx , & q , vars ); err != nil {
48
- return nil , fmt .Errorf ("failed to query discussion categories: %w" , err )
49
- }
50
-
51
- // Add categories to the map
52
- for _ , category := range q .Repository .DiscussionCategories .Nodes {
53
- categories [string (category .Name )] = fmt .Sprint (category .ID )
54
- }
55
-
56
- // Check if there are more pages
57
- hasNextPage = bool (q .Repository .DiscussionCategories .PageInfo .HasNextPage )
58
- if hasNextPage {
59
- after = string (q .Repository .DiscussionCategories .PageInfo .EndCursor )
60
- }
61
- }
62
-
63
- return categories , nil
64
- }
65
-
66
16
func ListDiscussions (getGQLClient GetGQLClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
67
17
return mcp .NewTool ("list_discussions" ,
68
18
mcp .WithDescription (t ("TOOL_LIST_DISCUSSIONS_DESCRIPTION" , "List discussions for a repository" )),
0 commit comments