Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add sort and order parameters to search_repositories tool#1191

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kerobbi merged 7 commits intomainfromimprove-search-repositories-tool
Oct 9, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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: 2 additions & 0 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -993,9 +993,11 @@ Possible options:

- **search_repositories** - Search repositories
- `minimal_output`: Return minimal repository information (default: true). When false, returns full GitHub API repository objects. (boolean, optional)
- `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)
- `query`: Repository search query. Examples: 'machine learning in:name stars:>1000 language:python', 'topic:react', 'user:facebook'. Supports advanced search syntax for precise filtering. (string, required)
- `sort`: Sort repositories by field, defaults to best match (string, optional)

</details>

Expand Down
18 changes: 18 additions & 0 deletionspkg/github/__toolsnaps__/search_repositories.snap
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,14 @@
"description": "Return minimal repository information (default: true). When false, returns full GitHub API repository objects.",
"type": "boolean"
},
"order": {
"description": "Sort order",
"enum": [
"asc",
"desc"
],
"type": "string"
},
"page": {
"description": "Page number for pagination (min 1)",
"minimum": 1,
Expand All@@ -25,6 +33,16 @@
"query": {
"description": "Repository search query. Examples: 'machine learning in:name stars:\u003e1000 language:python', 'topic:react', 'user:facebook'. Supports advanced search syntax for precise filtering.",
"type": "string"
},
"sort": {
"description": "Sort repositories by field, defaults to best match",
"enum": [
"stars",
"forks",
"help-wanted-issues",
"updated"
],
"type": "string"
}
},
"required": [
Expand Down
5 changes: 4 additions & 1 deletionpkg/github/instructions.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,10 @@ Tool selection guidance:

Context management:
1. Use pagination whenever possible with batches of 5-10 items.
2. Use minimal_output parameter set to true if the full information is not needed to accomplish a task.`
2. Use minimal_output parameter set to true if the full information is not needed to accomplish a task.

Tool usage guidance:
1. For 'search_*' tools: Use separate 'sort' and 'order' parameters if available for sorting results - do not include 'sort:' syntax in query strings. Query strings should contain only search criteria (e.g., 'org:google language:python'), not sorting instructions.`

allInstructions := []string{baseInstruction}
allInstructions = append(allInstructions, instructions...)
Expand Down
18 changes: 18 additions & 0 deletionspkg/github/search.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,14 @@ func SearchRepositories(getClient GetClientFn, t translations.TranslationHelperF
mcp.Required(),
mcp.Description("Repository search query. Examples: 'machine learning in:name stars:>1000 language:python', 'topic:react', 'user:facebook'. Supports advanced search syntax for precise filtering."),
),
mcp.WithString("sort",
mcp.Description("Sort repositories by field, defaults to best match"),
mcp.Enum("stars", "forks", "help-wanted-issues", "updated"),
),
mcp.WithString("order",
mcp.Description("Sort order"),
mcp.Enum("asc", "desc"),
),
mcp.WithBoolean("minimal_output",
mcp.Description("Return minimal repository information (default: true). When false, returns full GitHub API repository objects."),
mcp.DefaultBool(true),
Expand All@@ -37,6 +45,14 @@ func SearchRepositories(getClient GetClientFn, t translations.TranslationHelperF
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
sort, err := OptionalParam[string](request, "sort")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
order, err := OptionalParam[string](request, "order")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
pagination, err := OptionalPaginationParams(request)
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
Expand All@@ -46,6 +62,8 @@ func SearchRepositories(getClient GetClientFn, t translations.TranslationHelperF
return mcp.NewToolResultError(err.Error()), nil
}
opts := &github.SearchOptions{
Sort: sort,
Order: order,
ListOptions: github.ListOptions{
Page: pagination.Page,
PerPage: pagination.PerPage,
Expand Down
6 changes: 6 additions & 0 deletionspkg/github/search_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,8 @@ func Test_SearchRepositories(t *testing.T) {
assert.Equal(t, "search_repositories", tool.Name)
assert.NotEmpty(t, tool.Description)
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, "page")
assert.Contains(t, tool.InputSchema.Properties, "perPage")
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"query"})
Expand DownExpand Up@@ -66,6 +68,8 @@ func Test_SearchRepositories(t *testing.T) {
mock.GetSearchRepositories,
expectQueryParams(t, map[string]string{
"q": "golang test",
"sort": "stars",
"order": "desc",
"page": "2",
"per_page": "10",
}).andThen(
Expand All@@ -75,6 +79,8 @@ func Test_SearchRepositories(t *testing.T) {
),
requestArgs: map[string]interface{}{
"query": "golang test",
"sort": "stars",
"order": "desc",
"page": float64(2),
"perPage": float64(10),
},
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp