{"record":{"id":"e38702de24e81d42","repo":"thedotmack/claude-mem","slug":"skipping-local-hook-api-key-bootstrap-claude-mem","errorCode":null,"errorMessage":"Skipping local hook API key bootstrap: CLAUDE_MEM_SERVER_DATABASE_URL is not set. Run `npx claude-mem server keys rotate` after configuring Postgres to provision a key.","messagePattern":"Skipping local hook API key bootstrap: CLAUDE_MEM_SERVER_DATABASE_URL is not set\\. Run `npx claude-mem server keys rotate` after configuring Postgres to provision a key\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/npx-cli/commands/install.ts","lineNumber":952,"sourceCode":"      + `(pg + redis/valkey). The server listens at ${serverBaseUrl}.`,\n  );\n\n  // The server mounts its MCP endpoint at `<baseUrl>/mcp` over HTTP (vs. the\n  // worker's stdio transport); trailing slashes are trimmed so we never emit\n  // `http://host//mcp`.\n  log.info(\n    `IDE MCP config target for the server runtime: http ${serverBaseUrl.replace(/\\/+$/, '')}/mcp`,\n  );\n\n  await maybeBootstrapServerApiKey();\n}\n\nasync function maybeBootstrapServerApiKey(): Promise<void> {\n  // Only attempt if Postgres is configured. Without DATABASE_URL we cannot\n  // reach the api_keys table — the operator must configure the server first\n  // and rerun `claude-mem server keys rotate`.\n  if (!process.env.CLAUDE_MEM_SERVER_DATABASE_URL) {\n    log.warn(\n      'Skipping local hook API key bootstrap: CLAUDE_MEM_SERVER_DATABASE_URL is not set. '\n        + 'Run `npx claude-mem server keys rotate` after configuring Postgres to provision a key.',\n    );\n    return;\n  }\n  try {\n    await bootstrapAndPersistServerApiKey();\n  } catch (error: unknown) {\n    // [ANTI-PATTERN IGNORED]: the failure is already surfaced to the user via the interactive-aware log.warn wrapper below (p.log.warn in a TTY, console.warn otherwise), including the manual remediation command.\n    log.warn(\n      `Failed to bootstrap server API key: ${error instanceof Error ? error.message : String(error)}. `\n        + 'Hooks will fall back to the worker until you run `npx claude-mem server keys rotate`.',\n    );\n  }\n}\n\nasync function bootstrapAndPersistServerApiKey(): Promise<void> {\n  const { bootstrapServerApiKey, persistServerSettings } = await import(","sourceCodeStart":934,"sourceCodeEnd":970,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/npx-cli/commands/install.ts#L934-L970","documentation":"At the end of install, the installer wants to provision a local hook API key by inserting into the server's api_keys table, but that requires Postgres access via CLAUDE_MEM_SERVER_DATABASE_URL. When the env var is unset it skips the bootstrap with this warning and tells you the exact remediation command; hooks keep working by falling back to the worker.","triggerScenarios":"Running `npx claude-mem install` on a machine that does NOT run the claude-mem server component (no CLAUDE_MEM_SERVER_DATABASE_URL exported), or a server deployment where the env var is set only in the service unit, not the interactive shell running install.","commonSituations":"Typical client-only installs — this warning is expected and harmless; forgetting to export the server env in the shell used for install; Postgres configured later, after claude-mem was already installed.","solutions":["If you do not run the claude-mem server: ignore it — hooks use the worker fallback by design.","If you do: export CLAUDE_MEM_SERVER_DATABASE_URL (or put it where install runs), rerun `npx claude-mem install`.","Provision the key manually afterwards: `npx claude-mem server keys rotate`."],"exampleFix":"# before: install without server env\nnpx claude-mem install  # warns: bootstrap skipped\n# after\nexport CLAUDE_MEM_SERVER_DATABASE_URL=postgres://...\nnpx claude-mem install && npx claude-mem server keys rotate","handlingStrategy":"validation","validationCode":"// Decide up front whether server-mode bootstrap applies:\nconst serverMode = Boolean(process.env.CLAUDE_MEM_SERVER_DATABASE_URL);\nif (!serverMode) {\n  // expect the skip warning; plan to run `npx claude-mem server keys rotate` later\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export CLAUDE_MEM_SERVER_DATABASE_URL in the same shell/profile that runs install on server hosts.","Treat the warning as expected on client-only machines — the worker fallback is by design.","After configuring Postgres later, remember the key does NOT auto-provision: run keys rotate."],"tags":["install","env-var","api-key","postgres","server"],"backgroundTag":"missing-env-var","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-21T10:36:37.832Z"}