Deploy agentmemory
Shared memory server for Claude Code, Codex, Cursor and MCP agents
agentmemory
Just deployed
Deploy and Host agentmemory on Railway
agentmemory is an open-source memory server for AI coding agents. Claude Code, Codex, Cursor, Gemini CLI, OpenCode, Hermes and any MCP client save what they learn while they work, and get the relevant pieces back at the start of the next session. This template runs a pinned agentmemory release as one always-on server, so every machine and teammate shares the same memory. The REST API, MCP tools and the live viewer all sit on one HTTPS address behind a generated secret.
About Hosting agentmemory
- Locked from the first second.
AGENTMEMORY_SECRETis generated at deploy. Every route that reads or writes memories needs it asAuthorization: Bearer ‹secret›, and a request without it gets 401. Only the healthcheck and the viewer's empty page load without the secret, and the viewer asks for it before it shows anything. - REST API and viewer on one domain. Upstream serves the API on port 3111 and the viewer on 3113, and its Railway notes tell you to add a TCP proxy for the viewer. This template puts both behind one gate on the Railway domain: the API under
/agentmemory/, the viewer at/. - Memories on a volume. Everything agentmemory keeps is stored in
/data, which is a Railway volume, so it stays across redeploys and upgrades. - No API key needed. Search runs on BM25 out of the box. You can add on-device embeddings (
EMBEDDING_PROVIDER=local) or a provider key later. - A clear page instead of a crash loop. If the secret is missing or weak, or the volume is missing, the service shows a page that says what to fix and starts nothing.
Common Use Cases
- One shared memory for Claude Code across your laptop, your desktop and cloud sessions
- A team memory: coding agents on several machines save decisions, fixes and conventions to the same server
- Memory for cloud agents (Devin, Hermes, OpenClaw, CI agents) that can't reach a
localhostserver - Browsing, editing, exporting and forgetting what your agents remember in the live viewer
Dependencies for agentmemory Hosting
- A coding agent or MCP client on your machine (Claude Code, Codex, Cursor, Gemini CLI, OpenCode and others)
- Optional: an OpenAI, Anthropic, Gemini, OpenRouter or other provider key, for LLM compression of observations and embeddings
Deployment Dependencies
Implementation Details
Copy AGENTMEMORY_SECRET from the service's Variables tab. Below, https://‹your-domain› is the service's Railway domain.
Claude Code (plugin). Install the plugin with /plugin install (see upstream's README). When Claude Code asks for the plugin settings, enter https://‹your-domain› as the URL and the secret. Hooks and the bundled MCP server then use this server.
Claude Code, Codex and other agents (connector). Install the CLI with npm i -g @agentmemory/agentmemory, run agentmemory connect claude-code --with-hooks (or codex, cursor, gemini-cli, ...), and start the agent with these set in its environment:
export AGENTMEMORY_URL=https://‹your-domain›
export AGENTMEMORY_SECRET=‹secret›
Any MCP client. Add this server block. The @agentmemory/mcp shim forwards the tools to your server:
"agentmemory": {
"command": "npx",
"args": ["-y", "@agentmemory/mcp"],
"env": {
"AGENTMEMORY_URL": "https://‹your-domain›",
"AGENTMEMORY_SECRET": "‹secret›"
}
}
REST. Save a memory and search for it:
curl -X POST https://‹your-domain›/agentmemory/remember \
-H "Authorization: Bearer $AGENTMEMORY_SECRET" -H "Content-Type: application/json" \
-d '{"content":"Project falcon deploys to Railway, region europe-west4","type":"fact"}'
curl -X POST https://‹your-domain›/agentmemory/smart-search \
-H "Authorization: Bearer $AGENTMEMORY_SECRET" -H "Content-Type: application/json" \
-d '{"query":"where does falcon deploy"}'
Viewer. Open https://‹your-domain›/ and paste the secret when it asks. The browser keeps it for that tab only.
Other services in the same Railway project can reach it at http://agentmemory.railway.internal:8080 with the same bearer.
Providers (optional). Set EMBEDDING_PROVIDER=local for on-device embeddings (it downloads a small model on first use and needs more memory), or EMBEDDING_PROVIDER=openai with OPENAI_API_KEY. For LLM compression of observations, set a provider key (for example ANTHROPIC_API_KEY) and AGENTMEMORY_AUTO_COMPRESS=true. Upstream's .env.example lists every setting; add any of them as a service variable.
Custom domain. Set AGENTMEMORY_PUBLIC_URL to https://memory.example.com so the viewer can call the API from that address.
Resources. On Railway, with the default keyless search, it used about 0.35–0.45 GB of RAM while holding 800 memories and answering parallel searches, so it fits the 0.5 GB Free plan limit. With on-device embeddings it used about 0.42 GB; give the service 1 GB if you turn them on, for headroom.
Notes and limits:
- Rotating
AGENTMEMORY_SECRETlocks out every client until you give them the new value. - Back up the volume before upgrades. Railway volumes aren't a portable backup.
- Each template update pins a newer agentmemory release.
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 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
agentmemory
two-workspaces/agentmemory
