memgw
Allows Hermes agents to prefetch stored memory and synchronize conversation turns into the shared memory store.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@memgwRemember the client's preferred color scheme: dark."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π§ memgw
Shared long-term memory for AI coding agents.
One store that Claude Code, Codex CLI, opencode, and anything that speaks MCP can all read from and write to. Your agents stop forgetting you every session.
English Β· TiαΊΏng Viα»t
npm install -g @holetex/memgw && memgw setupOne command: it creates ~/.memgw, generates keys, asks for your LLM key, wires up
Claude Code (hooks + MCP) and Codex (MCP) when they are on the machine, starts the
gateway, and ends with a health check. What it does NOT fully automate, it says out
loud: reboot supervision is installed automatically on macOS (launchd) and Linux
(systemd --user) from a permanent checkout (npm i -g @holetex/memgw or a clone), while
Windows / npx-cache runs get the exact Task Scheduler / install command printed
instead; opencode gets a one-line copy command. When Codex CLI is found, its
transcript watcher (Codex has no hooks) is installed supervised too on
macOS/Linux β elsewhere the exact memgw watch --agent codex command is printed.
Just want to try it without installing anything? npx @holetex/memgw setup works
too β same wizard, but running from the npx cache means no reboot supervision
(the wizard says so and prints the permanent-install command). Prefer doing
everything by hand? memgw start just starts the gateway and prints the commands.
Prefer delegating? Tell your agent: "install memgw β follow https://github.com/holetexvn/memgw/blob/main/AGENTS.md". AGENTS.md is a playbook written for agents: non-interactive setup, what to ask you (the LLM key), and how to verify the install.
The problem
Every agent keeps its memory in its own silo. Claude Code on your laptop knows nothing about the session you ran on your desktop. Codex knows nothing about either. Close the terminal and the context is gone.
The expensive part of your day is not writing code, it is re-explaining context: what this project is, which conventions apply, what not to touch, and what you already tried last week that did not work.
memgw keeps that in one place. Every agent writes to it, every agent reads from it.
Related MCP server: mcp-chest-memory
Architecture
Three layers, each more distilled than the last:
Layer | What | Written by | Lifetime |
events | raw conversation turns | capture, no LLM involved | 90 days |
facts | one-sentence atoms, deduplicated | worker, 2 LLM calls per batch | forever |
notes | Markdown topic files in a git repo | worker, agentic loop | forever |
Capture is cheap and dumb on purpose: it writes raw turns and returns immediately, so it never slows an agent down. Everything expensive happens later, in the background.
A session with memgw
Retrieval follows one rule that matters: stable context is injected once at session start (profile, topic index) so it stays inside the prompt cache, while specific facts are exposed as tools for the agent to call when it actually needs them. Injecting search results on every turn breaks caching and floods the context with noise.
One fact type earns its keep more than the rest: deadend, meaning something you tried
that failed and why. Agents love repeating the same mistake; this is what stops them.
Why not just⦠?
Chat history | RAG over transcripts | memgw | |
Survives closing the terminal | β | β | β |
Shared across different agents | β | β per-tool | β one store |
Distilled (facts, not walls of text) | β | β raw chunks | β one-sentence atoms |
Remembers what failed and why | β | β οΈ buried | β
|
Prompt-cache friendly | β | β injects every turn | β inject once + tools |
Human-auditable | β | β opaque index | β
|
Infrastructure needed | β | vector DB + pipeline | one SQLite file |
Features
π Every MCP agent β Claude Code, Codex CLI, opencode, claude.ai, Hermes, or any CLI via the generic transcript watcher. Five MCP tools, one endpoint.
π Local-first β one process, one SQLite file, binds
127.0.0.1. Deploy to a VPS with one installer when you want several machines sharing memory.π Hybrid search β FTS5/BM25 always works (no API, no cost);
memgw embed onadds semantic vectors in the same SQLite file, RRF-fused, falling back to BM25 if the embeddings API is down.πͺ¦ Dead-end memory β
type=deadendfacts stop agents from retrying what already failed. The most valuable fact type, and the easiest for humans to forget to pass on.π Git-audited notes β everything the model writes to Markdown is one
git log -paway from inspection and onegit revertaway from undo.π‘οΈ Auth is never optional β the server refuses to start without a key, and refuses weak keys off-loopback. There is no configuration in which memgw is an open store.
πΈ $1β3 / month β cost tracks how much you talk to agents, not store size; every background worker runs off a cursor. Works with any OpenAI-compatible endpoint.
π English + Vietnamese prompts β facts come out in the language you work in (
MEMGW_PROMPT_LANG=vi). Adding a language is copying one block.
Install
Local
npx @holetex/memgw start # zero config, binds 127.0.0.1No LLM key yet? That is the default path, not a degraded one: capture keeps working, events queue locally, and when you add a key later the backlog gets distilled β nothing is lost. Add it whenever you are ready:
memgw key # masked prompt; provider auto-detected from the keyOpenAI, Anthropic, Groq, and OpenRouter keys are recognised by their prefix and
configure the endpoint and a sensible cheap model automatically. Any other
OpenAI-compatible endpoint (DeepSeek, local Ollama or vLLM) works too β set
MEMGW_LLM_BASE_URL in ~/.memgw/env. The key lives in that file on your machine
and is sent only to the provider you chose.
No key at all? npx @holetex/memgw start --mock exercises the entire pipeline without one.
Server
For several machines sharing one store, or for web clients that need a public HTTPS URL:
bash scripts/build-installer.sh # builds memgw-installer.run from this checkout
scp memgw-installer.run user@vps:/tmp/
ssh user@vps "sudo MEMGW_DOMAIN=memgw.example.com MEMGW_LLM_API_KEY=sk-xxx \
bash /tmp/memgw-installer.run"The installer handles Node, a dedicated user, systemd, Caddy with TLS, the firewall, and an optional Litestream backup to S3-compatible storage. See docs/02-OPERATIONS.md.
Connect your agents
Agent | Read | Write |
Claude Code | MCP + |
|
Codex CLI | MCP | transcript watcher |
opencode | MCP | native plugin |
claude.ai / web | MCP connector | the agent calls |
Hermes |
|
|
anything else | MCP, if it speaks it |
|
npx @holetex/memgw hooks # Claude Code capture + bootstrap
claude mcp add --transport http memgw http://127.0.0.1:8931/mcp \
--header "Authorization: Bearer $MEMGW_KEY"
codex mcp add memgw --url http://127.0.0.1:8931/mcp/<MEMGW_MCP_SECRET>
npx @holetex/memgw watch --agent codex # Codex has no hooks, so watch its transcriptsFull details for every client: docs/03-INTEGRATION.md and docs/05-MULTI-AGENT.md.
Adding an unsupported CLI usually needs no code at all:
npx @holetex/memgw watch --agent generic --dir ~/.some-cli/sessions --once --dry-runMCP tools
Five tools, available to every connected agent:
Tool | Purpose |
| search distilled facts, filterable by type and topic |
| search raw transcripts across all agents |
| read a topic note or the profile |
| save a fact |
| profile plus the topic index |
CLI
memgw start Start the gateway
memgw init Create config without starting
memgw status Store statistics
memgw doctor Diagnose configuration and connectivity
memgw search Search facts from the terminal
memgw save Save a fact from the terminal
memgw forget Retire facts (dry-run by default)
memgw key Set the LLM key later (provider auto-detected, gateway restarted)
memgw embed Toggle semantic search on or off
memgw watch Follow agent transcripts
memgw hooks Install Claude Code hooksDesign choices
SQLite plus FTS5, no vector database. Full-text search is the layer that always
works: no API dependency, no cost. Semantic search is one command away (memgw embed on)
and lives in the same SQLite file β vectors as BLOBs, fused with BM25, falling back to
BM25 whenever the embeddings API is down. Off by default.
Notes are Markdown in a git repo. Memory the model writes is memory you must be able
to inspect and correct. git log -p shows every change the worker made, and a bad edit is
one git revert away.
Auth is never optional. The server refuses to start without a key. Bind to anything other than loopback and it also demands a strong one. There is no configuration in which memgw is an open memory store.
Best-effort by design. Every call has a timeout, every failure is swallowed and logged. A dead memory store must never take your agent down with it.
The reasoning behind each of these, including what was rejected and why, is in docs/01-ARCHITECTURE.md.
Measured recall
End-to-end on LoCoMo (1,986 questions through the real capture β extraction β dedup β search pipeline, LLM-judged):
Retrieval | Overall | Refuses correctly when memory has no answer |
BM25 (default) | 58.6% | 84.5% |
+ embeddings ( | 66.4% | 80.3% |
On PersonaMem (COLM 2025, 32k-token tier, 589 multiple-choice questions on user personalization): 59.6% against a 25% random baseline, end-to-end through the same pipeline.
Methodology, per-category numbers, and how to reproduce it for ~$4: docs/06-BENCHMARKS.md.
Cost
Roughly 15 sessions a day across all agents, with a cheap model, comes to about 60 LLM calls and 0.5M tokens per day: $1-3 a month. Cost tracks how much you talk to your agents, not how large the store grows, because every worker runs off a cursor.
Documentation
Document | Read it when |
you want to know how it works and why | |
deploying, configuring, troubleshooting, backups | |
connecting a specific client | |
endpoint and MCP tool reference | |
adding Codex, opencode, or your own CLI | |
measured recall on LoCoMo, and how to rerun it |
Prompt language
Extraction prompts ship in English and Vietnamese. The facts a model writes come out in the prompt language, so pick the one you actually work in:
echo 'MEMGW_PROMPT_LANG=vi' >> ~/.memgw/envAdding a language means copying one block in src/prompts.js. Contributions welcome.
Development
git clone https://github.com/holetexvn/memgw.git
cd memgw && npm install
bash test/run-all.sh # 11 suites, no API key needed; the runner prints totalsThe suite includes verify-docs.mjs, which cross-checks this documentation against the
code: endpoints, tool names, and the constants quoted in prose. Change a default without
updating the docs and the suite goes red.
See CONTRIBUTING.md.
Prior art
The layered-distillation approach and several implementation details were informed by
reading TencentDB Agent Memory
(MIT). memgw is a much smaller, single-user take on the same idea: no team management, no
ACL layer, no external infrastructure. docs/01-ARCHITECTURE.md has a section comparing
the two.
License
MIT
If memgw saves you from re-explaining your project one more time, β the repo β it helps other people's agents find their memory too.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityAmaintenanceProvides persistent memory for AI coding agents via MCP, allowing them to recall fragility, decisions, and bugs across sessions.2943MIT
- Alicense-qualityBmaintenanceProvides a persistent, local-first memory for coding agents over MCP, enabling automatic recall and recording of past work, failures, and decisions to reduce repetition and token usage.MIT
- Alicense-qualityCmaintenanceProvides persistent memory and task management for coding agents via MCP tools, enabling mid-session recall and capture of durable knowledge.432MIT
- Alicense-qualityBmaintenanceProvides persistent, cross-session memory for CLI agents via MCP tools, enabling them to recall, distill, and share experiences across projects and tools.6MIT
Related MCP Connectors
Shared long-term memory vault for AI agents with 20 MCP tools.
User-owned memory for AI agents, Copilot, Claude, IDEs, CLIs, and chat apps over remote MCP.
Your memory, everywhere AI goes. Build knowledge once, access it via MCP anywhere.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/holetexvn/memgw'
If you have feedback or need assistance with the MCP directory API, please join our Discord server