---
title: "Deploy agentmemory"
description: "Shared memory server for Claude Code, Codex, Cursor and MCP agents"
category: "AI/ML"
url: https://railway.com/deploy/agentmemory
---

# Deploy agentmemory

Shared memory server for Claude Code, Codex, Cursor and MCP agents

**[Deploy agentmemory on Railway](https://railway.com/template/agentmemory)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/agentmemory/manifest.json

- **Creator:** Two Workspaces
- **Category:** AI/ML

## Template content

### agentmemory https://raw.githubusercontent.com/two-workspaces/agentmemory/main/icon.png

- **Source:** https://github.com/two-workspaces/agentmemory
- **Health check:** /agentmemory/livez
- **Public domain:** Yes

## Documentation

# Deploy and Host agentmemory on Railway

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/deploy/agentmemory?referralCode=sLjDXb&utm_medium=integration&utm_source=button&utm_campaign=agentmemory)

[agentmemory](https://github.com/rohitg00/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_SECRET` is generated at deploy. Every route that reads or writes memories needs it as `Authorization: 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 `localhost` server
- 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

- [agentmemory on GitHub](https://github.com/rohitg00/agentmemory)
- [agentmemory deployment notes](https://github.com/rohitg00/agentmemory/tree/main/deploy)
- [Template source on GitHub](https://github.com/two-workspaces/agentmemory)

### 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:

```bash
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:

```json
"agentmemory": {
  "command": "npx",
  "args": ["-y", "@agentmemory/mcp"],
  "env": {
    "AGENTMEMORY_URL": "https://‹your-domain›",
    "AGENTMEMORY_SECRET": "‹secret›"
  }
}
```

**REST.** Save a memory and search for it:

```bash
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`](https://github.com/rohitg00/agentmemory/blob/main/.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_SECRET` locks 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.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/agentmemory
