thedotmack/claude-mem · warning

Skipping local hook API key bootstrap…

Error message

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.

What it means

During install, the optional local hook API key bootstrap only runs when Postgres is configured via CLAUDE_MEM_SERVER_DATABASE_URL. Without that env var the api_keys table is unreachable, so the installer skips bootstrapping and warns the operator to run `npx claude-mem server keys rotate` after configuring Postgres.

Solutions

  1. If server mode is intended: set CLAUDE_MEM_SERVER_DATABASE_URL to your Postgres connection string, then rerun the installer.
  2. After Postgres is configured, provision a key with `npx claude-mem server keys rotate` as the warning suggests.
  3. If server mode is not intended, ignore the warning — hook API key bootstrap is optional.

Example fix

// before
npx claude-mem install
// after
export CLAUDE_MEM_SERVER_DATABASE_URL=postgres://user:pass@localhost:5432/claude_mem
npx claude-mem install
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.CLAUDE_MEM_SERVER_DATABASE_URL) {
  console.warn('Server API key bootstrap will be skipped; set CLAUDE_MEM_SERVER_DATABASE_URL first if you need server mode.');
}

Prevention

When it happens

Trigger: Running the install command with `process.env.CLAUDE_MEM_SERVER_DATABASE_URL` unset — e.g. default installs that don't use the Postgres-backed server mode.

Common situations: Local-only installs using SQLite/file storage; env var set only in a shell profile not loaded by the npx process; users intending server mode but forgetting to export DATABASE_URL before install.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/e38702de24e81d42. Report an issue: GitHub.

Appendix: source

Thrown at src/npx-cli/commands/install.ts:1017

      + `(pg + redis/valkey). The server listens at ${serverBaseUrl}.`,
  );

  // The server mounts its MCP endpoint at `<baseUrl>/mcp` over HTTP (vs. the
  // worker's stdio transport); trailing slashes are trimmed so we never emit
  // `http://host//mcp`.
  log.info(
    `IDE MCP config target for the server runtime: http ${serverBaseUrl.replace(/\/+$/, '')}/mcp`,
  );

  await maybeBootstrapServerApiKey();
}

async function maybeBootstrapServerApiKey(): Promise<void> {
  // Only attempt if Postgres is configured. Without DATABASE_URL we cannot
  // reach the api_keys table — the operator must configure the server first
  // and rerun `claude-mem server keys rotate`.
  if (!process.env.CLAUDE_MEM_SERVER_DATABASE_URL) {
    log.warn(
      '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.',
    );
    return;
  }
  try {
    await bootstrapAndPersistServerApiKey();
  } catch (error: unknown) {
    // [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.
    log.warn(
      `Failed to bootstrap server API key: ${error instanceof Error ? error.message : String(error)}. `
        + 'Hooks will fall back to the worker until you run `npx claude-mem server keys rotate`.',
    );
  }
}

async function bootstrapAndPersistServerApiKey(): Promise<void> {
  const { bootstrapServerApiKey, persistServerSettings } = await import(

View on GitHub (pinned to d8bc9755e7)