From e10f392c2ac06291e964448b4bc5a594f55d812a Mon Sep 17 00:00:00 2001 From: Sam Morrow Date: Mon, 7 Apr 2025 23:07:56 +0200 Subject: [PATCH 1/2] chore: export code scanning funcs --- pkg/github/code_scanning.go | 4 ++-- pkg/github/code_scanning_test.go | 8 ++++---- pkg/github/server.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/github/code_scanning.go b/pkg/github/code_scanning.go index 81ee2c31..1b9cd876 100644 --- a/pkg/github/code_scanning.go +++ b/pkg/github/code_scanning.go @@ -13,7 +13,7 @@ import ( "github.com/mark3labs/mcp-go/server" ) -func getCodeScanningAlert(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) { +func GetCodeScanningAlert(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) { return mcp.NewTool("get_code_scanning_alert", mcp.WithDescription(t("TOOL_GET_CODE_SCANNING_ALERT_DESCRIPTION", "Get details of a specific code scanning alert in a GitHub repository.")), mcp.WithString("owner", @@ -66,7 +66,7 @@ func getCodeScanningAlert(client *github.Client, t translations.TranslationHelpe } } -func listCodeScanningAlerts(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) { +func ListCodeScanningAlerts(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) { return mcp.NewTool("list_code_scanning_alerts", mcp.WithDescription(t("TOOL_LIST_CODE_SCANNING_ALERTS_DESCRIPTION", "List code scanning alerts in a GitHub repository.")), mcp.WithString("owner", diff --git a/pkg/github/code_scanning_test.go b/pkg/github/code_scanning_test.go index ec4d671e..f1f3a1de 100644 --- a/pkg/github/code_scanning_test.go +++ b/pkg/github/code_scanning_test.go @@ -16,7 +16,7 @@ import ( func Test_GetCodeScanningAlert(t *testing.T) { // Verify tool definition once mockClient := github.NewClient(nil) - tool, _ := getCodeScanningAlert(mockClient, translations.NullTranslationHelper) + tool, _ := GetCodeScanningAlert(mockClient, translations.NullTranslationHelper) assert.Equal(t, "get_code_scanning_alert", tool.Name) assert.NotEmpty(t, tool.Description) @@ -82,7 +82,7 @@ func Test_GetCodeScanningAlert(t *testing.T) { t.Run(tc.name, func(t *testing.T) { // Setup client with mock client := github.NewClient(tc.mockedClient) - _, handler := getCodeScanningAlert(client, translations.NullTranslationHelper) + _, handler := GetCodeScanningAlert(client, translations.NullTranslationHelper) // Create call request request := createMCPRequest(tc.requestArgs) @@ -118,7 +118,7 @@ func Test_GetCodeScanningAlert(t *testing.T) { func Test_ListCodeScanningAlerts(t *testing.T) { // Verify tool definition once mockClient := github.NewClient(nil) - tool, _ := listCodeScanningAlerts(mockClient, translations.NullTranslationHelper) + tool, _ := ListCodeScanningAlerts(mockClient, translations.NullTranslationHelper) assert.Equal(t, "list_code_scanning_alerts", tool.Name) assert.NotEmpty(t, tool.Description) @@ -201,7 +201,7 @@ func Test_ListCodeScanningAlerts(t *testing.T) { t.Run(tc.name, func(t *testing.T) { // Setup client with mock client := github.NewClient(tc.mockedClient) - _, handler := listCodeScanningAlerts(client, translations.NullTranslationHelper) + _, handler := ListCodeScanningAlerts(client, translations.NullTranslationHelper) // Create call request request := createMCPRequest(tc.requestArgs) diff --git a/pkg/github/server.go b/pkg/github/server.go index bf3583b9..ec485a74 100644 --- a/pkg/github/server.go +++ b/pkg/github/server.go @@ -75,8 +75,8 @@ func NewServer(client *github.Client, version string, readOnly bool, t translati s.AddTool(getMe(client, t)) // Add GitHub tools - Code Scanning - s.AddTool(getCodeScanningAlert(client, t)) - s.AddTool(listCodeScanningAlerts(client, t)) + s.AddTool(GetCodeScanningAlert(client, t)) + s.AddTool(ListCodeScanningAlerts(client, t)) return s } From a2208abbca50a36480550a48291a476b3f5c2e57 Mon Sep 17 00:00:00 2001 From: Sam Morrow Date: Mon, 7 Apr 2025 23:22:56 +0200 Subject: [PATCH 2/2] chore: export issues funcs --- pkg/github/issues.go | 28 ++++++++++++++-------------- pkg/github/issues_test.go | 28 ++++++++++++++-------------- pkg/github/server.go | 14 +++++++------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/pkg/github/issues.go b/pkg/github/issues.go index 1632e9e8..8b1039ca 100644 --- a/pkg/github/issues.go +++ b/pkg/github/issues.go @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index 485169fd..04a2ae19 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -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) @@ -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) @@ -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) @@ -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{ @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/pkg/github/server.go b/pkg/github/server.go index ec485a74..7ece3553 100644 --- a/pkg/github/server.go +++ b/pkg/github/server.go @@ -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