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

Function RequiredBigInt

pkg/github/params.go:158–174  ·  view source on GitHub ↗

RequiredBigInt 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. 2. Checks if the parameter is of the expected type (float64 or numeric string). 3. Checks if the parameter is not

(args map[string]any, p string)

Source from the content-addressed store, hash-verified

156// 3. Checks if the parameter is not empty, i.e: non-zero value.
157// 4. Validates that the float64 value can be safely converted to int64 without truncation.
158func RequiredBigInt(args map[string]any, p string) (int64, error) {
159 val, ok := args[p]
160 if !ok {
161 return 0, fmt.Errorf("missing required parameter: %s", p)
162 }
163
164 result, err := toInt64(val)
165 if err != nil {
166 return 0, fmt.Errorf("parameter %s is not a valid number: %w", p, err)
167 }
168
169 if result == 0 {
170 return 0, fmt.Errorf("missing required parameter: %s", p)
171 }
172
173 return result, nil
174}
175
176// OptionalParam is a helper function that can be used to fetch a requested parameter from the request.
177// It does the following checks:

Callers 6

AddIssueCommentFunction · 0.85
ProjectsGetFunction · 0.85
ProjectsWriteFunction · 0.85

Calls 1

toInt64Function · 0.85

Tested by

no test coverage detected