{"record":{"id":"99ed4936d2f7a6f6","repo":"upstash/context7","slug":"invalid-mcp-max-subscriptions-using-the-default-o","errorCode":null,"errorMessage":"Invalid MCP_MAX_SUBSCRIPTIONS; using the default of ${DEFAULT_MAX_SUBSCRIPTIONS}.","messagePattern":"Invalid MCP_MAX_SUBSCRIPTIONS; using the default of (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/mcp/src/lib/subscriptions.ts","lineNumber":11,"sourceCode":"// Context7's tools, prompts, and resources are static for the process lifetime,\n// so notification subscriptions provide no useful events.\nexport const DEFAULT_MAX_SUBSCRIPTIONS = 0;\n\nexport function getMaxSubscriptions(value = process.env.MCP_MAX_SUBSCRIPTIONS): number {\n  if (value === undefined) return DEFAULT_MAX_SUBSCRIPTIONS;\n\n  const parsed = Number(value);\n  if (Number.isSafeInteger(parsed) && parsed >= 0) return parsed;\n\n  console.warn(`Invalid MCP_MAX_SUBSCRIPTIONS; using the default of ${DEFAULT_MAX_SUBSCRIPTIONS}.`);\n  return DEFAULT_MAX_SUBSCRIPTIONS;\n}\n","sourceCodeStart":1,"sourceCodeEnd":14,"githubUrl":"https://github.com/upstash/context7/blob/4416fb855b8f752be735e34f943b5d0762701aad/packages/mcp/src/lib/subscriptions.ts#L1-L14","documentation":"getMaxSubscriptions parses MCP_MAX_SUBSCRIPTIONS; if the value is set but not a non-negative safe integer, it warns with this message and falls back to DEFAULT_MAX_SUBSCRIPTIONS. The process continues with the default rather than crashing.","triggerScenarios":"Setting MCP_MAX_SUBSCRIPTIONS to a non-numeric string (\"abc\"), a negative number (\"-1\"), a float (\"1.5\"), Infinity/NaN forms, or a value beyond Number.MAX_SAFE_INTEGER, then starting the MCP server (rawMcpHandler / stdioHandle).","commonSituations":"Typo in the env value; quoting issues in .env files adding stray characters; copy-pasting a locale-formatted number like \"1,000\"; setting an empty string.","solutions":["Set MCP_MAX_SUBSCRIPTIONS to a plain non-negative integer, e.g. MCP_MAX_SUBSCRIPTIONS=100.","Remove the variable entirely to use the default.","Check for hidden whitespace, quotes, or commas in the env definition.","Log the parsed value at startup to confirm the setting took effect."],"exampleFix":"// before (in .env)\nMCP_MAX_SUBSCRIPTIONS=\"1,000\"\n// after\nMCP_MAX_SUBSCRIPTIONS=1000","handlingStrategy":"validation","validationCode":"const raw = process.env.MCP_MAX_SUBSCRIPTIONS;\nif (raw !== undefined && !/^\\d+$/.test(raw.trim())) throw new Error(`MCP_MAX_SUBSCRIPTIONS must be a non-negative integer, got: ${raw}`);","typeGuard":"const isValidMaxSubscriptions = (v: string): v is `${number}` => /^\\d+$/.test(v.trim());","tryCatchPattern":null,"preventionTips":["Validate env vars at startup with a schema (e.g. zod).","Use plain integers without quotes, commas, or spaces in .env files.","Remove the variable rather than setting an empty string when you want the default.","Document the expected format next to where the value is configured."],"tags":["environment","configuration","env-var"],"backgroundTag":"invalid-env-var-value","analyzedSha":"4416fb855b8f752be735e34f943b5d0762701aad","analyzedAt":"2026-09-16T20:28:07.148Z","contentChangedAt":"2026-09-16T20:28:07.148Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}