Skip to content

How to Enable Cross-Session Memory with neural-memory MCP Server

Problem

I spent hours explaining my project architecture to Claude Code. We debugged a complex authentication flow, documented the database schema, and figured out why the payment service kept failing. The next day, I started a new session and Claude knew nothing.

Conversation log
Me: "Remember how we fixed the payment service yesterday?"
Claude: "I don't have access to our previous conversation.
Could you explain the issue again?"

I had to re-explain everything:

  • The API uses Bearer tokens with 1-hour expiry
  • The payment service fails if amounts have more than 2 decimal places
  • The database uses composite keys in the orders table
  • The auth middleware strips Bearer before validating

Every session started from zero. Claude couldn’t remember:

  • Debugging insights from previous sessions
  • Architecture decisions we made together
  • Code patterns I prefer
  • Project-specific knowledge

I needed Claude to remember across sessions. Not just within a single conversation.

What I Discovered

I found neural-memory, an MCP server that provides persistent memory for Claude Code. It stores information in a local SQLite database that survives session restarts.

The key insight: it mimics how human brains work. Instead of a simple key-value store, it uses neurons, synapses, and fibers to create associations between memories.

┌─────────────────────────────────────────────────────────────┐
│ Traditional Key-Value Store │
├─────────────────────────────────────────────────────────────┤
│ key: "payment_api" │
│ value: "uses Bearer tokens, 1-hour expiry" │
│ │
│ Problem: Can't find related memories │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ Neural-Memory Structure │
├─────────────────────────────────────────────────────────────┤
│ Neuron: "payment_api" │
│ └── Synapse ──▶ Neuron: "authentication" │
│ └── Synapse ──▶ Neuron: "bearer_tokens" │
│ └── Synapse ──▶ Neuron: "expiry_issues" │
│ │
│ Benefit: Retrieving "payment" finds all related concepts │
└─────────────────────────────────────────────────────────────┘

When I search for “payment”, I get not just the payment info, but also related concepts like authentication and tokens.

Installation

I installed neural-memory via pip:

Terminal
pip install neural-memory

Output:

Successfully installed neural-memory-0.1.0

Then I configured it in my Claude Code MCP settings.

My First Attempt (Failed)

I edited the mcp.json file:

~/.claude/mcp.json
{
"mcpServers": {
"neural-memory": {
"command": "neural-memory"
}
}
}

I restarted Claude Code and tried to store a memory:

Me: "Remember that our API uses Bearer token authentication with 1-hour expiry"
Claude: "I've stored that memory for you."

I started a new session and asked:

Me: "What do you know about our authentication?"
Claude: "I don't have any stored memories about authentication."

The memory didn’t persist. I made a mistake.

The Fix: Missing MCP Flag

The issue was my configuration. neural-memory needs the --mcp flag to run in MCP server mode:

~/.claude/mcp.json
{
"mcpServers": {
"neural-memory": {
"command": "neural-memory",
"args": ["--mcp"]
}
}
}

Without --mcp, the command runs but doesn’t speak the MCP protocol. Claude Code can’t communicate with it properly.

After fixing the config, I restarted Claude Code and tested again:

Me: "Store this: our API uses Bearer token authentication with 1-hour expiry"
Claude: "I've stored that memory."

New session:

Me: "What do you know about our authentication?"
Claude: "Based on stored memories: Your API uses Bearer token
authentication with 1-hour expiry."

It worked. The memory survived a session restart.

How Memory Storage Works

The neural-memory server stores data in SQLite locally:

Terminal
# Default location
ls ~/.neural-memory/
# Output
memory.db config.json

No API keys required. No cloud storage. Everything stays on my machine.

When I tell Claude to store something, it creates a memory with:

Memory structure diagram
┌─────────────────────────────────────────────────────────────┐
│ Memory Structure │
├─────────────────────────────────────────────────────────────┤
│ ID: mem_abc123 │
│ Content: "API uses Bearer tokens with 1-hour expiry" │
│ Timestamp: 2026-03-25T10:30:00Z │
│ Importance: 0.7 │
│ Tags: ["authentication", "api", "security"] │
└─────────────────────────────────────────────────────────────┘

