Skip to content

Cleanup #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: go mod download

- name: Run unit tests
run: go test -race ./...
run: script/test

- name: Build
run: go build -v ./cmd/github-mcp-server
50 changes: 0 additions & 50 deletions pkg/github/discussions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,6 @@ import (
"github.com/shurcooL/githubv4"
)

// GetAllDiscussionCategories retrieves all discussion categories for a repository
// by paginating through all pages and returns them as a map where the key is the
// category name and the value is the category ID.
func GetAllDiscussionCategories(ctx context.Context, client *githubv4.Client, owner, repo string) (map[string]string, error) {
categories := make(map[string]string)
var after string
hasNextPage := true

for hasNextPage {
// Prepare GraphQL query with pagination
var q struct {
Repository struct {
DiscussionCategories struct {
Nodes []struct {
ID githubv4.ID
Name githubv4.String
}
PageInfo struct {
HasNextPage githubv4.Boolean
EndCursor githubv4.String
}
} `graphql:"discussionCategories(first: 100, after: $after)"`
} `graphql:"repository(owner: $owner, name: $repo)"`
}

vars := map[string]interface{}{
"owner": githubv4.String(owner),
"repo": githubv4.String(repo),
"after": githubv4.String(after),
}

if err := client.Query(ctx, &q, vars); err != nil {
return nil, fmt.Errorf("failed to query discussion categories: %w", err)
}

// Add categories to the map
for _, category := range q.Repository.DiscussionCategories.Nodes {
categories[string(category.Name)] = fmt.Sprint(category.ID)
}

// Check if there are more pages
hasNextPage = bool(q.Repository.DiscussionCategories.PageInfo.HasNextPage)
if hasNextPage {
after = string(q.Repository.DiscussionCategories.PageInfo.EndCursor)
}
}

return categories, nil
}

func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("list_discussions",
mcp.WithDescription(t("TOOL_LIST_DISCUSSIONS_DESCRIPTION", "List discussions for a repository")),
Expand Down
1 change: 0 additions & 1 deletion script/lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ BINDIR="$(git rev-parse --show-toplevel)"/bin
BINARY=$BINDIR/golangci-lint
GOLANGCI_LINT_VERSION=v2.2.1


if [ ! -f "$BINARY" ]; then
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s "$GOLANGCI_LINT_VERSION"
fi
Expand Down
3 changes: 3 additions & 0 deletions script/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set -eu

go test -race ./...