Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
change minimal_output to use new OptionalBoolParamWithDefault
  • Loading branch information
mattdholloway committed Aug 28, 2025
commit 9ea0ac92536b4135f5b869ad4b05b93572e8750c
5 changes: 1 addition & 4 deletions pkg/github/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ func SearchRepositories(getClient GetClientFn, t translations.TranslationHelperF
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
minimalOutput, err := OptionalParam[bool](request, "minimal_output")
minimalOutput, err := OptionalBoolParamWithDefault(request, "minimal_output", true)
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
if _, ok := request.GetArguments()["minimal_output"]; !ok {
minimalOutput = true
}
opts := &github.SearchOptions{
ListOptions: github.ListOptions{
Page: pagination.Page,
Expand Down
13 changes: 13 additions & 0 deletions pkg/github/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,19 @@ func OptionalIntParamWithDefault(r mcp.CallToolRequest, p string, d int) (int, e
return v, nil
}

// OptionalBoolParamWithDefault is a helper function that can be used to fetch a requested parameter from the request
// similar to optionalBoolParam, but it also takes a default value.
func OptionalBoolParamWithDefault(r mcp.CallToolRequest, p string, d bool) (bool, error) {
v, err := OptionalParam[bool](r, p)
if err != nil {
return false, err
}
if !v {
Comment thread
mattdholloway marked this conversation as resolved.
Resolved
return d, nil
}
return v, nil
}

// OptionalStringArrayParam is a helper function that can be used to fetch a requested parameter from the request.
// It does the following checks:
// 1. Checks if the parameter is present in the request, if not, it returns its zero-value
Expand Down