Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 64 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,77 @@ misses by following the links between your notes. It is an MCP server and a CLI
folder of markdown, Obsidian vaults included: `pip install`, point it at the folder, and
Claude Code, Cursor, Codex or any other MCP client can recall from it.

![sgm-index builds the index of the 202-note bench vault, then sgm-ask --ab shows tool-lanternfish entering the top 5 only through a graph hop; the one-minute CPU indexing wait is cut](docs/demo.gif)

**Your agent forgets everything between sessions, and plain vector search gives it back
flat, unrelated chunks. This gives it associative recall over your own markdown notes:
vector search finds the entry points, the `[[wikilinks]]` you already wrote are the graph.
One SQLite file, no graph database, no ETL pass, no server.**

[![PyPI](https://img.shields.io/pypi/v/sqlite-graph-memory)](https://pypi.org/project/sqlite-graph-memory/) [![tests](https://img.shields.io/github/actions/workflow/status/tonydzi/sqlite-graph-memory/tests.yml?label=tests)](https://github.com/tonydzi/sqlite-graph-memory/actions/workflows/tests.yml) [![MCP Registry](https://img.shields.io/badge/MCP%20Registry-io.github.tonydzi%2Fsqlite--graph--memory-blue)](https://registry.modelcontextprotocol.io/v0/servers?search=sqlite-graph-memory) [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)

## Install in your client

Build the index once (any folder of markdown; [`uv`](https://docs.astral.sh/uv/) gives you `uvx`):

```bash
BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --from 'sqlite-graph-memory[embeddings]' sgm-index ~/notes
```

Then point your client at the server. Use the absolute path of that index folder.

**Claude Code**

```bash
claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --with 'sqlite-graph-memory[embeddings]' sqlite-graph-memory
```

**Cursor** (`~/.cursor/mcp.json`; Claude Desktop, Zed and Windsurf take the same `mcpServers` block)

```json
{
"mcpServers": {
"sqlite-graph-memory": {
"command": "uvx",
"args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
}
}
}
```

**VS Code** (`.vscode/mcp.json` in the workspace)

```json
{
"servers": {
"sqlite-graph-memory": {
"type": "stdio",
"command": "uvx",
"args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
}
}
}
```

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

```toml
[mcp_servers.sqlite-graph-memory]
command = "uvx"
args = ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"]
env = { BRAIN_INDEX_DIR = "/absolute/path/to/.sgm-index" }
```

Size, `du -sh` of a fresh Python 3.12 venv on an x86_64 Mac (1 Nov 2026): the base install is
26 MB and has no torch (numpy only, enough for the graph half and the SQLite ledger);
with `[embeddings]`, which indexing and recall need, it is 879 MB, 540 MB of that torch 2.2.2
CPU. On Linux the default torch wheel brings CUDA libraries and is bigger; not measured here.
Already installed with pip? Replace `uvx --with ... sqlite-graph-memory` by `sgm-mcp`
([`examples/mcp-config.json`](examples/mcp-config.json)). Agents that read files first:
[`llms.txt`](llms.txt).

## Three commands

```bash
Expand Down Expand Up @@ -60,14 +124,6 @@ That is the idea in one query, and it is not a blanket win. On this same vault v
ranks ahead of graph mode overall; the numbers are in [`bench/`](bench/README.md). `--ab`
exists so you can measure which one wins on your own notes.

**From any MCP client** (Claude Desktop, Cursor, Zed, Windsurf): `sgm-mcp` after the install
above, or `uvx --with 'sqlite-graph-memory[embeddings]' sqlite-graph-memory`. Set
`BRAIN_INDEX_DIR` to the `index` folder `sgm-index` wrote. Config:
[`examples/mcp-config.json`](examples/mcp-config.json). Claude Code:
`claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=/path/to/index -- sgm-mcp`.
Codex: a `[mcp_servers.sqlite-graph-memory]` table in `~/.codex/config.toml` with
`command = "sgm-mcp"`. Agents that read files first: [`llms.txt`](llms.txt).

## What it is

Graph RAG on SQLite for AI agents — a working pilot, not a framework. It is the extracted
Expand Down
Binary file added docs/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docs/demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Renders docs/demo.gif, the clip at the top of the README. Real run, output not edited.
#
# pip install 'sqlite-graph-memory[embeddings]' # sgm-index and sgm-ask on PATH
# uvx --from 'asciinema<3' asciinema rec --cols 104 --rows 36 -c 'bash docs/demo.sh' demo.cast
# agg --idle-time-limit 2 --last-frame-duration 10 --font-size 16 --theme monokai demo.cast docs/demo.gif
#
# The only cut is agg's idle-time limit: on an x86_64 Mac CPU the embedding pass
# takes about a minute and prints nothing (the progress bar is off), so the gif
# skips that silence. The query is the one from "Three commands" in the README.
set -e
export TQDM_DISABLE=1 SGM_NO_STAR_PROMPT=1 TOKENIZERS_PARALLELISM=false
demo=$(mktemp -d)
cp -R "$(dirname "$0")/../bench/vault" "$demo/notes"
cd "$demo"

say() { # print a command as if typed, then run it
printf '\033[1;32m$\033[0m '
for ((i = 0; i < ${#1}; i++)); do printf '%s' "${1:i:1}"; sleep 0.045; done
echo; sleep 0.4
eval "$1" 2>/dev/null # model-loading warnings go to stderr
}

clear
printf '\033[2m# 202 markdown notes that link to each other with [[wikilinks]]\033[0m\n'
sleep 1.5
say 'sgm-index ./notes'
sleep 2
echo
say "sgm-ask --ab 'In which programming language is the tool behind Project Ouzel written?'"
sleep 1.5
printf '\n\033[2m# the answer is in tool-lanternfish; only the graph hop from project-ouzel reaches it\033[0m\n'
sleep 2
Loading