memshelf-mcp
The memshelf-mcp server lets AI agents manage episodic memory by offloading, organizing, and retrieving information to a local, version-controlled shelf, optimizing token usage and preserving detailed context.
Initialize a shelf (
memshelf_init): Bootstrap with chosen storage (git-local, plain, git-remote), including INDEX preamble, POLICY template, and ledger header. Idempotent.Shelve an episode (
memshelf_shelve): Offload a closed topic as a validated, structured episode with a digest (≤120 words), sections, tags, redacted secrets, and optional autocommit. Enforces digest contract, appends ledger row, returns address.Recall episodes or sections (
memshelf_recall): Fetch a full episode or a specific H2 section by ID, wrapped in a data envelope. Optionally logs recalls for realized-savings accounting.Read the INDEX (
memshelf_index): Retrieve the compact shelf index—the lightweight entry point for all shelved memories.Search the shelf (
memshelf_search): Grep episodes for all query tokens, returning matching addresses and snippets (split episodes match at section level).View token economy (
memshelf_stats): Report standing cost (INDEX + digests) vs. shelved mass, compression ratio, and realized savings from logged recalls.Resolve multi-writer conflicts (
memshelf_resolve): Merge ledger/recall-log rows from parallel sessions and rebuild derived files; never auto-merges conflicting episodes. Useful as a rebuild tool even without conflicts.Check shelf integrity (
memshelf_doctor): Diagnose episode schema, digest contract, accidental secrets, ledger consistency, INDEX budget, and optional public remote visibility. Read-only.Import transcripts (
memshelf_import): Discover conversations in exported transcripts (Claude.ai JSON or Claude Code JSONL) and extract a cleaned working file for segmented shelving, without exposing raw data to context.Regenerate derived files: Rebuild
INDEX.md,ledger.tsv,stats.svg, etc. from source episodes to ensure consistency or adopt new storage patterns.Window management advice: Propose actions (shelve, drop, rollup) to reclaim token window space based on current context occupants and their token consumption.
Rollup episodes: Consolidate multiple episodes over a period into a single rollup episode with a new digest, archiving original episodes to keep the main index concise.
Purge episodes: Delete expired episodes from the working tree while retaining them in git history for future reference.
Supports cross-writing and reading the same memory shelf with Google's Gemini CLI, enabling vendor-portable memory across different AI platforms.
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., "@memshelf-mcpShelve this conversation as 'design-review'"
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.
memshelf-mcp
Put your agent's memory on a shelf, hand it the index.
_ _ __
_ __ ___ ___ _ __ ___ ___| |__ ___| |/ _|
| '_ ` _ \ / _ \ '_ ` _ \/ __| '_ \ / _ \ | |_
| | | | | | __/ | | | | \__ \ | | | __/ | _|
|_| |_| |_|\___|_| |_| |_|___/_| |_|\___|_|_|
____________________________________________
| INDEX >> | E-01 | E-02 | E-03 | E-04 | ... |
|__________|______|______|______|______|_____|
memory shelves for AI agentsWhat this is
Long-running agent sessions burn tokens re-sending history and lose detail to lossy auto-compaction. memshelf applies the docshelf pattern — tiny index in context, bodies fetched on demand — to the agent's own working memory:
Closed conversation topics, research dumps, and bulky tool output are offloaded to a local shelf as Markdown episodes.
Each episode carries an LLM-written, contract-validated digest that preserves decisions, rejected alternatives, artifacts, and open threads.
The agent keeps only
INDEX.md(kilobytes) + digests in context and recalls exact sections via INDEX → SUBINDEX navigation over MCP.
Positioning in one sentence: claude-mem's loop, git's substrate, docshelf's navigation — episodic memory you can grep, diff, review, and carry between hosts. Private and local by default: the standard storage mode is a local git repo with no remote configured. The tool is public; the memory never is.
Related MCP server: hmem
Measured, not promised
One week of dogfooding on the live shelf — full numbers and methodology in
docs/demo.md:
Measure | Result |
Episodes on the shelf | 34 |
Standing cost in every session (INDEX + digests) | ~8.6K tokens |
Shelved mass those episodes replace | ~1.9M tokens — ≈220 : 1 |
One question answered from memory | ~1.8K tokens (INDEX + one episode) |
Recall test: fresh agent, INDEX path only | 5 / 5 — zero misses, zero over-fetch |
Tokens are counted as chars/4 everywhere, so the ratios are estimator-independent; absolute counts move with the tokenizer.
Quick start
As an MCP server:
# Claude Code
claude mcp add memshelf -- uvx memshelf-mcp// Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"memshelf": { "command": "uvx", "args": ["memshelf-mcp"] }
}
}As a Claude Desktop extension — adapters/claude-desktop/:
an .mcpb bundle installed from Settings → Extensions, with a Default
shelf setting so calls need not repeat the path. Nothing has to be installed
alongside it — not even Python.
As a Claude Code plugin — adapters/claude-code/:
a /shelve skill plus SessionStart / SessionEnd / PreCompact hooks.
Or from the shell (pip install memshelf-mcp, Python ≥ 3.10) — the same
loop, no MCP:
memshelf init --shelf ~/my-shelf --name "My working memory"
memshelf shelve --shelf ~/my-shelf --slug 2026-07-23-topic --kind topic \
--digest "What was decided, what was rejected and why, what stays open." \
--section "Decisions=What was decided, and what was rejected instead — one line each."
memshelf recall --shelf ~/my-shelf --id 2026-07-23-topic --section Decisions --log
memshelf stats --shelf ~/my-shelf # claimed + realized savings
memshelf doctor --shelf ~/my-shelf # exit 1 on integrity errorsTool surface
One verb per job; the same names over MCP (memshelf_*) and in the CLI:
Tool | What it does |
| Create (or top up) a memory shelf: docshelf layout, fixed categories |
| Offload one closed topic as a durable, indexed episode; |
| Validate a digest against the contract without touching the shelf |
| Retro-shelve a whole exported dialog without pulling it through context |
| Return the shelf INDEX — the small recall entry point |
| Fetch an episode by id, or a single |
| Grep the shelf; returns matching episodes |
| The shelf's token economy: standing cost vs shelved mass, claimed vs realized |
| What your context is made of and what you could put down — proposals only |
| Regenerate every derived file from the episodes |
| Archive a period behind one digest-of-digests |
| Drop episodes past |
| Settle multi-writer conflicts: regenerate derived, union the recall log |
| Diagnose: episode schema, digest contract at rest, secret shapes, index bloat |
The rules the tools enforce
The digest is a contract, not a convention. It is the only thing read at
recall before fetching a body, so a weak one devalues the whole episode.
lint_digest runs the same validator as shelve with no side effects
(--strict turns warnings into failures); errors block a shelve, warnings do
not — a pure reference digest legitimately carries no decision marker. A
rejected digest is a feature: the tool prints exactly what to fix and writes
nothing.
--amend re-runs the whole pipeline — redaction, the digest contract,
composition — so an amended episode is exactly as guarded as a fresh one,
which a hand-edit of the file never is. Amending a slug that is not on the
shelf is an error, not a create.
The episode is the source; everything else is output. ledger.tsv,
INDEX.md, stats.svg and each category's .meta.json are derived:
shelve writes and commits the episode alone, rebuild renders the rest —
delete all four and rebuild restores them byte-identically. That is what
makes two sessions shelving in parallel a non-event: the merge is clean by
construction. On a shared shelf, let a bot own the derived files on main —
ready-to-copy workflows in adapters/shelf-repo/;
rebuild --adopt migrates an older shelf once, rebuild --check is the
CI guard.
Two consequences worth stating plainly, because getting them wrong costs a merge conflict:
doctorreportsno-ledger-rowandstale-indeximmediately after a correctshelve— on every branch,mainincluded. Nothing is broken: the episode is written, the derived files are not rendered yet. They clear on the nextrebuild— the bot's run, on a shelf that has one.Do not rebuild and commit the derived files by hand to silence them. That is exactly the conflict class the split removes: a hand-regenerated
ledger.tsv/INDEX.md/stats.svgmeets the bot's, and the merge stops being clean by construction. Wait for the renderer; on a shelf without a bot, runmemshelf rebuild --shelf .as its own step.
If those warnings persist for a day while episodes keep arriving, that is a
different state — the renderer is not lagging, it is stopped — and doctor
says so separately, as derived-stale at error severity.
advise proposes, never writes. It answers the question the project was
founded on — a dead topic has been occupying 30K tokens for forty minutes.
The tool cannot see your window, so you tell it what is in there:
memshelf advise --shelf ~/my-shelf \
--occupant 'auth refactor=42000,closed' \
--occupant 'search dump=9000,idle=18' \
--occupant 'Case B verdict=12000,live,episode=2026-07-22-case-b-verdict'Three things keep it honest: it counts itself (INDEX + digests are in the
report, not left out of it), it verifies episode= claims before
proposing a drop, and it reports net — a topic too small to pay for its
own digest is not proposed at all.
Rollup shrinks navigation and nothing else. When INDEX grows into a real
share of your window, rollup collapses a period into one digest-of-digests
and moves the originals to archive/ — still reachable by recall and
search, every ledger row intact. The rollup digest is yours, not the tool's:
synthesizing a quarter is the part a tool cannot do.
index-bloat is not what a rollup is for. INDEX lists your episodes, so
its size grows with the shelf by design; its budget grows with the shelf too
(INDEX_BASE_TOKENS + INDEX_TOKENS_PER_ENTRY × listed). Over budget therefore
means entries are overpriced, never that there are too many of them — so
doctor reports the cost of one line, and the fix is to trim it and
rebuild. A rollup would remove entries and their allowance together and
leave the price where it was. Having the two paired the other way is what made
"archive a third of your memory" the standard way to silence a formatting
problem.
purge deletes the working tree, not history. Retention is opt-in per
episode (--retain-until); purge is a dry run until --apply — and even
then git history still has the file. Real erasure is a deliberate
filter-repo pass over the whole repository, never a side effect of a tool
call, and the purge report says so.
resolve regenerates derived paths, never merges them — a derived file
has no history, only a current correct value. The one file it unions is
recall-log.tsv, because a recall is an event, not a fact about the
episodes. Conflicting episodes are content, not mechanics: resolve
reports them and steps aside.
The design rationale behind each rule lives in
docs/DECISIONS.md and
docs/ARCHITECTURE.md.
One memory, multiple AIs
The memory is vendor-portable, and that is a measured fact, not a design
intention: the same live shelf has been read and cross-written by Claude Code
(Anthropic) and Gemini CLI (Google) through one shelf-spec server —
protocol and field notes in docs/portability.md.
Status
M0 complete: the pattern was validated with zero code on a live shelf —
retro-import of months of material, then a week of shelve-at-close
(docs/M0.md). M1 shipped the server/CLI that enforces it,
plus the Claude Code plugin. Next milestones with exit criteria:
docs/ROADMAP.md; release history:
CHANGELOG.md.
Documents
Rendered site: https://ignatenkofi.github.io/memshelf-mcp/ — including the week-report infographic from the dogfood shelf.
Doc | What it covers |
Problem, the bet, hero scenarios, principles, non-goals | |
Episode format, digest contract, storage modes, triggers, MCP tool surface, portability model, privacy, failure modes | |
Prior-art survey (2026-07), platform built-ins, positioning, risks | |
Milestones M0–M3 with exit criteria | |
Decision log | |
M0 experiment protocol and results: cases, token ledger, recall test | |
Measured numbers from the dogfood shelf: compression, recall test, doctor findings | |
One memory, multiple AIs: the cross-vendor experiment | |
A worked episode file and a memory-shelf INDEX | |
Claude Code plugin: | |
Claude Desktop |
Origin
Designed as RFC-0001 in the docshelf-mcp repo (#42, #43, #44); this repo is the project's home from 2026-07-13 on. The docshelf copy is frozen as a historical snapshot.
Related projects
docshelf-mcp — the sibling project and storage layer: PDFs/Markdown → chat-project-friendly document shelves with the same index-and-fetch economics (measured: ~3.7K tokens vs 1.2M per question). memshelf was born as RFC-0001 in its repo and reuses its splitter/indexer/read/search verbatim.
The dogfood memory shelf is a private repo — by design (MANIFEST principle 5).
License
MIT — see LICENSE.
mcp-name: io.github.ignatenkofi/memshelf-mcp
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
- AlicenseAqualityAmaintenanceProvides persistent, searchable memory for AI agents, enabling them to retain, recall, and reflect on information across conversations.191MIT
- AlicenseNot gradedqualityAmaintenanceEnables persistent, portable memory for AI agents across sessions, devices, and providers with token-efficient 5-level lazy loading and automatic session capture.41MIT
- AlicenseNot gradedqualityBmaintenancePersistent long-term memory for AI agents via MCP, saving 80-90% memory-related token costs by enabling on-demand recall instead of always-injecting context.67MIT
- AlicenseNot gradedqualityBmaintenanceEnables persistent, graph-based memory for AI agents, allowing them to store, traverse, and recall relationships between facts, decisions, and context across sessions for efficient reasoning and reduced token usage.MIT
Related MCP Connectors
Persistent memory for AI agents. Search, store, and recall across sessions.
Persistent memory for AI agents — verbatim conversations, searchable by meaning.
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
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/ignatenkofi/memshelf-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server