Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81f093e

Browse files
committed
Inline optional bool function for all notifications
1 parent 9424fbd commit 81f093e

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

pkg/github/notifications.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ func ListNotifications(getClient GetClientFn, t translations.TranslationHelperFu
3636
if err != nil {
3737
return mcp.NewToolResultError(err.Error()), nil
3838
}
39-
all, err := OptionalBoolParamWithDefault(request, "all", false) // Default to false unless specified
40-
if err != nil {
41-
return mcp.NewToolResultError(err.Error()), nil
39+
all := false
40+
if val, err := OptionalParam[bool](request, "all"); err == nil {
41+
all = val
4242
}
4343

4444
opts := &github.NotificationListOptions{

pkg/github/server.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,6 @@ func OptionalIntParam(r mcp.CallToolRequest, p string) (int, error) {
130130
return int(v), nil
131131
}
132132

133-
// OptionalBoolParamWithDefault is a helper function that retrieves a boolean parameter from the request.
134-
// If the parameter is not present, it returns the provided default value. If the parameter is present,
135-
// it validates its type and returns the value.
136-
func OptionalBoolParamWithDefault(request mcp.CallToolRequest, s string, b bool) (bool, error) {
137-
v, err := OptionalParam[bool](request, s)
138-
if err != nil {
139-
return false, err
140-
}
141-
if !b {
142-
return b, nil
143-
}
144-
return v, nil
145-
}
146-
147133
// OptionalIntParamWithDefault is a helper function that can be used to fetch a requested parameter from the request
148134
// similar to optionalIntParam, but it also takes a default value.
149135
func OptionalIntParamWithDefault(r mcp.CallToolRequest, p string, d int) (int, error) {

0 commit comments

Comments
 (0)