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.
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:
pip install neural-memoryOutput:
Successfully installed neural-memory-0.1.0Then I configured it in my Claude Code MCP settings.
My First Attempt (Failed)
I edited the mcp.json file:
{ "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:
{ "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:
# Default locationls ~/.neural-memory/
# Outputmemory.db config.jsonNo 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 │├─────────────────────────────────────────────────────────────┤│ 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 theamount field has more than 2 decimal places. We need to roundto 2 decimals before sending to the API.Pattern 2: Store architecture decisions
Remember that we decided to use PostgreSQL for the main databaseand Redis for caching. The session store uses Redis with TTL of24 hours.Pattern 3: Store code patterns
Store this: I prefer functional programming style with immutablepatterns. 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.com2. API key location: PAYMENT_API_KEY environment variable3. Rate limit: 100 requests per minute4. Related: Payment service fails on amounts with >2 decimal placesThe 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.
# Memory database location~/.neural-memory/memory.db
# Check what's storedsqlite3 ~/.neural-memory/memory.db "SELECT * FROM memories LIMIT 5;"I can back up the database:
cp ~/.neural-memory/memory.db ~/backups/neural-memory-$(date +%Y%m%d).dbWhen 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:
- Install with
pip install neural-memory - Configure with the
--mcpflag in mcp.json - Explicitly ask Claude to store memories
- Use tags for better retrieval
- Audit memories periodically to remove stale data
- All data stays local in SQLite
The installation:
pip install neural-memoryThe configuration:
{ "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