Back to MCP Servers

Longhand

Persistent local memory for Claude Code. Indexes every session JSONL verbatim into SQLite + ChromaDB for semantic recall (~126ms) across your entire history. Never summarizes, zero API calls, 17 MCP tools including fuzzy `recall`, deterministic `replay_file`, and git-aware `reca…

knowledge-memorysqliteapi
By Wynelson94
113Updated 6 days agoPythonMIT

Installation

npx -y longhand

Configuration

{
  "mcpServers": {
    "longhand": {
      "command": "npx",
      "args": ["-y", "longhand"]
    }
  }
}

How to use

  1. Run the installation command above (if needed)
  2. Open your Claude Code settings file (~/.claude/settings.json)
  3. Add the configuration to the mcpServers section
  4. Restart Claude Code to apply changes
<!-- mcp-name: io.github.Wynelson94/longhand -->

Longhand

Longhand MCP server PyPI version Python License Tests Local SafeSkill 93/100

Persistent local memory for Claude Code. Every tool call, every file edit, every thinking block from every Claude Code session — stored verbatim on your machine. Searchable, replayable, and recallable by fuzzy natural-language questions. Zero API calls. Zero summaries. Zero decisions made by an AI about what's worth remembering.

Claude Code quietly rotates your session files after a few weeks. Longhand captures them into SQLite before they're gone. Once ingested, your history stays forever — even after the source JSONL files are deleted. Install early; the past you don't capture is unrecoverable.

If you have 20+ Claude Code sessions in ~/.claude/projects/, Longhand can search across every fix, decision, and conversation you've had in ~56ms — without a single API call.

Does it use a lot of tokens? No — every tool is capped by design. A full recall across 100+ sessions returns ~4K tokens. Reading one raw session JSONL costs 10–50× more. See Token budget.

pip install longhand
longhand setup        # ingest history + install hooks + configure MCP
longhand recall "that stripe webhook bug from last week"

Want to kick the tires first? Run longhand demo for a 60-second walkthrough on a fake 3-session sample corpus — your real ~/.claude and ~/.longhand are not touched. The demo seeds a sandboxed store with a Stripe-webhook bug + Supabase auth migration + downstream 401 fix, then runs cross-session recall and project-status so you can see what the output looks like before committing.

pip install longhand
longhand demo         # sandboxed; cleans up afterwards (pass --keep to explore)

Upgrading to 0.9.0? Live ingestion captures sessions in flight, plan history is preserved as first-class data, and an optional reconciler job keeps the index honest in the background:

  • New longhand ingest-live command runs from Claude Code's Stop hook to tail the active transcript between assistant turns. Sessions show up in recall while you're still working, not after they end.
  • New longhand plans list command and list_plans MCP tool surface every Write/Edit to ~/.claude/plans/*.md across your entire history. Plans are now extracted as their own entity alongside episodes.
  • New longhand schedule install-reconciler installs an optional launchd job that runs reconcile --fix periodically — catches anything the live and post-session hooks missed without you ever thinking about it.
  • The Stop hook coexists with the existing SessionEnd hook: live tails the transcript as it grows; SessionEnd does the full analysis pass when the session closes.

Upgrading to 0.8.1? Staleness signals now propagate everywhere they belong, and reconcile is an MCP tool — Claude can self-heal the index from inside a session:

  • search and list_sessions now wrap the response with stale: true + stale_reason when the project they're scoped to has on-disk transcripts not yet ingested. Pre-v0.8.1 these returned clean-looking empty results (same silent-failure shape recall_project_status was built to catch — just one layer up).
  • New reconcile MCP tool wraps longhand reconcile --fix. After a staleness banner fires, Claude calls reconcile directly instead of asking the user to run a CLI command.
  • list_sessions default limit raised from 20 to 50 — active days routinely cross 5+ projects across 5+ sessions; the old default truncated reviews silently.

Upgrading from 0.7.x or earlier? Cleaner recall narratives, plus a real bug-finding test layer underneath (from 0.8.0):

  • Pre-v0.8 _compose_fix_summary prepended a literal "Intent:" label to half of all extracted episodes (49% of the reference corpus). The label leaked into every recall narrative for those episodes. Migration v4 strips it from existing rows on first store open — no command needed.
  • Diff content in fix_summary now truncates at whitespace boundaries with a visible , instead of landing mid-token (phoneNum', family?:', strin'). Forward-only.
  • Narrative footer "Other matches" lines now include the session id so you can drill in.
  • New canary harness (tests/fixtures/corpus/) anchors regression tests to real shipped bugs. New recall validator (scripts/recall_diff.py) snapshots and diffs ranking results against your live corpus — catches regressions pytest can't see.
pip install --upgrade longhand
longhand recall "..."   # migration runs transparently on first open

If you're also coming from 0.5.x, run longhand reconcile --fix once to re-attribute multi-project sessions per the v0.6 inference improvements (cd-into-project sessions now attribute to the project where most work happened, not the first-event cwd). If you're on 0.5.8 or earlier, chain them: longhand reconcile --fix && longhand analyze --all. Both are idempotent.

Large history? (>1 GB of ~/.claude/projects) Expect the first-time backfill to take 10–30 minutes on an M-class Mac — most of that wall time is the embedding model running on all your cores (which is why you'll see triple-digit CPU%; that's ONNX doing its job, not a hang). To get a working store faster, use the fast-path:

longhand setup --skip-analysis   # SQLite only; works in ~1 min for multi-GB corpora
longhand analyze --all           # fill in episodes + vectors whenever, safe to background

Exact-text search, timelines, file history, and commit lookup all work after --skip-analysis. Semantic recall needs the analyze --all pass to complete. Typical throughput on an M-class Mac is ~1–2 sessions/sec for full analysis.

Status: v0.11.1 — stable, daily-driver tested, security-audited (zero critical findings), on PyPI, available as a Claude Code plugin. Validated against 246 real Claude Code sessions across 54 inferred projects. 316 unit tests passing.

Full docs: Longhand Wiki — getting started, CLI reference, MCP tools reference, architecture, and troubleshooting.

Longhand demo


The Inversion

Everyone is solving AI memory by making the context window bigger. 1M tokens. 2M tokens. Context-infinite. The whole industry is racing in the same direction: make the model carry more state.

Longhand goes the other direction. The model doesn't need to carry the memory. The disk does.

Bigger context windowsLonghand
Where it livesRented from a model providerA SQLite file + ChromaDB on your laptop
Cost per queryTokens × dollarsZero
PrivacyGoes through someone else's serversNever leaves your machine
SpeedSeconds to minutes for large contexts~56ms search · ~1.4s full recall
LossAttention degrades in the middle of long contextsEvery event from the source file, nothing dropped
PersistenceDies when the window closesLives until you delete the file
Across model versionsDoesn't transferSame data, any model
OfflineNoYes
Scales withProvider's pricingYour hard drive

The "memory crisis" in AI was an artificial constraint. Storage is solved. SQLite is from 2000. ChromaDB is two years old. Both run on a laptop. Longhand bypasses the crisis by ignoring it — your past sessions are already on disk, written by Claude Code itself, in JSONL files that contain every single event verbatim. Longhand reads those files, indexes them locally, and gives you semantic recall over your entire history without ever sending a token through someone else's API.

Local. Complete. Yours.

Storage footprint: ~2GB for a heavy power user (240+ sessions, 125k events, months of daily Opus usage across 14 repos). Typical users: 200–400MB. Once Claude Code rotates the source files off disk, Longhand isn't a duplicate — it's the only copy.


Python version note

Python 3.10 – 3.13 are fully supported. On Python 3.14, longhand pins chromadb<1.0 automatically because chromadb's newer Rust bindings segfault on 3.14 (see #4). Once chromadb ships a 3.14-compatible 1.x wheel, the constraint will relax.


Longhand vs claude-mem

thedotmack/claude-mem is the most popular Claude Code memory tool on GitHub (55k+ stars). It's a good tool. It is also solving the memory problem in the opposite direction from Longhand, and the difference is worth understanding before you pick one.

claude-memLonghand
What's storedAI-generated summaries / "observations"Verbatim events from the raw JSONL
Who decides what's keptAn LLM, at write timeNobody — everything is kept
CompressionSemantic (lossy, by design)None (lossless)
API calls per sessionOne or more (calls Claude to summarize)Zero
Thinking blocksTypically folded into summariesFirst-class, stored verbatim
Deterministic replayNo — summaries can't reconstruct file stateYes — every diff kept and replayable
Model portabilityTied to the summarizer's outputSame data works across any model, forever
RuntimeTypeScript, Bun, HTTP worker on :37777Python, no server
LicenseAGPL-3.0MIT

The philosophical split: claude-mem asks an AI what was important and keeps that. Longhand keeps the actual bytes and lets you decide later. If you trust a model's judgment about its own past, claude-mem's approach is cheaper at query time (pre-summarized) and easier on storage. If you've ever been burned by a summary that dropped the thing that turned out to matter, Longhand is the tool that never throws anything away.

Both can coexist on the same machine — they operate on the same JSONL files without interfering.


The Principles

Longhand is built on a handful of principles. If you disagree with them, you probably want a different tool.

1. Information doesn't disappear — it moves.

When data goes "missing" it's almost never actually gone. It got compressed, summarized, filed somewhere else, or renamed. Find the raw source and th

View source on GitHub