github/github-mcp-server · error

parameter %s is not a valid number: %w

Error message

parameter %s is not a valid number: %w

What it means

Thrown by RequiredInt in pkg/github/params.go when an int-typed required argument is present but toInt cannot coerce it: unparseable numeric strings ("abc"), non-numeric JSON types (bool/array/object), NaN/Inf strings, fractional values (1.5), or out-of-int-range magnitudes. The error wraps the underlying cause with %w, so the nested message tells you exactly which sub-case fired.

Source

Thrown at pkg/github/params.go:162

	}

	return val, nil
}

// 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 empty, i.e: non-zero value
func RequiredInt(args map[string]any, p string) (int, error) {
	v, ok := args[p]
	if !ok {
		return 0, fmt.Errorf("missing required parameter: %s", p)
	}

	result, err := toInt(v)
	if err != nil {
		return 0, fmt.Errorf("parameter %s is not a valid number: %w", p, err)
	}

	if result == 0 {
		return 0, fmt.Errorf("missing required parameter: %s", p)
	}

	return result, nil
}

// 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 empty, i.e: non-zero value.
// 4. Validates that the float64 value can be safely converted to int64 without truncation.
func RequiredBigInt(args map[string]any, p string) (int64, error) {
	val, ok := args[p]
	if !ok {

View on GitHub (pinned to 0ea1f775a7)

Solutions

  1. Read the wrapped cause after the colon — 'invalid numeric value', 'expected number, got bool', 'non-integer numeric value', etc. each has its own fix.
  2. Send a plain JSON integer for the parameter.
  3. If the value comes from user/LLM text, sanitize to /^-?\d+$/ before sending.
  4. Round computed values and confirm they are finite before the call.

Example fix

// before
arguments = { owner, repo, issue_number: "#42" };
// after
arguments = { owner, repo, issue_number: 42 };
Defensive patterns

Strategy: try-catch

Validate before calling

function intParam(args, name) {
  const v = args[name];
  if (v === undefined) throw new Error(`missing required parameter: ${name}`);
  const n = typeof v === "string" ? Number(v.trim()) : v;
  if (typeof n !== "number" || !Number.isInteger(n) || !Number.isFinite(n)) {
    throw new Error(`parameter ${name} is not a valid number: ${JSON.stringify(v)}`);
  }
  if (n === 0) throw new Error(`missing required parameter: ${name} (zero)`);
  return n;
}

Type guard

function isValidRequiredInt(v: unknown): v is number {
  const n = typeof v === "string" ? Number(v) : v;
  return typeof n === "number" && Number.isFinite(n) && Number.isInteger(n) && n !== 0;
}

Try / catch

The error chains the cause with %w — match /parameter (\w+) is not a valid number: (.+)/ and branch on the suffix: 'invalid numeric value' → sanitize the string; 'expected number, got T' → fix the JSON type; 'non-integer' → round; 'non-finite' → fix computation; 'out of int range' → clamp. Retry once after the targeted fix.

Prevention

When it happens

Trigger: issue_number: "#42"; per_page: "thirty"; pull_number: 1.5 or true; page: "NaN"; any of the toInt failure modes reached through a required int parameter.

Common situations: IDs copied from UI text with decorations; quoted numbers from LLMs; fractional computed values; boolean sent where count expected.

Related errors


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