github/github-mcp-server · error

invalid numeric value: %s

Error message

invalid numeric value: %s

What it means

Thrown by toInt in pkg/github/params.go when a numeric argument is sent as a string but strconv.ParseFloat cannot parse it. toInt is the coercion layer for RequiredInt/optional int params: it accepts float64 (JSON numbers) and numeric strings ("30", "1e3"), and any string ParseFloat rejects produces this error.

Source

Thrown at pkg/github/params.go:75

// isAcceptedError checks if the error is an accepted error.
func isAcceptedError(err error) bool {
	var acceptedError *github.AcceptedError
	return errors.As(err, &acceptedError)
}

// toInt converts a value to int, handling both float64 and string representations.
// Some MCP clients send numeric values as strings. It rejects NaN, ±Inf,
// fractional values, and values outside the int range.
func toInt(val any) (int, error) {
	var f float64
	switch v := val.(type) {
	case float64:
		f = v
	case string:
		var err error
		f, err = strconv.ParseFloat(v, 64)
		if err != nil {
			return 0, fmt.Errorf("invalid numeric value: %s", v)
		}
	default:
		return 0, fmt.Errorf("expected number, got %T", val)
	}
	if math.IsNaN(f) || math.IsInf(f, 0) {
		return 0, fmt.Errorf("non-finite numeric value")
	}
	if f != math.Trunc(f) {
		return 0, fmt.Errorf("non-integer numeric value: %v", f)
	}
	if f > math.MaxInt || f < math.MinInt {
		return 0, fmt.Errorf("numeric value out of int range: %v", f)
	}
	return int(f), nil
}

// toInt64 converts a value to int64, handling both float64 and string representations.
// Some MCP clients send numeric values as strings. It rejects NaN, ±Inf,

View on GitHub (pinned to 0ea1f775a7)

Solutions

  1. Send the value as a real JSON number instead of a string.
  2. If it must be a string, make it a clean decimal literal parseable by Go's ParseFloat ("30", "-5", "1e3").
  3. Strip units, separators, and whitespace on the client before sending.
  4. Note the error is wrapped by RequiredInt as "parameter %s is not a valid number" — read the nested cause for the offending string.

Example fix

// before
arguments: { owner, repo, page: "1,000" }
// after
arguments: { owner, repo, page: 1000 }
Defensive patterns

Strategy: validation

Validate before calling

function toIntArg(v) {
  if (typeof v === "number") return v;
  if (typeof v === "string" && /^[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?$/.test(v.trim())) {
    return Number(v);
  }
  throw new Error(`not a parseable number: ${JSON.stringify(v)}`);
}

Type guard

function isNumericString(v: unknown): v is string {
  return typeof v === "string" && v.trim() !== "" && !isNaN(Number(v));
}

Try / catch

Catch the wrapped 'not a valid number: ... invalid numeric value: <s>' text, sanitize or replace the offending string, retry once; surface the bad value to the user if it came from input.

Prevention

When it happens

Trigger: per_page: "abc", page: "1-5", per_page: "30px", or a string with whitespace/commas like "1,000" passed to a tool using int parameters.

Common situations: LLM-generated numeric strings with units or punctuation; form input forwarded verbatim; locale-formatted numbers ("1.000,00"); truncated or corrupted string payloads.

Related errors


AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15). Data as JSON: /api/errors/c18bb6a6ca5c47b5. Report an issue: GitHub.