Skip to content

Commit 9ea0ac9

Browse files
committed
change minimal_output to use new OptionalBoolParamWithDefault
1 parent ca91a80 commit 9ea0ac9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

pkg/github/search.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,10 @@ func SearchRepositories(getClient GetClientFn, t translations.TranslationHelperF
4141
if err != nil {
4242
return mcp.NewToolResultError(err.Error()), nil
4343
}
44-
minimalOutput, err := OptionalParam[bool](request, "minimal_output")
44+
minimalOutput, err := OptionalBoolParamWithDefault(request, "minimal_output", true)
4545
if err != nil {
4646
return mcp.NewToolResultError(err.Error()), nil
4747
}
48-
if _, ok := request.GetArguments()["minimal_output"]; !ok {
49-
minimalOutput = true
50-
}
5148
opts := &github.SearchOptions{
5249
ListOptions: github.ListOptions{
5350
Page: pagination.Page,

pkg/github/server.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ func OptionalIntParamWithDefault(r mcp.CallToolRequest, p string, d int) (int, e
144144
return v, nil
145145
}
146146

147+
// OptionalBoolParamWithDefault is a helper function that can be used to fetch a requested parameter from the request
148+
// similar to optionalBoolParam, but it also takes a default value.
149+
func OptionalBoolParamWithDefault(r mcp.CallToolRequest, p string, d bool) (bool, error) {
150+
v, err := OptionalParam[bool](r, p)
151+
if err != nil {
152+
return false, err
153+
}
154+
if !v {
155+
return d, nil
156+
}
157+
return v, nil
158+
}
159+
147160
// OptionalStringArrayParam is a helper function that can be used to fetch a requested parameter from the request.
148161
// It does the following checks:
149162
// 1. Checks if the parameter is present in the request, if not, it returns its zero-value

0 commit comments

Comments
 (0)