You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pkg/github/search.go
+11-30Lines changed: 11 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,6 @@ package github
2
2
3
3
import (
4
4
"context"
5
-
"encoding/json"
6
5
"fmt"
7
6
"io"
8
7
@@ -14,7 +13,7 @@ import (
14
13
)
15
14
16
15
// SearchRepositories creates a tool to search for GitHub repositories.
17
-
funcSearchRepositories(getClientGetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
16
+
funcSearchRepositories(getClientGetClientFn, t translations.TranslationHelperFunc, flagsFeatureFlags) (tool mcp.Tool, handler server.ToolHandlerFunc) {
18
17
returnmcp.NewTool("search_repositories",
19
18
mcp.WithDescription(t("TOOL_SEARCH_REPOSITORIES_DESCRIPTION", "Find GitHub repositories by name, description, readme, topics, or other metadata. Perfect for discovering projects, finding examples, or locating specific repositories across GitHub.")),
20
19
@@ -93,7 +92,6 @@ func SearchRepositories(getClient GetClientFn, t translations.TranslationHelperF
93
92
}
94
93
95
94
// Return either minimal or full response based on parameter
@@ -132,23 +130,15 @@ func SearchRepositories(getClient GetClientFn, t translations.TranslationHelperF
132
130
Items: minimalRepos,
133
131
}
134
132
135
-
r, err=json.Marshal(minimalResult)
136
-
iferr!=nil {
137
-
returnnil, fmt.Errorf("failed to marshal minimal response: %w", err)
138
-
}
139
-
} else {
140
-
r, err=json.Marshal(result)
141
-
iferr!=nil {
142
-
returnnil, fmt.Errorf("failed to marshal full response: %w", err)
143
-
}
133
+
returnFormatResponse(minimalResult, flags)
144
134
}
145
135
146
-
returnmcp.NewToolResultText(string(r)), nil
136
+
returnFormatResponse(result, flags)
147
137
}
148
138
}
149
139
150
140
// SearchCode creates a tool to search for code across GitHub repositories.
151
-
funcSearchCode(getClientGetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
141
+
funcSearchCode(getClientGetClientFn, t translations.TranslationHelperFunc, flagsFeatureFlags) (tool mcp.Tool, handler server.ToolHandlerFunc) {
152
142
returnmcp.NewTool("search_code",
153
143
mcp.WithDescription(t("TOOL_SEARCH_CODE_DESCRIPTION", "Fast and precise code search across ALL GitHub repositories using GitHub's native search engine. Best for finding exact symbols, functions, classes, or specific code patterns.")),
154
144
mcp.WithToolAnnotation(mcp.ToolAnnotation{
@@ -218,16 +208,11 @@ func SearchCode(getClient GetClientFn, t translations.TranslationHelperFunc) (to
218
208
returnmcp.NewToolResultError(fmt.Sprintf("failed to search code: %s", string(body))), nil
219
209
}
220
210
221
-
r, err:=json.Marshal(result)
222
-
iferr!=nil {
223
-
returnnil, fmt.Errorf("failed to marshal response: %w", err)
returnnil, fmt.Errorf("failed to marshal response: %w", err)
313
-
}
314
-
returnmcp.NewToolResultText(string(r)), nil
295
+
returnFormatResponse(minimalResp, flags)
315
296
}
316
297
}
317
298
318
299
// SearchUsers creates a tool to search for GitHub users.
319
-
funcSearchUsers(getClientGetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
300
+
funcSearchUsers(getClientGetClientFn, t translations.TranslationHelperFunc, flagsFeatureFlags) (tool mcp.Tool, handler server.ToolHandlerFunc) {
320
301
returnmcp.NewTool("search_users",
321
302
mcp.WithDescription(t("TOOL_SEARCH_USERS_DESCRIPTION", "Find GitHub users by username, real name, or other profile information. Useful for locating developers, contributors, or team members.")),
322
303
mcp.WithToolAnnotation(mcp.ToolAnnotation{
@@ -336,11 +317,11 @@ func SearchUsers(getClient GetClientFn, t translations.TranslationHelperFunc) (t
336
317
mcp.Enum("asc", "desc"),
337
318
),
338
319
WithPagination(),
339
-
), userOrOrgHandler("user", getClient)
320
+
), userOrOrgHandler("user", getClient, flags)
340
321
}
341
322
342
323
// SearchOrgs creates a tool to search for GitHub organizations.
343
-
funcSearchOrgs(getClientGetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
324
+
funcSearchOrgs(getClientGetClientFn, t translations.TranslationHelperFunc, flagsFeatureFlags) (tool mcp.Tool, handler server.ToolHandlerFunc) {
344
325
returnmcp.NewTool("search_orgs",
345
326
mcp.WithDescription(t("TOOL_SEARCH_ORGS_DESCRIPTION", "Find GitHub organizations by name, location, or other organization metadata. Ideal for discovering companies, open source foundations, or teams.")),
346
327
@@ -361,5 +342,5 @@ func SearchOrgs(getClient GetClientFn, t translations.TranslationHelperFunc) (to
0 commit comments