# lean-memory MCP server

> Provides local-first, persistent agent memory using SQLite to store and retrieve facts with hybrid dense and sparse search.

- Repository: https://github.com/Wuesteon/lean-memory
- Page: https://hostedmcp.org/servers/wuesteon/lean-memory
- Transport: stdio
- Stars: 43
- License: Apache-2.0
- Latest version: 0.3.0

## Install

### Claude Code

```sh
claude mcp add lean-memory -- uvx lean-memory
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "lean-memory": {
      "command": "uvx",
      "args": [
        "lean-memory"
      ]
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "lean-memory": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "lean-memory"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"lean-memory","type":"stdio","command":"uvx","args":["lean-memory"]}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "lean-memory": {
      "command": "uvx",
      "args": [
        "lean-memory"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add lean-memory -- uvx lean-memory
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.lean-memory]
command = "uvx"
args = ["lean-memory"]
```

### Gemini CLI

```sh
gemini mcp add -s user lean-memory uvx -- lean-memory
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "lean-memory": {
      "command": "uvx",
      "args": [
        "lean-memory"
      ]
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `ANTHROPIC_API_KEY` | no | no |  |
| `LM_DATA_ROOT` | no | no | Directory for per-namespace SQLite memory files. Defaults to ~/.lean_memory when unset. |

## FAQ

### How are conflicting facts handled?

Conflicting facts are superseded rather than deleted, allowing you to query past states using point-in-time searches.
