{"record":{"id":"54904419ca16295c","repo":"github/github-mcp-server","slug":"parameter-s-is-not-of-type-t-is-t","errorCode":null,"errorMessage":"parameter %s is not of type %T, is %T","messagePattern":"parameter (.+?) is not of type %T, is %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/params.go","lineNumber":27,"sourceCode":"\t\"github.com/google/go-github/v89/github\"\n\t\"github.com/google/jsonschema-go/jsonschema\"\n)\n\n// OptionalParamOK is a helper function that can be used to fetch a requested parameter from the request.\n// It returns the value, a boolean indicating if the parameter was present, and an error if the type is wrong.\nfunc OptionalParamOK[T any, A map[string]any](args A, p string) (value T, ok bool, err error) {\n\t// Check if the parameter is present in the request\n\tval, exists := args[p]\n\tif !exists {\n\t\t// Not present, return zero value, false, no error\n\t\treturn\n\t}\n\n\t// Check if the parameter is of the expected type\n\tvalue, ok = val.(T)\n\tif !ok {\n\t\t// Present but wrong type\n\t\terr = fmt.Errorf(\"parameter %s is not of type %T, is %T\", p, value, val)\n\t\tok = true // Set ok to true because the parameter *was* present, even if wrong type\n\t\treturn\n\t}\n\n\t// Present and correct type\n\tok = true\n\treturn\n}\n\n// OptionalNullableStringParam preserves omitted, null, and non-empty string values.\nfunc OptionalNullableStringParam(args map[string]any, p string) (*string, bool, error) {\n\tvalue, ok := args[p]\n\tif !ok {\n\t\treturn nil, false, nil\n\t}\n\tif value == nil {\n\t\treturn nil, true, nil\n\t}","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/params.go#L9-L45","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\narguments: { owner, repo, per_page: \"30\" }\n// after\narguments: { owner, repo, per_page: 30 }","handlingStrategy":"type-guard","validationCode":"function checkOptional(args, name, kind) {\n  const v = args[name];\n  if (v === undefined) return; // absent is fine\n  const ok = kind === \"number\" ? typeof v === \"number\" : typeof v === kind;\n  if (!ok) throw new Error(`${name} must be a JSON ${kind}, got ${typeof v}`);\n}","typeGuard":"function isJSONNumber(v: unknown): v is number {\n  return typeof v === \"number\" && Number.isFinite(v);\n}\nfunction isJSONString(v: unknown): v is string {\n  return typeof v === \"string\";\n}","tryCatchPattern":"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.","preventionTips":["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."],"tags":["validation","type-mismatch","argument-parsing","json","mcp-tool"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}