{"record":{"id":"8e6f6db4dad30743","repo":"github/github-mcp-server","slug":"parameter-s-is-not-of-type-t","errorCode":null,"errorMessage":"parameter %s is not of type %T","messagePattern":"parameter (.+?) is not of type %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/params.go","lineNumber":139,"sourceCode":"}\n\n// RequiredParam is a helper function that can be used to fetch a requested parameter from the request.\n// It does the following checks:\n// 1. Checks if the parameter is present in the request.\n// 2. Checks if the parameter is of the expected type.\n// 3. Checks if the parameter is not empty, i.e: non-zero value\nfunc RequiredParam[T comparable](args map[string]any, p string) (T, error) {\n\tvar zero T\n\n\t// Check if the parameter is present in the request\n\tif _, ok := args[p]; !ok {\n\t\treturn zero, fmt.Errorf(\"missing required parameter: %s\", p)\n\t}\n\n\t// Check if the parameter is of the expected type\n\tval, ok := args[p].(T)\n\tif !ok {\n\t\treturn zero, fmt.Errorf(\"parameter %s is not of type %T\", p, zero)\n\t}\n\n\tif val == zero {\n\t\treturn zero, fmt.Errorf(\"missing required parameter: %s\", p)\n\t}\n\n\treturn val, nil\n}\n\n// RequiredInt is a helper function that can be used to fetch a requested parameter from the request.\n// It does the following checks:\n// 1. Checks if the parameter is present in the request.\n// 2. Checks if the parameter is of the expected type (float64 or numeric string).\n// 3. Checks if the parameter is not empty, i.e: non-zero value\nfunc RequiredInt(args map[string]any, p string) (int, error) {\n\tv, ok := args[p]\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"missing required parameter: %s\", p)","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/params.go#L121-L157","documentation":"Thrown by RequiredParam in pkg/github/params.go when a required argument is present but its type does not match the expected Go type T. It is the second check of the generic extractor: the key exists, but args[p].(T) fails, e.g. a number where a string is required.","triggerScenarios":"owner: 42 or pull_number: \"5\" (when the handler uses RequiredParam[int]-style extraction) instead of the schema-declared type; arrays/objects passed to scalar required fields.","commonSituations":"Quoted numbers from form input or LLM output; client serializers that stringify everything; key-value confusion after schema changes.","solutions":["Match the exact JSON type declared in the tool's inputSchema for that key.","Read the error text: it states the parameter name and the expected type.","For numeric fields that must be strings, prefer tools whose params accept numeric strings (RequiredInt/RequiredBigInt paths).","Add client-side schema validation to catch type mismatches before the request."],"exampleFix":"// before\narguments = { owner: \"octocat\", repo: \"hello\", pull_number: \"5\" }\n// after\narguments = { owner: \"octocat\", repo: \"hello\", pull_number: 5 }","handlingStrategy":"type-guard","validationCode":"function assertType(name, v, expected) {\n  if (v !== undefined && typeof v !== expected) {\n    throw new Error(`${name} must be ${expected}, got ${typeof v}`);\n  }\n}","typeGuard":"function isStringParam(v: unknown): v is string {\n  return typeof v === \"string\";\n}","tryCatchPattern":"Parse 'parameter X is not of type T' from the error result, coerce the named argument to the declared JSON type, and retry once.","preventionTips":["Do not quote numbers or stringify booleans when building arguments.","Derive argument types from the tool schema, not from loose any-typed objects.","Add a client-side JSON-schema validator for outgoing tool calls."],"tags":["validation","type-mismatch","argument-parsing","mcp-tool"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}