{"record":{"id":"2770129786345f98","repo":"paperclipai/paperclip","slug":"missing-paperclip-api-key","errorCode":null,"errorMessage":"Missing PAPERCLIP_API_KEY","messagePattern":"Missing PAPERCLIP_API_KEY","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/mcp-server/src/config.ts","lineNumber":29,"sourceCode":"}\n\nfunction stripTrailingSlash(value: string): string {\n  return value.replace(/\\/+$/, \"\");\n}\n\nexport function normalizeApiUrl(apiUrl: string): string {\n  const trimmed = stripTrailingSlash(apiUrl.trim());\n  return trimmed.endsWith(\"/api\") ? trimmed : `${trimmed}/api`;\n}\n\nexport function readConfigFromEnv(env: NodeJS.ProcessEnv = process.env): PaperclipMcpConfig {\n  const apiUrl = nonEmpty(env.PAPERCLIP_API_URL);\n  if (!apiUrl) {\n    throw new Error(\"Missing PAPERCLIP_API_URL\");\n  }\n  const apiKey = nonEmpty(env.PAPERCLIP_API_KEY);\n  if (!apiKey) {\n    throw new Error(\"Missing PAPERCLIP_API_KEY\");\n  }\n\n  return {\n    apiUrl: normalizeApiUrl(apiUrl),\n    apiKey,\n    companyId: nonEmpty(env.PAPERCLIP_COMPANY_ID),\n    agentId: nonEmpty(env.PAPERCLIP_AGENT_ID),\n    runId: nonEmpty(env.PAPERCLIP_RUN_ID),\n  };\n}\n","sourceCodeStart":11,"sourceCodeEnd":40,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/mcp-server/src/config.ts#L11-L40","documentation":"readConfigFromEnv's second required-field check: PAPERCLIP_API_KEY must be a non-empty string, otherwise the client has no credential to put in the Authorization header. Throws immediately after the URL check.","triggerScenarios":"Server started without PAPERCLIP_API_KEY, or with the var empty/whitespace.","commonSituations":"API key secret not injected by the secrets manager; key rotated and the new one not yet deployed; var name typo (e.g. PAPERCLIP_KEY).","solutions":["Set PAPERCLIP_API_KEY to a valid agent API key from the Paperclip control plane.","Confirm the secret is mounted/exported into the MCP server process.","Verify the var name is exactly PAPERCLIP_API_KEY."],"exampleFix":"# before\nexport PAPERCLIP_API_URL=https://paperclip.example.com/api\n# PAPERCLIP_API_KEY missing -> error\n# after\nexport PAPERCLIP_API_KEY=$(cat /run/secrets/paperclip-key)","handlingStrategy":"validation","validationCode":"if (!process.env.PAPERCLIP_API_KEY?.trim()) throw new Error('PAPERCLIP_API_KEY must be set before starting the MCP server');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inject the API key via your secrets manager, not a committed .env.","Verify the key name is exactly PAPERCLIP_API_KEY.","After rotation, redeploy all processes that cache the key."],"tags":["configuration","env","secrets","startup-validation","paperclip-mcp"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}