Deploy claude-mem | Persistent Memory Server for Claude Code

claude-mem server: shared memory for Claude Code, Codex and agents

Deploy claude-mem | Persistent Memory Server for Claude Code

Just deployed

/data

/var/lib/postgresql/data

Just deployed

Deploy and Host claude-mem on Railway

Deploy on Railway

claude-mem gives Claude Code (and Codex, OpenCode, Gemini CLI and other agents) a memory that lasts across sessions. It captures what your agent does, compresses it into short observations with Claude, and feeds the relevant ones back into later sessions. This template runs claude-mem's server runtime, so that memory lives in one place on Railway instead of on one laptop: every machine and teammate that holds the API key reads and writes the same memory, and any MCP client can search it.

About Hosting claude-mem

Three services on Railway's private network:

  • claude-mem: the server runtime from a pinned claude-mem release. It serves the /v1 API and the /v1/mcp recall endpoint, and runs memory generation in the same process. The embedding model for search by meaning is baked into the image.
  • Postgres 17 with pgvector, holding events, observations, sessions and API keys, on a volume.
  • Redis for the BullMQ generation queue, with append-only persistence on a volume.

On first boot the server creates a team, a project and an API key with read and write access. The key is CLAUDE_MEM_API_KEY, generated by Railway when you deploy. Every request needs it, so the public URL is useless without it.

Common Use Cases

  • Keep one Claude Code memory across your laptop, desktop and cloud dev boxes
  • Share project memory with teammates, so their agent knows what yours already learned
  • Search past sessions from any MCP client: "when did we change the retry limit?"
  • Give hosted agents (Hermes, OpenClaw, CI bots) a memory that survives redeploys

Dependencies for claude-mem Hosting

  • An Anthropic API key (ANTHROPIC_API_KEY) for memory generation. Gemini and OpenRouter work too.
  • claude-mem installed on each machine whose sessions you want captured (npx claude-mem install).

Deployment Dependencies

Implementation Details

Recall from any MCP client (read-only). Copy CLAUDE_MEM_API_KEY from the claude-mem service's Variables tab, then:

claude mcp add --transport http claude-mem https://‹your-domain›/v1/mcp \
  --header "Authorization: Bearer ‹CLAUDE_MEM_API_KEY›"

Capture from Claude Code. Install claude-mem locally, then point its hooks at the server in ~/.claude-mem/settings.json. The project id is printed in the claude-mem service's deploy logs ([railway-setup] project id: ...):

{
  "CLAUDE_MEM_RUNTIME": "server",
  "CLAUDE_MEM_SERVER_URL": "https://‹your-domain›",
  "CLAUDE_MEM_SERVER_API_KEY": "‹CLAUDE_MEM_API_KEY›",
  "CLAUDE_MEM_SERVER_PROJECT_ID": "‹project id›"
}

Generation provider: claude by default, using ANTHROPIC_API_KEY. For Gemini set CLAUDE_MEM_SERVER_PROVIDER=gemini and GEMINI_API_KEY; for OpenRouter, openrouter and OPENROUTER_API_KEY. Without a key, events are still stored and nothing is generated until you add one.

More keys: POST /v1/keys with your key mints a read-only key for a teammate and returns a ready claude mcp add command.

Notes and limits:

  • claude-mem's server runtime is labelled beta upstream; routes and settings can change between releases. The template pins a release and is updated deliberately.
  • Generation calls cost provider tokens on every captured event. Set CLAUDE_MEM_MONTHLY_TOKEN_CAP on the claude-mem service to cap spend.
  • CLAUDE_MEM_API_KEY only matters on first boot. To replace it, set a new value: the next boot adds it as another key. Revoke the old one in Postgres (api_keys.revoked_at).
  • Back up the Postgres volume before upgrades; it holds all your memory.

Why Deploy claude-mem on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying claude-mem on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
117
View Template
NEW
Weaviate
Vector database with hybrid search and an API key-protected API

zer0person
1
View Template
Möbius v0.1 Personal AI OS
Self-hosted AI agent that builds and runs apps for you, with memory.

bento
1