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

Function RequiredInt

pkg/github/params.go:134–150  ·  view source on GitHub ↗

RequiredInt 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 emp

(args map[string]any, p string)

Source from the content-addressed store, hash-verified

132// 2. Checks if the parameter is of the expected type (float64 or numeric string).
133// 3. Checks if the parameter is not empty, i.e: non-zero value
134func RequiredInt(args map[string]any, p string) (int, error) {
135 v, ok := args[p]
136 if !ok {
137 return 0, fmt.Errorf("missing required parameter: %s", p)
138 }
139
140 result, err := toInt(v)
141 if err != nil {
142 return 0, fmt.Errorf("parameter %s is not a valid number: %w", p, err)
143 }
144
145 if result == 0 {
146 return 0, fmt.Errorf("missing required parameter: %s", p)
147 }
148
149 return result, nil
150}
151
152// RequiredBigInt is a helper function that can be used to fetch a requested parameter from the request.
153// It does the following checks:

Callers 15

GetCodeQualityFindingFunction · 0.85
IssueReadFunction · 0.85
AddIssueCommentFunction · 0.85
SubIssueWriteFunction · 0.85
IssueWriteFunction · 0.85
addDiscussionCommentFunction · 0.85
replyToDiscussionCommentFunction · 0.85
ProjectsListFunction · 0.85
ProjectsGetFunction · 0.85
ProjectsWriteFunction · 0.85
listProjectFieldsFunction · 0.85
listProjectItemsFunction · 0.85

Calls 1

toIntFunction · 0.85

Tested by 1

Test_RequiredIntFunction · 0.68