When I retrieve memories, it uses semantic search to find relevant entries.

Practical Usage Patterns

I developed patterns for effective memory storage:

Pattern 1: Store debugging insights

Store this debugging insight: the payment service fails if the
amount field has more than 2 decimal places. We need to round
to 2 decimals before sending to the API.

Pattern 2: Store architecture decisions

Remember that we decided to use PostgreSQL for the main database
and Redis for caching. The session store uses Redis with TTL of
24 hours.

Pattern 3: Store code patterns

Store this: I prefer functional programming style with immutable
patterns. Always use spread operators instead of mutations.

Pattern 4: Retrieve context

What do you know about our database schema?
What debugging insights do we have about the payment service?
What are my coding preferences?

Memory Association

The power of neural-memory is in associations. When I store related memories:

Store: "Payment service endpoint is https://api.payments.example.com"
Store: "Payment service API key is in environment variable PAYMENT_API_KEY"
Store: "Payment service has rate limit of 100 requests per minute"

And later ask:

What do you know about payments?

I get all related memories:

Found 3 memories related to payments:
1. Payment service endpoint: https://api.payments.example.com
2. API key location: PAYMENT_API_KEY environment variable
3. Rate limit: 100 requests per minute
4. Related: Payment service fails on amounts with >2 decimal places

The system auto-associates related concepts.

Memory Audit

Over time, memories accumulate. Some become outdated. I run periodic audits:

Audit my memories. Show me all memories about the API.

Claude lists all relevant memories, and I can delete outdated ones:

Delete the memory about the old API endpoint.
Delete memories older than 30 days that mention "temporary".

Common Mistakes

I made several mistakes learning to use neural-memory:

Mistake 1: Not being explicit about storage

# BAD: Claude won't store this automatically
"We use React with TypeScript"
# GOOD: Explicitly request storage
"Store this: We use React with TypeScript for the frontend"

Claude doesn’t automatically store everything. You need to explicitly ask it to store memories.

Mistake 2: Storing irrelevant information

# BAD: Clutters memory with noise
"Store this: I had coffee this morning"
# GOOD: Store project-relevant information
"Store this: The build fails if node_modules has duplicate packages"

Mistake 3: Not using tags

# BAD: Hard to find later
"Store: The admin panel uses a separate auth flow"
# GOOD: Tags improve retrieval
"Store: The admin panel uses a separate auth flow.
Tags: authentication, admin, security"

Mistake 4: Forgetting to audit

Old memories become stale. I review mine weekly:

Show me all memories about the database.
Which memories are older than 60 days?
Delete memories about the deprecated v1 API.

Memory Privacy

The SQLite database stays on my machine. No cloud sync. No API calls to external servers.

Terminal
# Memory database location
~/.neural-memory/memory.db
# Check what's stored
sqlite3 ~/.neural-memory/memory.db "SELECT * FROM memories LIMIT 5;"

I can back up the database:

Terminal
cp ~/.neural-memory/memory.db ~/backups/neural-memory-$(date +%Y%m%d).db

When Memory Helps Most

neural-memory helps with:

  • Ongoing projects: Store decisions, patterns, and gotchas once
  • Debugging sessions: Remember what fixed similar issues before
  • Team knowledge: Document architecture decisions permanently
  • Code preferences: Store your style preferences once, apply everywhere

It’s less helpful for:

  • One-time questions
  • General programming help
  • Simple syntax lookups

Summary

neural-memory gives Claude Code persistent memory across sessions. Here’s what I learned:

  1. Install with pip install neural-memory
  2. Configure with the --mcp flag in mcp.json
  3. Explicitly ask Claude to store memories
  4. Use tags for better retrieval
  5. Audit memories periodically to remove stale data
  6. All data stays local in SQLite

The installation:

Terminal window
pip install neural-memory

The configuration:

~/.claude/mcp.json
{
"mcpServers": {
"neural-memory": {
"command": "neural-memory",
"args": ["--mcp"]
}
}
}

Now I explain my project once. Claude remembers across sessions. I spend less time repeating context and more time solving problems.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments