Skip to content
Open
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
10 changes: 6 additions & 4 deletions pkg/github/discussions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"github.com/shurcooL/githubv4"
)

const errFailedToGetGQLClient = "failed to get GitHub GQL client: %v"

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 Expand Up @@ -51,7 +53,7 @@

client, err := getGQLClient(ctx)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("failed to get GitHub GQL client: %v", err)), nil
return mcp.NewToolResultError(fmt.Sprintf(errFailedToGetGQLClient, err)), nil
}

// If category filter is specified, use it as the category ID for server-side filtering
Expand All @@ -67,7 +69,7 @@
// Query with category filter (server-side filtering)
var query struct {
Repository struct {
Discussions struct {

Check warning on line 72 in pkg/github/discussions.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested anonymous struct into a named type for better readability and reusability.

See more on https://sonarcloud.io/project/issues?id=COG-GTM_github-mcp-server&issues=AZ1zOQHRTAyY_RG9KdHZ&open=AZ1zOQHRTAyY_RG9KdHZ&pullRequest=138
Nodes []struct {
Number githubv4.Int
Title githubv4.String
Expand Down Expand Up @@ -108,7 +110,7 @@
// Query without category filter
var query struct {
Repository struct {
Discussions struct {

Check warning on line 113 in pkg/github/discussions.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested anonymous struct into a named type for better readability and reusability.

See more on https://sonarcloud.io/project/issues?id=COG-GTM_github-mcp-server&issues=AZ1zOQHRTAyY_RG9KdHa&open=AZ1zOQHRTAyY_RG9KdHa&pullRequest=138
Nodes []struct {
Number githubv4.Int
Title githubv4.String
Expand Down Expand Up @@ -187,18 +189,18 @@
}
client, err := getGQLClient(ctx)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("failed to get GitHub GQL client: %v", err)), nil
return mcp.NewToolResultError(fmt.Sprintf(errFailedToGetGQLClient, err)), nil
}

var q struct {
Repository struct {
Discussion struct {

Check warning on line 197 in pkg/github/discussions.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested anonymous struct into a named type for better readability and reusability.

See more on https://sonarcloud.io/project/issues?id=COG-GTM_github-mcp-server&issues=AZ1zOQHRTAyY_RG9KdHb&open=AZ1zOQHRTAyY_RG9KdHb&pullRequest=138
Number githubv4.Int
Body githubv4.String
State githubv4.String
CreatedAt githubv4.DateTime
URL githubv4.String `graphql:"url"`
Category struct {

Check warning on line 203 in pkg/github/discussions.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested anonymous struct into a named type for better readability and reusability.

See more on https://sonarcloud.io/project/issues?id=COG-GTM_github-mcp-server&issues=AZ1zOQHRTAyY_RG9KdHc&open=AZ1zOQHRTAyY_RG9KdHc&pullRequest=138
Name githubv4.String
} `graphql:"category"`
} `graphql:"discussion(number: $discussionNumber)"`
Expand Down Expand Up @@ -258,13 +260,13 @@

client, err := getGQLClient(ctx)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("failed to get GitHub GQL client: %v", err)), nil
return mcp.NewToolResultError(fmt.Sprintf(errFailedToGetGQLClient, err)), nil
}

var q struct {
Repository struct {
Discussion struct {

Check warning on line 268 in pkg/github/discussions.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested anonymous struct into a named type for better readability and reusability.

See more on https://sonarcloud.io/project/issues?id=COG-GTM_github-mcp-server&issues=AZ1zOQHRTAyY_RG9KdHd&open=AZ1zOQHRTAyY_RG9KdHd&pullRequest=138
Comments struct {

Check warning on line 269 in pkg/github/discussions.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested anonymous struct into a named type for better readability and reusability.

See more on https://sonarcloud.io/project/issues?id=COG-GTM_github-mcp-server&issues=AZ1zOQHRTAyY_RG9KdHe&open=AZ1zOQHRTAyY_RG9KdHe&pullRequest=138
Nodes []struct {
Body githubv4.String
}
Expand Down Expand Up @@ -356,11 +358,11 @@

client, err := getGQLClient(ctx)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("failed to get GitHub GQL client: %v", err)), nil
return mcp.NewToolResultError(fmt.Sprintf(errFailedToGetGQLClient, err)), nil
}
var q struct {
Repository struct {
DiscussionCategories struct {

Check warning on line 365 in pkg/github/discussions.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested anonymous struct into a named type for better readability and reusability.

See more on https://sonarcloud.io/project/issues?id=COG-GTM_github-mcp-server&issues=AZ1zOQHRTAyY_RG9KdHf&open=AZ1zOQHRTAyY_RG9KdHf&pullRequest=138
Nodes []struct {
ID githubv4.ID
Name githubv4.String
Expand Down