Skip to content

chore: export search funcs #167

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

// searchRepositories creates a tool to search for GitHub repositories.
func searchRepositories(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// SearchRepositories creates a tool to search for GitHub repositories.
func SearchRepositories(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("search_repositories",
mcp.WithDescription(t("TOOL_SEARCH_REPOSITORIES_DESCRIPTION", "Search for GitHub repositories")),
mcp.WithString("query",
Expand Down Expand Up @@ -62,8 +62,8 @@ func searchRepositories(client *github.Client, t translations.TranslationHelperF
}
}

// searchCode creates a tool to search for code across GitHub repositories.
func searchCode(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// SearchCode creates a tool to search for code across GitHub repositories.
func SearchCode(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("search_code",
mcp.WithDescription(t("TOOL_SEARCH_CODE_DESCRIPTION", "Search for code across GitHub repositories")),
mcp.WithString("q",
Expand Down Expand Up @@ -129,8 +129,8 @@ func searchCode(client *github.Client, t translations.TranslationHelperFunc) (to
}
}

// searchUsers creates a tool to search for GitHub users.
func searchUsers(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
// SearchUsers creates a tool to search for GitHub users.
func SearchUsers(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("search_users",
mcp.WithDescription(t("TOOL_SEARCH_USERS_DESCRIPTION", "Search for GitHub users")),
mcp.WithString("q",
Expand Down
12 changes: 6 additions & 6 deletions pkg/github/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func Test_SearchRepositories(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := searchRepositories(mockClient, translations.NullTranslationHelper)
tool, _ := SearchRepositories(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -163,7 +163,7 @@ func Test_SearchRepositories(t *testing.T) {
func Test_SearchCode(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := searchCode(mockClient, translations.NullTranslationHelper)
tool, _ := SearchCode(mockClient, translations.NullTranslationHelper)

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

// Create call request
request := createMCPRequest(tc.requestArgs)
Expand Down Expand Up @@ -314,7 +314,7 @@ func Test_SearchCode(t *testing.T) {
func Test_SearchUsers(t *testing.T) {
// Verify tool definition once
mockClient := github.NewClient(nil)
tool, _ := searchUsers(mockClient, translations.NullTranslationHelper)
tool, _ := SearchUsers(mockClient, translations.NullTranslationHelper)

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

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

// Add GitHub tools - Repositories
s.AddTool(searchRepositories(client, t))
s.AddTool(SearchRepositories(client, t))
s.AddTool(GetFileContents(client, t))
s.AddTool(ListCommits(client, t))
if !readOnly {
Expand All @@ -68,8 +68,8 @@ func NewServer(client *github.Client, version string, readOnly bool, t translati
}

// Add GitHub tools - Search
s.AddTool(searchCode(client, t))
s.AddTool(searchUsers(client, t))
s.AddTool(SearchCode(client, t))
s.AddTool(SearchUsers(client, t))

// Add GitHub tools - Users
s.AddTool(getMe(client, t))
Expand Down
Loading