ai-memory — Claude Code MCP server: what it does, how to install
Long-term memory server for AI coding assistants. It keeps architectural context across sessions in a local database without spending tokens until retrieval.
claude mcp add --env AI_MEMORY_DB=<AI_MEMORY_DB> --transport stdio ai-memory -- docker run -i --rm -e AI_MEMORY_DB ghcr.io/alphaonedev/ai-memory:0.5.1What ai-memory does
ai-memory supplies external memory to coding assistants via a local SQLite database powered by FTS5 full-text indexing. It stores user preferences and codebase conventions, automatically elevating critical knowledge to persistent status. Stored facts stay outside the prompt window, which keeps token consumption at zero until an actual search occurs.
Large setups can swap the storage engine for PostgreSQL with Apache AGE to build knowledge graphs. Version 0.9.0 rejects direct unauthenticated HTTP writes by default, while typical MCP tool calls remain open for local workflows. The Docker deployment expects an explicit AI_MEMORY_DB environment path to run.
What it helps with
- retain architectural choices across separate coding sessions
- retrieve previous code corrections via full-text search
- store project rules without bloating the model context window
- share persistent context among different AI assistants
Example prompts for the agent
- Recall our decisions on API error formatting from earlier sessions
- Store this module layout guideline in persistent memory
- Search memory for our database migration rules
How to install ai-memory
Platform CLI
claude mcp add --env AI_MEMORY_DB=<AI_MEMORY_DB> --transport stdio ai-memory -- docker run -i --rm -e AI_MEMORY_DB ghcr.io/alphaonedev/ai-memory:0.5.1Replace <…> with your own values
Platform CLI
codex mcp add ai-memory --env AI_MEMORY_DB=<AI_MEMORY_DB> -- docker run -i --rm -e AI_MEMORY_DB ghcr.io/alphaonedev/ai-memory:0.5.1Replace <…> with your own values
Config file
{
"mcpServers": {
"ai-memory": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"AI_MEMORY_DB",
"ghcr.io/alphaonedev/ai-memory:0.5.1"
],
"env": {
"AI_MEMORY_DB": "<AI_MEMORY_DB>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"ai-memory": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"AI_MEMORY_DB",
"ghcr.io/alphaonedev/ai-memory:0.5.1"
],
"env": {
"AI_MEMORY_DB": "<AI_MEMORY_DB>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e AI_MEMORY_DB=<AI_MEMORY_DB> ai-memory docker run -i --rm -e AI_MEMORY_DB ghcr.io/alphaonedev/ai-memory:0.5.1Replace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about ai-memory
How to install ai-memory in Claude Code?
Run claude mcp add --env AI_MEMORY_DB=<AI_MEMORY_DB> --transport stdio ai-memory -- docker run -i --rm -e AI_MEMORY_DB ghcr.io/alphaonedev/ai-memory:0.5.1, replacing <AI_MEMORY_DB> with your database file path.
What does ai-memory do?
It stores assistant discoveries and user rules in a local database, ranking them by relevance when queried. Prompts do not carry old data until the assistant explicitly retrieves it.
Which database backends are supported?
The server operates on local SQLite with FTS5 indexing. It also supports PostgreSQL paired with Apache AGE for graph-heavy setups.