Stop Losing Context: MCP Knowledge Graph Gives AI Real Memory
Every developer has felt that soul-crushing moment. You spend 45 minutes explaining your codebase architecture to Claude, carefully building context layer by layer. You step away for coffee, return to continue the session, and... it's gone. Poof. Your AI assistant greets you with the same generic enthusiasm as a barista who forgot your regular order. Forty-five minutes of meticulous context-building, vanished into the digital void.
Sound familiar? You're not alone. This isn't a bug in your workflow—it's a fundamental limitation of how large language models operate. Statelessness is baked into their DNA. Each conversation starts fresh, each session wipes the slate clean. We've accepted this as "just how AI works," compensating with increasingly desperate workarounds: massive context windows stuffed with pasted documentation, elaborate system prompts that read like legal contracts, third-party vector databases that require their own PhD to configure.
But what if I told you there's a better way? A method so elegantly simple it feels like cheating? Enter MCP Knowledge Graph—a rogue, brilliant fork that's solving AI amnesia at the protocol level. This isn't another vector database selling you complexity. It's persistent memory for AI models through a local knowledge graph, and it's about to change how you build with AI forever.
What is MCP Knowledge Graph?
MCP Knowledge Graph is an open-source MCP (Model Context Protocol) server created by shaneholloman that enables persistent memory for Claude and any MCP-compatible AI platform through a local knowledge graph. Born as a fork focused specifically on local development workflows, it strips away cloud dependencies and puts you in complete control of your AI's memory.
The repository's core mission is deceptively simple: store and retrieve information across conversations using entities, relations, and observations. But the implications are massive. Instead of treating each chat as an isolated event, MCP Knowledge Graph builds a cumulative, queryable memory store that grows smarter with every interaction.
Here's why it's trending hard right now. The AI development community has hit an inflection point. We've moved past the "wow, it can write code" phase into the "how do we actually ship production systems" phase. And production systems require state. They require memory. They require an AI that remembers your API conventions from Tuesday's session when you're debugging on Friday. MCP Knowledge Graph delivers exactly this, using nothing more than local JSONL files and the MCP protocol that Claude Code and Desktop already speak natively.
The "MCP" in the name refers to Anthropic's Model Context Protocol—a standardized way for AI systems to connect to external tools and data sources. By implementing memory as an MCP server, this project slots into your existing Claude workflow with zero friction. No custom clients. No API wrappers. Just pure, persistent memory where you need it most.
Key Features That Separate It From the Pack
Master Database Architecture: At the heart of MCP Knowledge Graph sits the master database—your primary, always-available memory store. Named default in listings and stored as memory.jsonl, it serves as the automatic fallback for all operations. No configuration paralysis, no "which database should I use?" decisions. The master database just works, everywhere, always.
Intelligent Project Detection: Create a .aim directory in any project root, and magic happens. The system automatically detects project-local storage and prioritizes it over global memory. This means your AI remembers project-specific conventions, architectural decisions, and domain knowledge without polluting your global memory store—or vice versa. The .aim naming isn't arbitrary; it stands for AI Memory, and it's your signal that this directory contains your AI's persistent brain.
Multi-Database Organization: While the master database handles the heavy lifting, named databases let you organize by life domain. work, personal, health, learning—create contexts that match how you actually think. Each database becomes a specialized knowledge graph that your AI can query with surgical precision.
Bulletproof Safety System: Here's where the engineering gets delicious. Every memory file starts with {"type":"_aim","source":"mcp-knowledge-graph"}—the safety marker that prevents catastrophic overwrites. Try to write to a JSONL file without this marker, and the system flat-out refuses. It's a small detail that prevents enormous disasters when you're experimenting with file paths.
Location Flexibility with Override: Auto-detection is the default, but you're never trapped by it. Force project or global storage with a simple location parameter. Need to store sensitive work data locally while keeping personal references in your synced Dropbox? Done. The system respects your intent without ceremony.
Database Discovery Tools: The aim_memory_list_stores function exposes every available database across both project and global locations, with clear labeling of which location is currently active. No more guessing where your memories went. No more phantom databases hiding in unexpected directories.
Real-World Use Cases Where This Shines
Long-Running Software Architecture Projects: You're designing a distributed system over three weeks of sporadic Claude sessions. Without memory, you re-explain your event-sourcing strategy every single time. With MCP Knowledge Graph, Claude recalls your OrderAggregate entity, remembers the outbox_pattern relation you established, and builds upon prior observations about your Kafka topology. The knowledge graph becomes your project's living documentation.
Personal Knowledge Management: Researching machine learning papers? Your AI remembers that transformer_attention observation you stored about the "Attention Is All You Need" paper. Six months later, when you're reading about Mamba's selective state spaces, Claude connects the dots—retrieving your prior notes, highlighting the evolution from quadratic attention to linear recurrence. Your AI becomes a genuine research companion, not a search interface.
Cross-Team Development Consistency: Share your .aim directory via version control, and your entire team inherits the project's AI memory. Onboarding new developers becomes frictionless—Claude already knows your coding standards, your preferred abstractions, your "why did we choose this?" decisions. The knowledge graph captures institutional memory that usually walks out the door with departing engineers.
Healthcare and Sensitive Domains: For professionals working with regulated data, local storage isn't optional—it's mandatory. MCP Knowledge Graph keeps everything on your machine. No cloud vectors. No external embeddings services. Your patient's medication history or your client's financial model never leaves your controlled environment, yet your AI retains full contextual awareness.
Multi-Context Life Management: The context parameter enables genuinely personal AI assistance. Your work database tracks Q4 deliverables and stakeholder relationships. Your personal database remembers your mother's birthday and your car's maintenance schedule. Your health database logs symptoms for your upcoming specialist appointment. One AI, multiple lives, zero cross-contamination.
Step-by-Step Installation & Setup Guide
Getting persistent memory running takes under five minutes. Here's the complete path from zero to remembering everything.
Prerequisites
Ensure Node.js 18+ is installed:
node --version
If you need to upgrade, grab the latest LTS from nodejs.org or use your preferred version manager.
Global Memory Setup (Recommended for Beginners)
The fastest path to persistent memory uses global storage with a dedicated directory. Create your memory home:
mkdir -p ~/.aim
Now configure Claude Desktop or Claude Code to connect to the MCP server. Edit your claude_desktop_config.json or .claude.json:
{
"mcpServers": {
"Aim-Memory-Bank": {
"command": "npx",
"args": [
"-y",
"mcp-knowledge-graph",
"--memory-path",
"/Users/yourusername/.aim"
]
}
}
}
Critical: Replace /Users/yourusername/.aim with your actual path. On macOS, that's typically your home directory. On Linux, same pattern. Windows users should use the appropriate path format.
Dropbox/Cloud Sync Setup (Power User Pattern)
For multi-machine memory that follows you everywhere, point to a synced directory. This is how the project author personally runs their system:
{
"mcpServers": {
"Aim-Memory-Bank": {
"command": "npx",
"args": [
"-y",
"mcp-knowledge-graph",
"--memory-path",
"/Users/yourusername/Dropbox/ai-memory"
]
}
}
}
Your memories now synchronize across every device where you run Dropbox. Start a conversation on your work MacBook, continue seamlessly on your Linux workstation at home. The knowledge graph doesn't care where you are—it just remembers.
Project-Local Memory Setup
For project-specific context that shouldn't leak into your global memory, navigate to any project root and create the magic directory:
cd ~/projects/my-awesome-api
mkdir .aim
That's it. No configuration file edits. The .aim directory name is hard-coded into the detection logic—deviate from it and the system won't recognize your project. From this directory, all memory operations automatically target .aim/memory.jsonl instead of your global store.
Auto-Approve Read Operations (Strongly Recommended)
Memory retrieval should be frictionless. Add this configuration to eliminate approval prompts for safe read operations:
{
"mcpServers": {
"Aim-Memory-Bank": {
"command": "npx",
"args": [
"-y",
"mcp-knowledge-graph",
"--memory-path",
"/Users/yourusername/.aim"
],
"autoapprove": [
"aim_memory_search",
"aim_memory_get",
"aim_memory_read_all",
"aim_memory_list_stores"
]
}
}
}
This lets your AI recall information instantly while still requiring explicit approval for destructive operations like aim_memory_forget.
REAL Code Examples: Memory in Action
Let's examine actual patterns from the repository, with detailed explanations of what's happening under the hood.
Example 1: Storing Your First Memory (Master Database)
This is the foundational pattern—storing an entity with observations into the default master database:
// Master Database (default - no context needed)
aim_memory_store({
entities: [{
name: "John_Doe",
entityType: "person",
observations: ["Met at conference"]
}]
})
What's happening here? The aim_memory_store tool receives an array of entity objects. Each entity requires three fields: name (the unique identifier, using snake_case by convention), entityType (categorization for future filtering), and observations (an array of factual strings). Notice the absence of a context parameter—this automatically routes to your master database. The system will create memory.jsonl if it doesn't exist, prepend the safety marker, and append your entity as a new JSON line. Next session, Claude can aim_memory_search for "John" and retrieve this complete record.
Example 2: Context-Specific Databases
When your life has distinct domains, named databases prevent chaos:
// Work database
aim_memory_store({
context: "work",
entities: [{
name: "Q4_Project",
entityType: "project",
observations: ["Due December 2024"]
}]
})
// Personal database
aim_memory_store({
context: "personal",
entities: [{
name: "Mom",
entityType: "person",
observations: ["Birthday March 15th"]
}]
})
The power move here: The context parameter transforms memory.jsonl into memory-work.jsonl and memory-personal.jsonl respectively. Your work stress doesn't contaminate your personal relationships. Your AI assistant becomes context-aware without you explicitly managing state. When you later ask Claude "what's urgent at work?" from your personal laptop, it queries the correct database automatically if you've configured location appropriately.
Example 3: Forcing Storage Location
Sometimes auto-detection guesses wrong, or you explicitly need cross-location operations:
// Master database in specific location
aim_memory_store({
location: "global",
entities: [{
name: "Important_Info",
entityType: "reference",
observations: ["Stored in global master database"]
}]
})
Why force location? Imagine you're in a project with .aim directory, but this particular entity belongs in your global knowledge base—perhaps a password reset procedure or your AWS↗ Bright Coding Blog account structure. The location: "global" override ensures it lands where you can find it from any project. The inverse (location: "project") works when you're operating from outside a project directory but need to inject context into a specific codebase's memory.
Example 4: Database Discovery and Inspection
Understanding your memory landscape prevents the "where did I put that?" panic:
{
"project_databases": [
"default", // Master Database (project-local)
"project-work" // Named database
],
"global_databases": [
"default", // Master Database (global)
"work",
"personal",
"health"
],
"current_location": "project (.aim directory detected)"
}
This is the output of aim_memory_list_stores. Key insight: "default" appears in both lists, but they're distinct physical files. The project-local default is my-project/.aim/memory.jsonl while the global default is ~/.aim/memory.jsonl. The current_location field tells you which context you're operating in right now—crucial for predicting where new memories will land.
Example 5: File Organization Deep Dive
The repository documents the complete file structure you'll encounter:
/Users/yourusername/.aim/
├── memory.jsonl # Master Database (default)
├── memory-work.jsonl # Work database
├── memory-personal.jsonl # Personal database
└── memory-health.jsonl # Health database
And for project-local:
my-project/
├── .aim/
│ ├── memory.jsonl # Project Master Database (default)
│ └── memory-work.jsonl # Project Work database
└── src/
The naming convention is mechanical and predictable: memory-{context}.jsonl for named databases, memory.jsonl for the master. This predictability lets you script against these files, back them up selectively, or even grep for emergency recovery when your AI isn't available.
Advanced Usage & Best Practices
Entity Naming Conventions: Use snake_case consistently. John_Doe not John Doe. Q4_Project not q4 project. Spaces and special characters in entity names will haunt you during retrieval. The knowledge graph is only as queryable as your naming discipline allows.
Observation Granularity: Store atomic facts, not essays. ["Met at ReactConf 2024", "Works at Vercel", "Interested in edge functions"] beats ["Met John at ReactConf, he works at Vercel and likes edge functions"] because it enables precise fact retrieval and individual fact deletion without rewriting everything.
Strategic Context Separation: Resist the temptation to create dozens of contexts. The master database handles 80% of needs. Reserve named databases for genuinely distinct life domains that should never intersect. Every new context adds cognitive overhead to your retrieval strategy.
Regular Memory Hygiene: Use aim_memory_forget and aim_memory_remove_facts aggressively. Stale observations poison your AI's reasoning. That "planning to use Vue 3" observation from 2022? It's actively harmful if your team migrated to Svelte. Treat your knowledge graph as a living document requiring curation.
Version Control Your .aim Directories: For team projects, commit .aim to git (add !.aim/ to your .gitignore negation patterns). Your project's institutional knowledge becomes as versioned as your code. Roll back bad architectural decisions in both your codebase and your AI's understanding simultaneously.
Comparison with Alternatives
| Feature | MCP Knowledge Graph | Vector Databases (Pinecone/Weaviate) | Simple File Pasting | Claude's Built-in Memory |
|---|---|---|---|---|
| Setup Complexity | Minimal (npx install) | High (API keys, indexing, embeddings) | None | None |
| Privacy | 100% local | Cloud-dependent | Local | Cloud (Anthropic servers) |
| Cross-Session Persistence | Native | Native | Manual paste required | Limited/None |
| Structured Relations | Native (entity-relation-observation) | Approximate (vector similarity) | None | None |
| Cost | Free | Usage-based, often expensive | Free | Included in subscription |
| Claude Integration | Native MCP protocol | Requires custom client | Manual | N/A |
| Multi-Database Support | Built-in | Manual index management | File organization hack | None |
| Query Precision | Exact name + keyword search | Semantic similarity | Ctrl+F | None |
| Team Sharability | Git-friendly .aim directories |
Complex access controls | Email/Slack paste | Individual only |
The verdict: Vector databases offer semantic retrieval at scale but introduce operational complexity that kills developer velocity. File pasting is free but requires constant manual intervention. Claude's native memory is improving but remains opaque and limited. MCP Knowledge Graph hits the sweet spot: structured enough for precision, simple enough for immediate adoption, local enough for sensitive domains, and native enough to feel invisible.
FAQ: Your Burning Questions Answered
Does this work with GPT-4 or other AI models?
MCP Knowledge Graph implements the Model Context Protocol, which is gaining traction beyond Anthropic's ecosystem. While designed for Claude Code/Desktop, any MCP-compatible platform can connect. Check your specific client's MCP support—OpenAI doesn't natively speak MCP yet, but community bridges exist.
Can I migrate memories between machines?
Absolutely. Your memory files are plain JSONL. Copy your .aim directory, rsync it, Dropbox it, git-clone it. The safety markers travel with the data. For seamless multi-machine workflows, the Dropbox sync configuration shown in setup is battle-tested by the project author.
What happens if I delete a memory file?
Those memories are gone permanently—there's no cloud backup. This is a feature, not a bug, for privacy-conscious users. Implement your own backup strategy: Time Machine, rclone to S3, or simple cp -r ~/.aim ~/.aim.backup.$(date +%Y%m%d).
How large can my knowledge graph grow?
JSONL files append indefinitely, but search performance degrades linearly with file size. For massive graphs (10k+ entities), consider periodic archival or splitting into more granular contexts. The file-based approach prioritizes simplicity over web-scale performance.
Can multiple AI sessions write simultaneously?
File-based storage means last-write-wins without concurrency controls. For single-user workflows this is rarely problematic. For true multi-user scenarios, you'd need to add file locking or migrate to a database-backed implementation.
Why the confusing .aim vs _aim naming?
Valid frustration! .aim (with dot) is the directory name for project detection. _aim (with underscore) is the file safety marker inside JSONL files. The similarity is intentional branding—both signal "AI Memory"—but they operate at entirely different layers. Remember: directory starts with dot, marker starts with underscore.
Is this production-ready for my startup?
The fork focuses on local development workflows. For production systems requiring high availability, consider it a prototyping and personal productivity tool. The MIT license lets you extend it, but evaluate your reliability requirements against the file-based architecture.
Conclusion: Your AI Deserves a Better Memory
We've normalized a bizarre reality: our AI assistants can generate elegant code, debug complex systems, and explain arcane algorithms, yet they forget our name between sessions. MCP Knowledge Graph exposes this amnesia as a solvable engineering problem, not an inherent limitation of the technology.
The implementation is almost aggressively simple—local JSONL files, a handful of MCP tools, clever project detection. But simplicity that solves real problems is the hallmark of great developer tools. You don't need a vector database PhD. You don't need cloud infrastructure. You need five minutes of configuration and the willingness to treat your AI's memory as seriously as your own codebase.
I've integrated MCP Knowledge Graph into my daily workflow for the past month. The difference is transformative. Claude now greets my projects with genuine familiarity—recalling architectural decisions, connecting prior research, building cumulative understanding rather than repeating groundhog-day introductions. My .aim directories are among my most valued project assets, right alongside package.json and README.md.
Stop accepting AI amnesia as inevitable. Give your models the memory they deserve. Fork the repo, create your first .aim directory, and experience what persistent context feels like. Your future self—the one debugging at 2 AM with an AI that actually remembers why you chose that weird caching strategy—will thank you.
Star the repository, open your first issue, and join the growing community of developers who refuse to start from zero every single session.