MCPcopy
hub / github.com/github/github-mcp-server / OptionalIntParam

Function OptionalIntParam

pkg/github/params.go:200–212  ·  view source on GitHub ↗

OptionalIntParam 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 2. If it is present, it checks if the parameter is of the expected type (float

(args map[string]any, p string)

Source from the content-addressed store, hash-verified

198// 1. Checks if the parameter is present in the request, if not, it returns its zero-value
199// 2. If it is present, it checks if the parameter is of the expected type (float64 or numeric string) and returns it
200func OptionalIntParam(args map[string]any, p string) (int, error) {
201 val, ok := args[p]
202 if !ok {
203 return 0, nil
204 }
205
206 result, err := toInt(val)
207 if err != nil {
208 return 0, fmt.Errorf("parameter %s is not a valid number: %w", p, err)
209 }
210
211 return result, nil
212}
213
214// OptionalIntParamWithDefault is a helper function that can be used to fetch a requested parameter from the request
215// similar to optionalIntParam, but it also takes a default value.

Callers 10

GetFileBlameFunction · 0.85
SubIssueWriteFunction · 0.85
IssueWriteFunction · 0.85
ActionsRunTriggerFunction · 0.85
ActionsGetJobLogsFunction · 0.85
Test_OptionalIntParamFunction · 0.85

Calls 1

toIntFunction · 0.85

Tested by 1

Test_OptionalIntParamFunction · 0.68