Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ The following sets of tools are available (all are on by default):
- `order`: Sort order (string, optional)
- `page`: Page number for pagination (min 1) (number, optional)
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
- `q`: Search query using GitHub code search syntax (string, required)
- `query`: Search query using GitHub code search syntax (string, required)
- `sort`: Sort field ('indexed' only) (string, optional)

- **search_repositories** - Search repositories
Expand Down
4 changes: 2 additions & 2 deletions pkg/github/__toolsnaps__/search_code.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"minimum": 1,
"type": "number"
},
"q": {
"query": {
"description": "Search query using GitHub code search syntax",
"type": "string"
},
Expand All @@ -35,7 +35,7 @@
}
},
"required": [
"q"
"query"
],
"type": "object"
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/github/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func SearchCode(getClient GetClientFn, t translations.TranslationHelperFunc) (to
Title: t("TOOL_SEARCH_CODE_USER_TITLE", "Search code"),
ReadOnlyHint: ToBoolPtr(true),
}),
mcp.WithString("q",
mcp.WithString("query",
mcp.Required(),
mcp.Description("Search query using GitHub code search syntax"),
),
Expand All @@ -97,7 +97,7 @@ func SearchCode(getClient GetClientFn, t translations.TranslationHelperFunc) (to
WithPagination(),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
query, err := RequiredParam[string](request, "q")
query, err := RequiredParam[string](request, "query")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/github/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ func Test_SearchCode(t *testing.T) {

assert.Equal(t, "search_code", tool.Name)
assert.NotEmpty(t, tool.Description)
assert.Contains(t, tool.InputSchema.Properties, "q")
assert.Contains(t, tool.InputSchema.Properties, "query")
assert.Contains(t, tool.InputSchema.Properties, "sort")
assert.Contains(t, tool.InputSchema.Properties, "order")
assert.Contains(t, tool.InputSchema.Properties, "perPage")
assert.Contains(t, tool.InputSchema.Properties, "page")
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"q"})
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"query"})

// Setup mock search results
mockSearchResult := &github.CodeSearchResult{
Expand Down Expand Up @@ -227,7 +227,7 @@ func Test_SearchCode(t *testing.T) {
),
),
requestArgs: map[string]interface{}{
"q": "fmt.Println language:go",
"query": "fmt.Println language:go",
"sort": "indexed",
"order": "desc",
"page": float64(1),
Expand All @@ -251,7 +251,7 @@ func Test_SearchCode(t *testing.T) {
),
),
requestArgs: map[string]interface{}{
"q": "fmt.Println language:go",
"query": "fmt.Println language:go",
},
expectError: false,
expectedResult: mockSearchResult,
Expand All @@ -268,7 +268,7 @@ func Test_SearchCode(t *testing.T) {
),
),
requestArgs: map[string]interface{}{
"q": "invalid:query",
"query": "invalid:query",
},
expectError: true,
expectedErrMsg: "failed to search code",
Expand Down
Loading