Skip to content

chore: export issues funcs #163

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 3 commits into from
Apr 8, 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
28 changes: 14 additions & 14 deletions pkg/github/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/mark3labs/mcp-go/server"
)

// getIssue creates a tool to get details of a specific issue in a GitHub repository.
func getIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// GetIssue creates a tool to get details of a specific issue in a GitHub repository.
func GetIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("get_issue",
mcp.WithDescription(t("TOOL_GET_ISSUE_DESCRIPTION", "Get details of a specific issue in a GitHub repository")),
mcp.WithString("owner",
Expand Down Expand Up @@ -68,8 +68,8 @@ func getIssue(client *github.Client, t translations.TranslationHelperFunc) (tool
}
}

// addIssueComment creates a tool to add a comment to an issue.
func addIssueComment(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// AddIssueComment creates a tool to add a comment to an issue.
func AddIssueComment(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("add_issue_comment",
mcp.WithDescription(t("TOOL_ADD_ISSUE_COMMENT_DESCRIPTION", "Add a comment to an existing issue")),
mcp.WithString("owner",
Expand Down Expand Up @@ -134,8 +134,8 @@ func addIssueComment(client *github.Client, t translations.TranslationHelperFunc
}
}

// searchIssues creates a tool to search for issues and pull requests.
func searchIssues(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// SearchIssues creates a tool to search for issues and pull requests.
func SearchIssues(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("search_issues",
mcp.WithDescription(t("TOOL_SEARCH_ISSUES_DESCRIPTION", "Search for issues and pull requests across GitHub repositories")),
mcp.WithString("q",
Expand Down Expand Up @@ -214,8 +214,8 @@ func searchIssues(client *github.Client, t translations.TranslationHelperFunc) (
}
}

// createIssue creates a tool to create a new issue in a GitHub repository.
func createIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// CreateIssue creates a tool to create a new issue in a GitHub repository.
func CreateIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("create_issue",
mcp.WithDescription(t("TOOL_CREATE_ISSUE_DESCRIPTION", "Create a new issue in a GitHub repository")),
mcp.WithString("owner",
Expand Down Expand Up @@ -328,8 +328,8 @@ func createIssue(client *github.Client, t translations.TranslationHelperFunc) (t
}
}

// listIssues creates a tool to list and filter repository issues
func listIssues(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// ListIssues creates a tool to list and filter repository issues
func ListIssues(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("list_issues",
mcp.WithDescription(t("TOOL_LIST_ISSUES_DESCRIPTION", "List issues in a GitHub repository with filtering options")),
mcp.WithString("owner",
Expand Down Expand Up @@ -442,8 +442,8 @@ func listIssues(client *github.Client, t translations.TranslationHelperFunc) (to
}
}

// updateIssue creates a tool to update an existing issue in a GitHub repository.
func updateIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// UpdateIssue creates a tool to update an existing issue in a GitHub repository.
func UpdateIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("update_issue",
mcp.WithDescription(t("TOOL_UPDATE_ISSUE_DESCRIPTION", "Update an existing issue in a GitHub repository")),
mcp.WithString("owner",
Expand Down Expand Up @@ -580,8 +580,8 @@ func updateIssue(client *github.Client, t translations.TranslationHelperFunc) (t
}
}

// getIssueComments creates a tool to get comments for a GitHub issue.
func getIssueComments(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// GetIssueComments creates a tool to get comments for a GitHub issue.
func GetIssueComments(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("get_issue_comments",
mcp.WithDescription(t("TOOL_GET_ISSUE_COMMENTS_DESCRIPTION", "Get comments for a GitHub issue")),
mcp.WithString("owner",
Expand Down
28 changes: 14 additions & 14 deletions pkg/github/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func Test_GetIssue(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := getIssue(mockClient, translations.NullTranslationHelper)
tool, _ := GetIssue(mockClient, translations.NullTranslationHelper)

assert.Equal(t, "get_issue", tool.Name)
assert.NotEmpty(t, tool.Description)
Expand Down Expand Up @@ -82,7 +82,7 @@ func Test_GetIssue(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// Setup client with mock
client := github.NewClient(tc.mockedClient)
_, handler := getIssue(client, translations.NullTranslationHelper)
_, handler := GetIssue(client, translations.NullTranslationHelper)

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -114,7 +114,7 @@ func Test_GetIssue(t *testing.T) {
func Test_AddIssueComment(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := addIssueComment(mockClient, translations.NullTranslationHelper)
tool, _ := AddIssueComment(mockClient, translations.NullTranslationHelper)

assert.Equal(t, "add_issue_comment", tool.Name)
assert.NotEmpty(t, tool.Description)
Expand Down Expand Up @@ -185,7 +185,7 @@ func Test_AddIssueComment(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// Setup client with mock
client := github.NewClient(tc.mockedClient)
_, handler := addIssueComment(client, translations.NullTranslationHelper)
_, handler := AddIssueComment(client, translations.NullTranslationHelper)

// Create call request
request := mcp.CallToolRequest{
Expand Down Expand Up @@ -237,7 +237,7 @@ func Test_AddIssueComment(t *testing.T) {
func Test_SearchIssues(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := searchIssues(mockClient, translations.NullTranslationHelper)
tool, _ := SearchIssues(mockClient, translations.NullTranslationHelper)

assert.Equal(t, "search_issues", tool.Name)
assert.NotEmpty(t, tool.Description)
Expand Down Expand Up @@ -352,7 +352,7 @@ func Test_SearchIssues(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// Setup client with mock
client := github.NewClient(tc.mockedClient)
_, handler := searchIssues(client, translations.NullTranslationHelper)
_, handler := SearchIssues(client, translations.NullTranslationHelper)

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -393,7 +393,7 @@ func Test_SearchIssues(t *testing.T) {
func Test_CreateIssue(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := createIssue(mockClient, translations.NullTranslationHelper)
tool, _ := CreateIssue(mockClient, translations.NullTranslationHelper)

assert.Equal(t, "create_issue", tool.Name)
assert.NotEmpty(t, tool.Description)
Expand Down Expand Up @@ -505,7 +505,7 @@ func Test_CreateIssue(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// Setup client with mock
client := github.NewClient(tc.mockedClient)
_, handler := createIssue(client, translations.NullTranslationHelper)
_, handler := CreateIssue(client, translations.NullTranslationHelper)

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -566,7 +566,7 @@ func Test_CreateIssue(t *testing.T) {
func Test_ListIssues(t *testing.T) {
// Verify tool definition
mockClient := github.NewClient(nil)
tool, _ := listIssues(mockClient, translations.NullTranslationHelper)
tool, _ := ListIssues(mockClient, translations.NullTranslationHelper)

assert.Equal(t, "list_issues", tool.Name)
assert.NotEmpty(t, tool.Description)
Expand Down Expand Up @@ -697,7 +697,7 @@ func Test_ListIssues(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// Setup client with mock
client := github.NewClient(tc.mockedClient)
_, handler := listIssues(client, translations.NullTranslationHelper)
_, handler := ListIssues(client, translations.NullTranslationHelper)

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -742,7 +742,7 @@ func Test_ListIssues(t *testing.T) {
func Test_UpdateIssue(t *testing.T) {
// Verify tool definition
mockClient := github.NewClient(nil)
tool, _ := updateIssue(mockClient, translations.NullTranslationHelper)
tool, _ := UpdateIssue(mockClient, translations.NullTranslationHelper)

assert.Equal(t, "update_issue", tool.Name)
assert.NotEmpty(t, tool.Description)
Expand Down Expand Up @@ -881,7 +881,7 @@ func Test_UpdateIssue(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// Setup client with mock
client := github.NewClient(tc.mockedClient)
_, handler := updateIssue(client, translations.NullTranslationHelper)
_, handler := UpdateIssue(client, translations.NullTranslationHelper)

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -999,7 +999,7 @@ func Test_ParseISOTimestamp(t *testing.T) {
func Test_GetIssueComments(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := getIssueComments(mockClient, translations.NullTranslationHelper)
tool, _ := GetIssueComments(mockClient, translations.NullTranslationHelper)

assert.Equal(t, "get_issue_comments", tool.Name)
assert.NotEmpty(t, tool.Description)
Expand Down Expand Up @@ -1099,7 +1099,7 @@ func Test_GetIssueComments(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// Setup client with mock
client := github.NewClient(tc.mockedClient)
_, handler := getIssueComments(client, translations.NullTranslationHelper)
_, handler := GetIssueComments(client, translations.NullTranslationHelper)

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down
14 changes: 7 additions & 7 deletions pkg/github/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func NewServer(client *github.Client, version string, readOnly bool, t translati
s.AddResourceTemplate(getRepositoryResourcePrContent(client, t))

// Add GitHub tools - Issues
s.AddTool(getIssue(client, t))
s.AddTool(searchIssues(client, t))
s.AddTool(listIssues(client, t))
s.AddTool(getIssueComments(client, t))
s.AddTool(GetIssue(client, t))
s.AddTool(SearchIssues(client, t))
s.AddTool(ListIssues(client, t))
s.AddTool(GetIssueComments(client, t))
if !readOnly {
s.AddTool(createIssue(client, t))
s.AddTool(addIssueComment(client, t))
s.AddTool(updateIssue(client, t))
s.AddTool(CreateIssue(client, t))
s.AddTool(AddIssueComment(client, t))
s.AddTool(UpdateIssue(client, t))
}

// Add GitHub tools - Pull Requests
Expand Down