Railway

Deploy Agentmemory — Shared Memory for AI Coding Agents

Self-host shared memory for Claude Code, Cursor & Codex agents

Deploy Agentmemory — Shared Memory for AI Coding Agents

Just deployed

/data

agentmemory viewer caddy

XavTo/caddy-zero-trust

Just deployed

Deploy and Host Agentmemory on Railway

Agentmemory is a self-hosted, persistent memory server for AI coding agents — one long-term memory backend shared across Claude Code, Cursor, Codex CLI, Cline, Goose, and other MCP-compatible tools. Instead of every session starting from zero, it remembers your project architecture, debugging history, decisions, and lessons learned, and serves them back through MCP and a REST API. This template runs it as an always-on backend so your whole toolchain shares the same project memory.


What This Template Deploys

ServicePurpose
AgentmemoryThe memory server — REST API (under /agentmemory/*), MCP surface, and optional viewer

A single service backed by a persistent /data volume that holds all stored memory and sessions across redeploys. Agentmemory computes its own embeddings and compression, so no external database is required for basic operation.


About Hosting

Agentmemory is straightforward once three specifics are understood — and each is a common "is this broken?" moment that this template preempts.

The API lives under /agentmemory/*, not the root path. Hitting the root returns nothing useful, which looks like a failure but is expected — the REST API is served under /agentmemory/* and is protected. Health-check the right path: GET /agentmemory/health with your Bearer token. Pointing a browser at the root and seeing "nothing there" is the number-one false alarm.

AGENTMEMORY_SECRET protects everything — send it as a Bearer token. The public service should expose only the authenticated REST API; the internal streams and engine stay private. Every request needs Authorization: Bearer $AGENTMEMORY_SECRET. Set a strong secret and keep it private — it's the key to your entire coding memory.

The MCP shim is thin — point it at the server for the full toolset. The published @agentmemory/mcp package is a lightweight shim. It exposes the full 53-tool surface only in proxy mode, when it can reach a running server via AGENTMEMORY_URL; with no server reachable it falls back to a 7-tool local set. So if an agent shows only 7 memory tools, it isn't pointed at this deployment — set AGENTMEMORY_URL to your Railway domain and the full toolkit appears.

Compression model choice drives your cost. Agentmemory runs background compression on observations via OpenRouter, so OPENROUTER_MODEL meaningfully affects monthly spend. Compression tolerates a cheaper model well, and the project warns at runtime when you pick a premium-tier one — so choose a low-cost model unless you have a reason not to.

The /data volume is your memory — persist it. All stored memory and sessions live under /data; this template mounts the volume so nothing is lost on redeploy. Embeddings use a current model (replacing Google's text-embedding-004, shut down January 2026), so it's up to date.

Typical cost: ~$5–10/month on Railway for the service and storage, plus your OpenRouter compression usage (small with a cheap model). Agentmemory is open source and free.


How It Compares

Agentmemory (self-hosted)Mem0 / OpenMemoryCloud memory (managed)Local-only MCP memory
FocusCoding agentsGeneral agentsGeneralSingle machine
Shared across toolsYes (team/multi-tool)YesYesNo (local)
AccessMCP + RESTMCP + SDKAPIMCP local
Data ownershipFull — your serverSelf-host or cloudVendorFull
Always-on backendYesVariesYesNo
Self-hostableYesYesNoYes

Local-only memory servers keep everything on one machine, so a second device or teammate can't share it. Managed cloud memory is easy but keeps your context on a vendor's servers. Mem0 and OpenMemory are strong general-purpose options. Agentmemory's focus is coding-agent memory specifically — a shared, always-on backend giving Claude Code, Cursor, and Codex the same long-term project context, self-hosted on infrastructure you own.


Deploy in Under 5 Minutes

  1. Click Deploy on Railway — Agentmemory builds automatically (~2 minutes)
  2. Confirm the /data volume is mounted and set a strong AGENTMEMORY_SECRET
  3. Verify it's live: GET /agentmemory/health with your Bearer token (not the root path)
  4. Set OPENROUTER_MODEL to a low-cost compression model and add your OpenRouter key
  5. In each agent, install the MCP shim and set AGENTMEMORY_URL to your Railway domain for the full toolset

Your coding agents now read and write to one shared, persistent memory.


Common Use Cases

  • Shared team memory — give everyone's Claude Code, Cursor, and Codex the same long-term project context
  • Cross-tool continuity — switch between coding agents without losing architecture decisions and debugging history
  • Persistent project knowledge — retain implementation decisions, preferences, and lessons learned across sessions
  • Custom integrations — connect non-MCP tools directly through the authenticated REST API

Configuration

VariableRequiredDescription
AGENTMEMORY_SECRETRequiredBearer token protecting the API — set a strong secret, send on every request
OPENROUTER_API_KEYRequiredKey for background compression via OpenRouter
OPENROUTER_MODELRecommendedCompression model — pick a low-cost one; premium models overspend
DATA_DIRPre-set/data — memory and session storage on the mounted volume
AGENTMEMORY_SUPPRESS_COST_WARNINGOptional1 to silence the premium-model cost warning once chosen deliberately

Use /agentmemory/* and the Bearer token. The API is under /agentmemory/*, not root, and every request needs Authorization: Bearer $AGENTMEMORY_SECRET. Seeing "nothing" at the root is expected.

Point agents at the server for all 53 tools. The MCP shim gives only 7 tools unless AGENTMEMORY_URL reaches this deployment — set it to your Railway domain in each agent. Persist the /data volume, or memory resets on redeploy.


Dependencies for Agentmemory Hosting

  • Railway account — ~$5–10/month plus OpenRouter compression usage
  • A persistent Railway volume mounted at /data (included)
  • An OpenRouter API key for background compression
  • MCP-compatible coding agents (Claude Code, Cursor, Codex CLI, Cline, Goose)

Deployment Dependencies

Implementation Details

The template runs Agentmemory as a single service exposing its REST API under /agentmemory/*, protected by a Bearer token (AGENTMEMORY_SECRET), with an optional authenticated viewer. Only the REST API is meant to be public; internal streams and the engine stay private. All memory and session state persists on a /data volume across redeploys.

Agents connect through the @agentmemory/mcp shim, which runs in proxy mode when AGENTMEMORY_URL points at a reachable server — exposing the full 53-tool MCP surface (memory_save, memory_recall, memory_smart_search, sessions, governance, and more). Without a reachable server it degrades to a 7-tool local set, the usual cause of a reduced toolset. Background compression summarizes observations through OpenRouter, so OPENROUTER_MODEL is the main cost lever; a low-cost model is recommended, with a runtime warning on premium choices. Embeddings use a current multi-dimensional model replacing the deprecated text-embedding-004. Health is confirmed at /agentmemory/health with the Bearer token; an empty root path is normal.


Frequently Asked Questions

Why does the root URL show nothing? Because the API is served under /agentmemory/*, not the root, and it's protected. Check /agentmemory/health with your Bearer token — an empty root is expected, not a failure.

Why do my agents only show 7 memory tools? The MCP shim falls back to a 7-tool local set when it can't reach a server. Set AGENTMEMORY_URL to your Railway domain so it runs in proxy mode and exposes the full 53-tool surface.

Which agents can share the memory? MCP-compatible coding tools — Claude Code, Cursor, Codex CLI, Cline, Goose, and others — plus any custom tool via the REST API. They all read and write the same long-term project memory.

How do I control the cost? Background compression runs through OpenRouter, so set OPENROUTER_MODEL to a low-cost model — compression tolerates it well. Premium models overspend and trigger a runtime warning.

Does my memory persist across redeploys? Yes, with the /data volume mounted. All memory and sessions live there. Without the volume, they reset.

How do I secure it? AGENTMEMORY_SECRET guards the API as a Bearer token on every request. Set a strong secret and keep it private, since it holds your entire coding memory.

Is it just for coding agents? That's its focus, but any tool can integrate through the authenticated REST API — so non-MCP and custom agents can use the same memory backend too.


Why Deploy Agentmemory 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 Agentmemory on Railway you get an always-on memory backend for your AI coding tools — the REST API and MCP surface exposed, the /data volume persisted, the Bearer token set, and automatic HTTPS. One shared, long-term project memory across Claude Code, Cursor, and Codex, on infrastructure you own.


Template Content

agentmemory viewer caddy

XavTo/caddy-zero-trust

More templates in this category

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

okisdev
113
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
1
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
56