Skip to content

chore: export pr funcs #164

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 1 commit 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
40 changes: 20 additions & 20 deletions pkg/github/pullrequests.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/mark3labs/mcp-go/server"
)

// getPullRequest creates a tool to get details of a specific pull request.
func getPullRequest(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// GetPullRequest creates a tool to get details of a specific pull request.
func GetPullRequest(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("get_pull_request",
mcp.WithDescription(t("TOOL_GET_PULL_REQUEST_DESCRIPTION", "Get details of a specific pull request")),
mcp.WithString("owner",
Expand Down Expand Up @@ -67,8 +67,8 @@ func getPullRequest(client *github.Client, t translations.TranslationHelperFunc)
}
}

// listPullRequests creates a tool to list and filter repository pull requests.
func listPullRequests(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// ListPullRequests creates a tool to list and filter repository pull requests.
func ListPullRequests(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("list_pull_requests",
mcp.WithDescription(t("TOOL_LIST_PULL_REQUESTS_DESCRIPTION", "List and filter repository pull requests")),
mcp.WithString("owner",
Expand Down Expand Up @@ -165,8 +165,8 @@ func listPullRequests(client *github.Client, t translations.TranslationHelperFun
}
}

// mergePullRequest creates a tool to merge a pull request.
func mergePullRequest(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// MergePullRequest creates a tool to merge a pull request.
func MergePullRequest(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("merge_pull_request",
mcp.WithDescription(t("TOOL_MERGE_PULL_REQUEST_DESCRIPTION", "Merge a pull request")),
mcp.WithString("owner",
Expand Down Expand Up @@ -245,8 +245,8 @@ func mergePullRequest(client *github.Client, t translations.TranslationHelperFun
}
}

// getPullRequestFiles creates a tool to get the list of files changed in a pull request.
func getPullRequestFiles(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// GetPullRequestFiles creates a tool to get the list of files changed in a pull request.
func GetPullRequestFiles(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("get_pull_request_files",
mcp.WithDescription(t("TOOL_GET_PULL_REQUEST_FILES_DESCRIPTION", "Get the list of files changed in a pull request")),
mcp.WithString("owner",
Expand Down Expand Up @@ -300,8 +300,8 @@ func getPullRequestFiles(client *github.Client, t translations.TranslationHelper
}
}

// getPullRequestStatus creates a tool to get the combined status of all status checks for a pull request.
func getPullRequestStatus(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// GetPullRequestStatus creates a tool to get the combined status of all status checks for a pull request.
func GetPullRequestStatus(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("get_pull_request_status",
mcp.WithDescription(t("TOOL_GET_PULL_REQUEST_STATUS_DESCRIPTION", "Get the combined status of all status checks for a pull request")),
mcp.WithString("owner",
Expand Down Expand Up @@ -369,8 +369,8 @@ func getPullRequestStatus(client *github.Client, t translations.TranslationHelpe
}
}

// updatePullRequestBranch creates a tool to update a pull request branch with the latest changes from the base branch.
func updatePullRequestBranch(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// UpdatePullRequestBranch creates a tool to update a pull request branch with the latest changes from the base branch.
func UpdatePullRequestBranch(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("update_pull_request_branch",
mcp.WithDescription(t("TOOL_UPDATE_PULL_REQUEST_BRANCH_DESCRIPTION", "Update a pull request branch with the latest changes from the base branch")),
mcp.WithString("owner",
Expand Down Expand Up @@ -439,8 +439,8 @@ func updatePullRequestBranch(client *github.Client, t translations.TranslationHe
}
}

// getPullRequestComments creates a tool to get the review comments on a pull request.
func getPullRequestComments(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// GetPullRequestComments creates a tool to get the review comments on a pull request.
func GetPullRequestComments(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("get_pull_request_comments",
mcp.WithDescription(t("TOOL_GET_PULL_REQUEST_COMMENTS_DESCRIPTION", "Get the review comments on a pull request")),
mcp.WithString("owner",
Expand Down Expand Up @@ -499,8 +499,8 @@ func getPullRequestComments(client *github.Client, t translations.TranslationHel
}
}

// getPullRequestReviews creates a tool to get the reviews on a pull request.
func getPullRequestReviews(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// GetPullRequestReviews creates a tool to get the reviews on a pull request.
func GetPullRequestReviews(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("get_pull_request_reviews",
mcp.WithDescription(t("TOOL_GET_PULL_REQUEST_REVIEWS_DESCRIPTION", "Get the reviews on a pull request")),
mcp.WithString("owner",
Expand Down Expand Up @@ -553,8 +553,8 @@ func getPullRequestReviews(client *github.Client, t translations.TranslationHelp
}
}

// createPullRequestReview creates a tool to submit a review on a pull request.
func createPullRequestReview(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// CreatePullRequestReview creates a tool to submit a review on a pull request.
func CreatePullRequestReview(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("create_pull_request_review",
mcp.WithDescription(t("TOOL_CREATE_PULL_REQUEST_REVIEW_DESCRIPTION", "Create a review on a pull request")),
mcp.WithString("owner",
Expand Down Expand Up @@ -745,8 +745,8 @@ func createPullRequestReview(client *github.Client, t translations.TranslationHe
}
}

// createPullRequest creates a tool to create a new pull request.
func createPullRequest(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// CreatePullRequest creates a tool to create a new pull request.
func CreatePullRequest(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("create_pull_request",
mcp.WithDescription(t("TOOL_CREATE_PULL_REQUEST_DESCRIPTION", "Create a new pull request in a GitHub repository")),
mcp.WithString("owner",
Expand Down
40 changes: 20 additions & 20 deletions pkg/github/pullrequests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
func Test_GetPullRequest(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := getPullRequest(mockClient, translations.NullTranslationHelper)
tool, _ := GetPullRequest(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -129,7 +129,7 @@ func Test_GetPullRequest(t *testing.T) {
func Test_ListPullRequests(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := listPullRequests(mockClient, translations.NullTranslationHelper)
tool, _ := ListPullRequests(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -259,7 +259,7 @@ func Test_ListPullRequests(t *testing.T) {
func Test_MergePullRequest(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := mergePullRequest(mockClient, translations.NullTranslationHelper)
tool, _ := MergePullRequest(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -370,7 +370,7 @@ func Test_MergePullRequest(t *testing.T) {
func Test_GetPullRequestFiles(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := getPullRequestFiles(mockClient, translations.NullTranslationHelper)
tool, _ := GetPullRequestFiles(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -486,7 +486,7 @@ func Test_GetPullRequestFiles(t *testing.T) {
func Test_GetPullRequestStatus(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := getPullRequestStatus(mockClient, translations.NullTranslationHelper)
tool, _ := GetPullRequestStatus(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -647,7 +647,7 @@ func Test_GetPullRequestStatus(t *testing.T) {
func Test_UpdatePullRequestBranch(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := updatePullRequestBranch(mockClient, translations.NullTranslationHelper)
tool, _ := UpdatePullRequestBranch(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -763,7 +763,7 @@ func Test_UpdatePullRequestBranch(t *testing.T) {
func Test_GetPullRequestComments(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := getPullRequestComments(mockClient, translations.NullTranslationHelper)
tool, _ := GetPullRequestComments(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -890,7 +890,7 @@ func Test_GetPullRequestComments(t *testing.T) {
func Test_GetPullRequestReviews(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := getPullRequestReviews(mockClient, translations.NullTranslationHelper)
tool, _ := GetPullRequestReviews(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -1013,7 +1013,7 @@ func Test_GetPullRequestReviews(t *testing.T) {
func Test_CreatePullRequestReview(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := createPullRequestReview(mockClient, translations.NullTranslationHelper)
tool, _ := CreatePullRequestReview(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -1384,7 +1384,7 @@ func Test_CreatePullRequestReview(t *testing.T) {
func Test_CreatePullRequest(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := createPullRequest(mockClient, translations.NullTranslationHelper)
tool, _ := CreatePullRequest(mockClient, translations.NullTranslationHelper)

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

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

// Add GitHub tools - Pull Requests
s.AddTool(getPullRequest(client, t))
s.AddTool(listPullRequests(client, t))
s.AddTool(getPullRequestFiles(client, t))
s.AddTool(getPullRequestStatus(client, t))
s.AddTool(getPullRequestComments(client, t))
s.AddTool(getPullRequestReviews(client, t))
s.AddTool(GetPullRequest(client, t))
s.AddTool(ListPullRequests(client, t))
s.AddTool(GetPullRequestFiles(client, t))
s.AddTool(GetPullRequestStatus(client, t))
s.AddTool(GetPullRequestComments(client, t))
s.AddTool(GetPullRequestReviews(client, t))
if !readOnly {
s.AddTool(mergePullRequest(client, t))
s.AddTool(updatePullRequestBranch(client, t))
s.AddTool(createPullRequestReview(client, t))
s.AddTool(createPullRequest(client, t))
s.AddTool(MergePullRequest(client, t))
s.AddTool(UpdatePullRequestBranch(client, t))
s.AddTool(CreatePullRequestReview(client, t))
s.AddTool(CreatePullRequest(client, t))
}

// Add GitHub tools - Repositories
Expand Down
Loading