{"record":{"id":"7818452e4898a2d4","repo":"modelcontextprotocol/servers","slug":"invalid-resourceid-args-resourceid-must-be-a","errorCode":null,"errorMessage":"Invalid resourceId: ${args?.resourceId}. Must be a finite positive integer.","messagePattern":"Invalid resourceId: (.+?)\\. Must be a finite positive integer\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/everything/prompts/resource.ts","lineNumber":58,"sourceCode":"      const resourceType = args.resourceType;\n      if (\n        !RESOURCE_TYPES.includes(\n          resourceType as typeof RESOURCE_TYPE_TEXT | typeof RESOURCE_TYPE_BLOB\n        )\n      ) {\n        throw new Error(\n          `Invalid resourceType: ${args?.resourceType}. Must be ${RESOURCE_TYPE_TEXT} or ${RESOURCE_TYPE_BLOB}.`\n        );\n      }\n\n      // Validate resourceId argument\n      const resourceId = Number(args?.resourceId);\n      if (\n        !Number.isFinite(resourceId) ||\n        !Number.isInteger(resourceId) ||\n        resourceId < 1\n      ) {\n        throw new Error(\n          `Invalid resourceId: ${args?.resourceId}. Must be a finite positive integer.`\n        );\n      }\n\n      // Get resource based on the resource type\n      const uri =\n        resourceType === RESOURCE_TYPE_TEXT\n          ? textResourceUri(resourceId)\n          : blobResourceUri(resourceId);\n      const resource =\n        resourceType === RESOURCE_TYPE_TEXT\n          ? textResource(uri, resourceId)\n          : blobResource(uri, resourceId);\n\n      return {\n        messages: [\n          {\n            role: \"user\",","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/76d64c822f5125032f89eb71dbdb94e42b434821/src/everything/prompts/resource.ts#L40-L76","documentation":"Thrown by the `resource-prompt` handler when `resourceId` cannot be coerced into a finite, positive integer. Because prompt arguments are strings, the handler runs `Number(args.resourceId)` and then checks finiteness, integrality, and `>= 1`. Failing any branch raises this error.","triggerScenarios":"Calling `resource-prompt` with a `resourceId` that is `\"0\"`, `\"-5\"`, `\"3.5\"`, `\"abc\"`, `\"Infinity\"`, `\"NaN\"`, an empty string, or omitted (Number(undefined) = NaN).","commonSituations":"Passing a zero-based index, a floating point id, a non-numeric placeholder, or forgetting that prompt args are strings and passing a JSON number that the transport still serializes as a non-coercible value.","solutions":["Provide `resourceId` as a string encoding of a positive integer, e.g. `\"1\"` or `\"42\"`.","Validate/normalize the id client-side: `String(parseInt(id, 10))` and ensure the result is `> 0`.","Use the completer to confirm the id is accepted before issuing the prompt call."],"exampleFix":"// before\n{ resourceType: 'Text', resourceId: '0' }\n// after\n{ resourceType: 'Text', resourceId: '1' }","handlingStrategy":"validation","validationCode":"function isValidResourceId(v: unknown): boolean {\n  const n = Number(v);\n  return Number.isFinite(n) && Number.isInteger(n) && n >= 1;\n}\nif (!isValidResourceId(args.resourceId)) {\n  args.resourceId = '1';\n}","typeGuard":"function isPositiveIntString(v: unknown): v is string {\n  if (typeof v !== 'string') return false;\n  const n = Number(v);\n  return Number.isFinite(n) && Number.isInteger(n) && n > 0;\n}","tryCatchPattern":null,"preventionTips":["Remember prompt args are always strings; send ids as e.g. \"1\", not 1.","Normalize ids client-side: String(parseInt(id,10)) and ensure > 0.","These ids are 1-based; never send 0."],"tags":["mcp","typescript","validation","everything-server","prompts"],"backgroundTag":null,"analyzedSha":"76d64c822f5125032f89eb71dbdb94e42b434821","analyzedAt":"2026-08-12T10:02:41.718Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}