github/github-mcp-server · error
parameter %s is not of type %T, is %T
Error message
parameter %s is not of type %T, is %T
What it means
Thrown by OptionalParamOK in pkg/github/params.go when an optional argument IS present in the tool request but its JSON type does not match the Go type the handler expects (e.g. a string is sent where a float64/int is expected, or a number where a string is expected). It is a strict type assertion: unlike toInt/toInt64 it does not coerce numeric strings to numbers.
Source
Thrown at pkg/github/params.go:27
"github.com/google/go-github/v89/github"
"github.com/google/jsonschema-go/jsonschema"
)
// OptionalParamOK is a helper function that can be used to fetch a requested parameter from the request.
// It returns the value, a boolean indicating if the parameter was present, and an error if the type is wrong.
func OptionalParamOK[T any, A map[string]any](args A, p string) (value T, ok bool, err error) {
// Check if the parameter is present in the request
val, exists := args[p]
if !exists {
// Not present, return zero value, false, no error
return
}
// Check if the parameter is of the expected type
value, ok = val.(T)
if !ok {
// Present but wrong type
err = fmt.Errorf("parameter %s is not of type %T, is %T", p, value, val)
ok = true // Set ok to true because the parameter *was* present, even if wrong type
return
}
// Present and correct type
ok = true
return
}
// OptionalNullableStringParam preserves omitted, null, and non-empty string values.
func OptionalNullableStringParam(args map[string]any, p string) (*string, bool, error) {
value, ok := args[p]
if !ok {
return nil, false, nil
}
if value == nil {
return nil, true, nil
}View on GitHub (pinned to 0ea1f775a7)
Solutions
- Send the argument with the exact JSON type shown in the tool's inputSchema: strings unquoted-as-numbers for numeric fields, plain strings for text fields.
- Remove the argument if you don't need it — optional parameters that are absent never trigger this error.
- For numeric fields you must send as strings, check whether the tool uses RequiredInt/OptionalInt-style helpers (which accept numeric strings) instead of the generic path.
- Inspect the full error text: it names the parameter and both the expected and actual types.
Example fix
// before
arguments: { owner, repo, per_page: "30" }
// after
arguments: { owner, repo, per_page: 30 } Defensive patterns
Strategy: type-guard
Validate before calling
function checkOptional(args, name, kind) {
const v = args[name];
if (v === undefined) return; // absent is fine
const ok = kind === "number" ? typeof v === "number" : typeof v === kind;
if (!ok) throw new Error(`${name} must be a JSON ${kind}, got ${typeof v}`);
} Type guard
function isJSONNumber(v: unknown): v is number {
return typeof v === "number" && Number.isFinite(v);
}
function isJSONString(v: unknown): v is string {
return typeof v === "string";
} Try / catch
Check the tool result's error text: parse 'parameter X is not of type A, is B' to learn both expected and actual types, then coerce or drop the parameter and retry once.
Prevention
- Never stringify numbers when building MCP tool arguments.
- Validate argument objects against the tool schema with a JSON-schema validator before dispatch.
- Keep a typed mapping of tool name to arguments interface in client code.
When it happens
Trigger: Passing per_page: "30" (string) to a tool whose handler extracts it via OptionalParamOK[float64]; passing owner: 42 (number) where string is expected; passing a JSON array or object where a scalar was expected.
Common situations: MCP clients or LLMs that serialize all arguments as strings; hand-built JSON requests where numbers are quoted; schema drift after upgrading the server so a parameter changed type; proxies that mangle JSON types.
Related errors
- parameter %s is not of type string or null, is %T
- expected number, got %T
- parameter %s is not of type %T
- invalid detail %q: must be one of "none", "stats", "full_pat
- parameter %s must not be empty
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/54904419ca16295c.
Report an issue: GitHub.