{"record":{"id":"061ea49187a2f05d","repo":"paperclipai/paperclip","slug":"companyid-is-required-because-paperclip-company-id","errorCode":null,"errorMessage":"companyId is required because PAPERCLIP_COMPANY_ID is not set","messagePattern":"companyId is required because PAPERCLIP_COMPANY_ID is not set","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/mcp-server/src/client.ts","lineNumber":65,"sourceCode":"    return text;\n  }\n}\n\nexport class PaperclipApiClient {\n  constructor(private readonly config: PaperclipMcpConfig) {}\n\n  get defaults() {\n    return {\n      companyId: this.config.companyId,\n      agentId: this.config.agentId,\n      runId: this.config.runId,\n    };\n  }\n\n  resolveCompanyId(companyId?: string | null): string {\n    const resolved = companyId?.trim() || this.config.companyId;\n    if (!resolved) {\n      throw new Error(\"companyId is required because PAPERCLIP_COMPANY_ID is not set\");\n    }\n    return resolved;\n  }\n\n  resolveAgentId(agentId?: string | null): string {\n    const resolved = agentId?.trim() || this.config.agentId;\n    if (!resolved) {\n      throw new Error(\"agentId is required because PAPERCLIP_AGENT_ID is not set\");\n    }\n    return resolved;\n  }\n\n  async requestJson<T>(method: string, path: string, options: JsonRequestOptions = {}): Promise<T> {\n    if (!path.startsWith(\"/\")) {\n      throw new Error(`API path must start with \"/\": ${path}`);\n    }\n\n    const url = new URL(path.slice(1), `${this.config.apiUrl}/`);","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/mcp-server/src/client.ts#L47-L83","documentation":"PaperclipMcpClient.resolveCompanyId returns the explicitly passed companyId if present, otherwise falls back to config.companyId (sourced from PAPERCLIP_COMPANY_ID). If both are empty after trim, it throws — every company-scoped tool needs a concrete company to act within.","triggerScenarios":"A tool is invoked without an explicit companyId argument while the server was started without PAPERCLIP_COMPANY_ID, or with that var set to whitespace only.","commonSituations":"Multi-tenant deployment where the operator expected per-call company selection but did not set the env fallback; .env not loaded in the MCP server process; value stripped by a secret manager.","solutions":["Set PAPERCLIP_COMPANY_ID in the server's environment and restart.","Pass companyId explicitly in the tool call arguments.","Verify the env var is actually visible to the process (print process.env at startup)."],"exampleFix":"// before: server started without PAPERCLIP_COMPANY_ID\n// after\nexport PAPERCLIP_COMPANY_ID=comp_123\n# restart MCP server","handlingStrategy":"validation","validationCode":"const companyId = process.env.PAPERCLIP_COMPANY_ID?.trim();\nif (!companyId) throw new Error('Startup config error: PAPERCLIP_COMPANY_ID must be set');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set PAPERCLIP_COMPANY_ID in the deployment env and verify it at startup.","Pass companyId explicitly on tool calls when running multi-company.","Print resolved config once at boot to catch stripped env vars early."],"tags":["configuration","paperclip-mcp","env","tenancy"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}