openmemory.sh
+ Docs menu

More

Self-hosting

Run OpenMemory yourself on Node.js with built-in SQLite, or on your own Cloudflare account with Workers and D1. Same API, same MCP server.

The service in https://github.com/lalagias/openmemory (License to be announced) runs in two ways from the same code in apps/api:

  • Node.js with the built-in node:sqlite module. One process, one database file.
  • Cloudflare Workers + D1, the way the hosted service runs.

Both serve the REST API under /v1, MCP at /mcp, the interactive reference at /docs, and the OpenAPI document at /openapi.json.

Node.js

Requirements: Node.js 22.18 or newer (it runs the TypeScript source directly), and pnpm.

git clone https://github.com/lalagias/openmemory
cd openmemory
pnpm install
cd apps/api
node src/node.ts   # or: pnpm start
openmemory listening on http://localhost:8787 (database: .../apps/api/data/openmemory.db)

Create a space against your server and connect clients to http://localhost:8787/mcp:

curl -s -X POST http://localhost:8787/v1/spaces -H 'content-type: application/json' -d '{"timezone":"Europe/Athens"}'

On Node:

  • PORT sets the port (default 8787) and OM_DB_PATH the SQLite file (default apps/api/data/openmemory.db). Migrations run automatically when the database opens.
  • Maintenance (inactive-space cleanup, undo-history purge, nightly dreams, index optimize) runs in-process every hour.
  • There is no server-side model, so spaces in server dream mode get housekeeping only. Use client mode (the default).
  • Rate limits are kept in process memory.

Cloudflare Workers + D1

From apps/api:

pnpm exec wrangler d1 create openmemory      # paste the database_id into wrangler.jsonc
pnpm db:migrate:remote                        # apply migrations to D1
pnpm run deploy                               # wrangler deploy

For local development: pnpm db:migrate:local, then pnpm dev (wrangler dev).

wrangler.jsonc already sets an hourly cron (0 * * * *) for maintenance. Optional bindings:

  • Workers AI for server dream mode: uncomment "ai": { "binding": "AI" } and run pnpm cf-typegen. OM_DREAM_MODEL picks the model (default @cf/meta/llama-3.3-70b-instruct-fp8-fast). Without it, server-mode spaces get housekeeping only.
  • Rate limiting: a Cloudflare Rate Limiting binding named RATE_LIMITER enforces the per-space limit across isolates (its own configured limit applies). Without it, the limit is kept per isolate, which makes it a soft limit.

Configuration

Every limit can be overridden with an environment variable (Worker vars or process.env). Invalid values are ignored.

VariableDefault
OM_MAX_MEMORIES5000
OM_MAX_RECORDS2000
OM_MAX_OPEN_ACTIONS500
OM_MAX_EVENTS10000
OM_MAX_JOURNAL800
OM_MAX_KV1000
OM_MAX_BATCH_OPS50
OM_MAX_BODY_BYTES262144 (256 KB)
OM_REQUESTS_PER_MINUTE120
OM_SPACES_PER_HOUR_PER_IP10
OM_INACTIVE_DAYS90
OM_SCRATCH_DAYS14
OM_DREAM_MAX_CHANGES50
OM_DREAM_INTERVAL_HOURS20

Pointing clients at your server

Replace the hosted URLs in any guide:

HostedSelf-hosted
https://api.openmemory.shhttp://localhost:8787 (or your Worker URL)
https://mcp.openmemory.shhttp://localhost:8787/mcp (or https://<your-worker>/mcp)