How I Built MemCP: Giving Claude a Real Memory

As a solo developer working on his next idea, Claude has been my pair programming partner for months now, and honestly, it’s been incredible, except for one problem that kept driving me crazy:

Every time I hit /compact, Claude forgets everything we just worked on.

All those architecture decisions we debated? Gone. That bug fix we finally figured out? Vanished. Client preferences I mentioned three times? Claude asks again. It’s like Groundhog Day, except I’m the one who has to repeat myself.

Until one evening, when I closed my laptop in frustration and made myself some coffee and decided to dig deeper in the topic. After hours of reading, I found two papers that completely changed my life: Recursive Language Models from MIT and MAGMA about multi-graph memory architecture.

That’s when it clicked. I could build a memory system that works the way I actually think.

What I built

MemCP is an MCP server that plugs into Claude Code. Here’s what makes it different:

Never lose context again

MemCP watches for /compact commands. When you hit it, Claude gets blocked with “save your work first” until it actually saves insights and context. No more silent memory wipes.

There’s also gentle reminders every 10 turns if Claude hasn’t saved anything yet.

Two types of storage

Memory is for insights like decisions, facts, preferences, findings. Small pieces of knowledge that matter.

Contexts are for big stuff such as entire files, docs, logs. These stay on disk. Claude can inspect metadata (file type, size, tokens) without loading anything. Then peek at specific sections, grep for patterns, or chunk into navigable pieces.

Knowledge that connects itself

Every time Claude saves an insight, MemCP automatically builds connections:

  • Links to similar ideas
  • Links to things from the same work session
  • Links cause-and-effect (it detects “because” and “therefore” in text)
  • Links things mentioning the same files or modules

So when you ask “why did we make that choice?”, it doesn’t just keyword search, it follows the cause-and-effect chain.

Search that improves as you go

Start with basic install? Keyword search works fine.

Add one package? You get ranked search.

Add another? Typo tolerance.

Add embeddings? Searches understand meaning, not just words.

The system automatically uses the best method available. No config needed.

Say you have a 50,000-line codebase file. Instead of dumping it into context:

  • Inspect it first (see type, size, preview and costs zero tokens)
  • Chunk it into sections
  • Peek at just section 5
  • Filter for only function definitions

You control what enters your context window.

Smart cleanup

After 30 days, unused stuff gets compressed and archived automatically. Important things (marked critical, accessed frequently, tagged “keep”) stay active.

If you need archived content later, it restores instantly.

Quick install

pip install memcp
bash <(curl -s https://raw.githubusercontent.com/maydali28/memcp/main/scripts/install.sh)

Two minutes. Restart Claude Code. Done.

What difference does it make?

I ran benchmarks comparing normal usage vs. MemCP:

Loading 500 insights normally costs 9,380 tokens. With MemCP? 462 tokens. That’s 20x less.

Analyzing a massive 50K token document? Normally costs 50,460 tokens (eats your whole context). With MemCP? 231 tokens because you’re just peeking at metadata and specific chunks. That’s 218x less.

But the real killer stat: after /compact, normal mode loses almost everything. MemCP keeps 100% of your stored knowledge.

Real workflow example

Morning session:

memcp_remember("User sessions expire after 1 hour, use Redis for storage", 
              category="decision", importance="critical", tags="auth,redis")

Three days later:

memcp_recall(query="how long do sessions last?")

Claude instantly recalls the decision, sees it was tagged critical, knows it’s about auth and Redis.

Working with large files:

memcp_load_context("api-routes", file_path="src/api/routes.py")
memcp_inspect_context("api-routes")  // Shows: python file, 2400 lines, ~15K tokens
memcp_filter_context("api-routes", pattern="def\s+\w+")  // Just function names
memcp_chunk_context("api-routes", strategy="lines", chunk_size=100)  // 24 chunks
memcp_peek_chunk("api-routes", 5)  // Read chunk 5 only

You navigate the file like a filesystem, not cramming it into context.

Why it matters for solo devs

When you’re building alone, you can’t afford to waste time re-explaining yesterday’s decisions. MemCP gave me:

  • No more context anxiety
  • Sessions that build on previous work automatically
  • Ability to work with huge files without thinking about token limits
  • Decisions from last month still accessible today

The three weeks I spent building this paid back in productivity within the first month.

Try it

MemCP is open source (MIT):

21 tools. Zero mandatory dependencies. Works out of the box.

If you’ve ever hit /compact and felt that sinking feeling watching your context disappear, give it a try. Stars and feedback appreciated.

If this helped, drop a heart below!

PS: Yes, Claude helped me build its own memory system. Meta, I know.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Build a Procurement Management System

Next Post

Making Gemini CLI extensions easier to use

Related Posts