LangChain-powered Universal Memory System for AI Assistants
Advanced memory orchestration with optional LangGraph workflows.
A modern memory system built on LangChain with ChromaDB, designed to work seamlessly with AI assistants like Cursor. Features sophisticated memory management, RAG capabilities, and optional advanced workflows with LangGraph.
- ๐ LangChain-Powered: Built on LangChain for seamless integration
- ๐ง Vector Memory: ChromaDB-based semantic memory with embeddings
- ๐ค Flexible Embeddings: Choose from multiple embedding models:
- Qwen3-Embedding-0.6B (lightweight, M3 optimized)
- E5-Large (high quality, multilingual)
- OpenAI (if API key available)
- โ๏ธ Memory Chains: Pre-built LangChain chains for memory-enhanced conversations
- ๐ ๏ธ LangChain Tools: Memory tools for agents and complex workflows
- ๐ LangGraph Support: Optional advanced workflows for complex scenarios
- ๐ฏ RAG Capabilities: Retrieval-Augmented Generation with memory
- ๐ท๏ธ Rich Metadata: Type-safe memory with tags, scopes, and priorities
- ๐ MCP Compatible: Full Model Context Protocol integration for Cursor
- ๐ Cross-Project Context Storage: Build knowledge graphs across multiple projects
- ๐ก๏ธ Minimal Guardrails for Vibe Coding: Prevent duplicate implementations and maintain consistency
- ๐ค Auto-Tracking: Automatically tracks Git activities, code changes, and chat sessions
- ๐ Code Intelligence: Analyze patterns, find duplicates, check quality across projects
# Create conda environment
conda create -n mnemo python=3.11 -y
conda activate mnemo
# Basic installation
pip install -e .
# With optional dependencies
pip install -e ".[graph]" # For LangGraph workflows
pip install -e ".[all]" # Everything included
# For MCP support with Cursor
pip install -e ".[mcp]"
from mnemo.memory.store import MnemoVectorStore
from mnemo.memory.client import MnemoMemoryClient
# Create memory system
vector_store = MnemoVectorStore(
collection_name="my_memories",
persist_directory="./memory_db"
)
client = MnemoMemoryClient(vector_store)
# Set context
client.set_context(workspace_path="/my/project")
# Remember something
memory_id = client.remember_fact(
key="project_goal",
fact="Build an awesome AI assistant with LangChain",
tags={"project", "goals", "langchain"}
)
# Search memories (semantic search with embeddings)
results = client.search("AI assistant", limit=5)
print(f"Found {len(results)} related memories")
# Recall most relevant
content = client.recall("What is the project goal?")
print(f"Goal: {content}")
# Remember a fact
mnemo remember "project_structure" "LangChain app with FastAPI backend" --memory-type "fact" --tags "architecture,langchain"
# Search memories (semantic search)
mnemo search "LangChain" --memory-types "fact,skill" --limit 5
# Store code patterns
mnemo code-pattern "fastapi_basic" "from fastapi import FastAPI; app = FastAPI()" "python" "Basic FastAPI setup"
# Get workspace context
mnemo workspace-context "/my/project"
# Get statistics
mnemo stats
- Facts: Static information and knowledge
- Skills: Learned patterns and techniques
- Preferences: User preferences and settings
- Conversations: Chat history and context
- Context: Contextual information
- Code Patterns: Reusable code snippets and templates
- Workspace: Workspace-specific data
- Project: Project-specific information
- Global: Available everywhere
- Workspace: Available in current workspace
- Project: Available in current project
- Session: Available in current session
- Temporary: Auto-expires
Mnemo supports multiple embedding models for different use cases:
- Qwen3-Embedding-0.6B โญ: Best for M3/M2 Macs, lightweight (2GB), 100+ languages
- intfloat/multilingual-e5-large: High quality, 1024 dims, 3GB memory
- paraphrase-multilingual-mpnet-base-v2: Balanced performance, 768 dims
# Use Qwen3 (default, lightweight)
from mnemo.core.embeddings import MnemoEmbeddings
embeddings = MnemoEmbeddings() # Uses Qwen3-0.6B by default
# Use E5-Large (higher quality)
embeddings = MnemoEmbeddings(
sentence_transformer_model="intfloat/multilingual-e5-large"
)
# Use OpenAI (requires API key)
embeddings = MnemoEmbeddings(
use_mock=False, # Force OpenAI if available
openai_api_key="your-key"
)
- Start the MCP server:
# Streamable mode with SSE support (RECOMMENDED)
python -m mnemo.mcp.cli serve-streamable --port 3334
# Legacy FastAPI mode (no SSE support)
python -m mnemo.mcp.cli serve-fastapi --port 3333
๐ก SSE Support: The streamable server supports both SSE and JSON modes automatically based on client preferences. If you encounter "Not SSE format" errors in corporate environments, see SSE Troubleshooting Guide.
- Add to
.cursor/mcp.json
:
{
"mcpServers": {
"mnemo": {
"url": "http://localhost:3334/mcp",
"env": {
"MNEMO_AUTO_TRACKING": "true",
"MNEMO_TRACKING_INTERVAL": "300",
"MNEMO_SESSION_TRACKING": "true"
}
}
}
}
- Restart Cursor and start using mnemo!
After installation, these tools are available in Cursor:
- remember: Store information with semantic memory
- recall: Retrieve the most relevant memory
- search: Search through all memories
- forget: Delete specific memories
- remember_code_pattern: Store reusable code patterns
- session_status: View current session tracking status
- analyze_project: Build knowledge graph of any project
- Supports Python, Kotlin, JavaScript, TypeScript
- Depth levels:
basic
,deep
,complete
(default: complete) - Example:
analyze_project("/path/to/project", "project-name", "python")
- find_pattern: Find similar code patterns across projects
- Uses semantic search to find related patterns
- Example:
find_pattern("authentication", "project-name")
- compare_projects: Compare coding patterns between projects
- Finds common patterns and differences
- Example:
compare_projects("project1", "project2")
- check_guardrails: Analyze code quality and detect issues
- Returns health score (0-100) with percentage-based metrics
- Checks: duplicates, unused code, complexity, consistency
- Example:
check_guardrails("project-name")
Mnemo automatically tracks and remembers:
- Git commits: New commits are automatically saved
- Code changes: Significant code modifications are tracked
- Branch switches: Branch changes are recorded
- File status: Working directory changes are monitored
Mnemo also tracks your chat sessions:
- Important messages: Messages with keywords like 'implement', 'fix', 'todo' are highlighted
- Session summaries: Automatically saves conversation summaries every 20 messages
- Tool usage: Tracks when and how you use mnemo tools
Configuration:
MNEMO_AUTO_TRACKING
: Enable/disable project tracking (default: "true")MNEMO_TRACKING_INTERVAL
: Tracking interval in seconds (default: 300)MNEMO_SESSION_TRACKING
: Enable/disable session tracking (default: "true")
๐ Detailed guides for beginners:
- ํ๊ตญ์ด ๊ฐ์ด๋ - Cursor ์ด๋ณด์๋ฅผ ์ํ ์๋ฒฝ ๊ฐ์ด๋
- English Guide - Complete guide for Cursor beginners
When AI assistants like Cursor work on multiple projects, they often "vibe code" - creating duplicate implementations, using different libraries for the same features, or ignoring existing patterns. Mnemo solves this with knowledge graphs that capture and reuse patterns across all your projects.
Mnemo's Code Guardrails analyze your project and provide a health score based on percentage metrics:
- ๐ 85-100: Excellent code quality
- ๐ 70-84: Good, minor improvements needed
- ๐ค 50-69: Fair, room for improvement
โ ๏ธ 30-49: Warning, several issues need attention- ๐ฑ 0-29: Critical, major refactoring needed
1. Duplicate Implementations (์ค๋ณต ๊ตฌํ)
- Finds functions with same names in different modules
- Example:
"You already have CustomError in errors.py!"
- Penalty based on duplicate rate (% of total functions)
2. Unused Functions (๋ฏธ์ฌ์ฉ ํจ์)
- Detects dead code that's never called
- Helps maintain a clean, efficient codebase
- Penalty based on unused rate (% of total functions)
3. Complexity Hotspots (๋ณต์ก๋ ํซ์คํ)
- Identifies overly complex files and functions
- Highlights areas that need refactoring
- Progressive penalty for high complexity
4. Consistency Issues (์ผ๊ด์ฑ ๋ฌธ์ )
- Detects style drift and pattern violations
- Example:
"Keep using snake_case like the rest of the codebase"
- Checks module size consistency
5. Potential Risks (์ ์ฌ์ ์ํ)
- Security issues and dangerous patterns
- High penalty (10 points each) for critical risks
6. DSL Pattern Analysis (Kotlin)
- Tracks underused DSL patterns
- Helps identify experimental or abandoned features
# Check project health
mcp check-guardrails <project-name>
# Example output:
# Health Score: 97/100 ๐ Excellent!
# - Duplicate rate: 2.1%
# - Unused rate: 5.2%
# - Issue density: 0.9
Real-world Results:
- Spice Framework (Kotlin): 97/100 ๐ (2.1% duplicates, 5.2% unused)
- Mnemo (Python): 75/100 ๐ (37.7% duplicates, 47.2% unused)
Build a searchable graph of your codebase:
# Start Neo4j
docker-compose -f docker-compose/docker-compose.yml up -d
# Analyze a Python project (Complete Analysis)
from mnemo.graph.complete_python_analyzer import CompletePythonAnalyzer
analyzer = CompletePythonAnalyzer()
results = analyzer.analyze_complete("./my-project", "my-project-name", ["all"])
# Analyze a Kotlin project
from mnemo.graph.complete_kotlin_analyzer import CompleteKotlinAnalyzer
analyzer = CompleteKotlinAnalyzer()
results = analyzer.analyze_complete("./kotlin-project", "project-name", ["all"])
# Check code health
from mnemo.graph.code_guardrails import CodeGuardrails
guardrails = CodeGuardrails()
health = guardrails.analyze_project_health("my-project-name")
print(f"Health Score: {health['health_score']}/100")
Currently supported:
- Python (.py) - Full AST analysis, function calls, imports
- Kotlin (.kt) - Classes, functions, Gradle modules
- JavaScript/TypeScript (.js/.ts/.jsx/.tsx) - ES6/CommonJS, Vue/React components
- More coming soon: Java, Go, Rust, C++
# Analyze multiple projects
from mnemo.graph.project_context_manager import ProjectContextManager
manager = ProjectContextManager()
# Analyze your Spring Boot backend
manager.analyze_project("/path/to/spring-app", "spring-app", "java")
# Analyze your React frontend
manager.analyze_project("/path/to/react-app", "react-app", "javascript")
# Later, when working on a new FastAPI project:
# "Create REST endpoints like my Spring Boot project"
patterns = manager.get_pattern_from_project("spring-app", "RestController")
# โ AI references actual Spring patterns and adapts them to FastAPI!
- Pattern Reuse: "Use the same auth pattern as project X"
- Consistency: Maintain coding standards across projects
- Knowledge Transfer: Learn from your best implementations
- No More Vibe Coding: AI understands your actual code, not just vibes
All code intelligence features are exposed as MCP tools:
# In Cursor, you can directly call:
# - analyze_project(project_path, project_name, language)
# - find_pattern(pattern, project)
# - compare_projects(project1, project2)
# - check_guardrails(project, checks)
No need for manual scripts - Cursor can use these tools automatically!
- Function/Method calls - Who calls whom
- Class hierarchies - Inheritance and interfaces
- Dependencies - What imports what
- Patterns - Common architectural patterns
- Cross-references - How projects relate
โโโโโโโโโโโโโโโโโโโ
โ LangChain Tools โ โ Agents & workflows
โ Memory Chains โ
โโโโโโโโโโโโโโโโโโโค
โ Memory Client โ โ High-level API
โโโโโโโโโโโโโโโโโโโค
โ Vector Store โ โ LangChain integration
โ (ChromaDB) โ
โโโโโโโโโโโโโโโโโโโค
โ Embeddings โ โ Semantic search
โ (OpenAI/Custom) โ
โโโโโโโโโโโโโโโโโโโ
Optional:
โโโโโโโโโโโโโโโโโโโ
โ LangGraph โ โ Advanced workflows
โ Workflows โ
โโโโโโโโโโโโโโโโโโโ
from langchain_openai import ChatOpenAI
from mnemo.chains.memory import MemoryChain
llm = ChatOpenAI()
memory_chain = MemoryChain(llm=llm, memory_client=client)
result = memory_chain({"query": "How do I use LangChain?"})
print(result["response"]) # Enhanced with relevant memories
from mnemo.chains.rag import MemoryRAGChain
rag_chain = MemoryRAGChain(llm=llm, memory_client=client)
result = rag_chain({"question": "Show me FastAPI examples"})
from langchain.agents import initialize_agent, AgentType
from mnemo.tools.memory import MemorySearchTool, MemoryStoreTool
tools = [
MemorySearchTool(memory_client=client),
MemoryStoreTool(memory_client=client)
]
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION)
response = agent.run("Search for Python examples and store any new patterns you find")
from mnemo.graph.memory_graph import MemoryWorkflowGraph
workflow = MemoryWorkflowGraph(llm=llm, memory_client=client)
result = workflow.run(
query="Help me understand LangChain",
should_learn=True # Learn from this conversation
)
mnemo/
โโโ core/ # Core types and utilities
โ โโโ types.py # Memory types and models
โ โโโ embeddings.py # Custom embeddings
โโโ memory/ # Memory system
โ โโโ store.py # Vector store wrapper
โ โโโ client.py # High-level client
โโโ chains/ # LangChain chains
โ โโโ memory.py # Memory-enhanced chains
โ โโโ rag.py # RAG implementations
โโโ tools/ # LangChain tools
โ โโโ memory.py # Memory tools for agents
โโโ graph/ # LangGraph workflows (optional)
โ โโโ memory_graph.py
โโโ cli.py # Command line interface
โโโ examples/ # Usage examples
Check out the examples/
directory for detailed usage examples:
basic_langchain.py
: Basic LangChain-based memory operationslangchain_chains.py
: Memory chains and RAG exampleslangchain_tools.py
: Tools and agents with memorylanggraph_workflow.py
: Advanced LangGraph workflows (optional)
- MCP server implementation
- Cursor memory assistance integration
- Real-time memory sync
- Context injection for Cursor
- Auto-tracking (Git, code changes, sessions)
- Code intelligence tools via MCP
- ChromaDB (Current)
- Qdrant integration
- Pinecone support
- Weaviate adapter
- Abstract vector store interface
- RDF/SPARQL support
- Neo4j integration
- Graph-based memory relationships
- Code knowledge graphs
- Cross-project pattern analysis
- Vibe coding guardrails
- Hybrid vector + graph search
- Multi-modal memories (images, audio)
- Distributed memory sync
- Memory compression & optimization
- Fine-tuned embeddings for specific domains
- Python 3.11+
- ChromaDB (default vector store)
- OpenAI API key (optional, for embeddings)
# Run tests
pytest
# Run with coverage
pytest --cov=mnemo
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Apache License 2.0 - see LICENSE file for details.
Built with โค๏ธ for the AI assistant community