
Memory Engineering
STDIOPersistent memory and semantic code understanding for AI assistants using MongoDB and Voyage AI
Persistent memory and semantic code understanding for AI assistants using MongoDB and Voyage AI
Persistent memory and semantic code understanding for AI assistants. Built on MongoDB Atlas Vector Search and Voyage AI embeddings.
voyage-code-3 is Voyage AI's specialized model that understands code like a senior developer:
UserService.create()
and User.create()
- knows one is a service method, the other is a model methodasync def
, JavaScript's async function
, and Go's go func()
all represent asynchronous patternshash_password()
relates to verify_password()
, salt
, bcrypt
, and security patterns// Ask: "How do we handle authentication?" // voyage-code-3 finds ALL of these (even without the word "auth"): validateToken() // JWT validation checkSession() // Session management requirePermission() // Authorization refreshTokens() // Token refresh logic loginUser() // Login flow // Traditional search would miss most of these!
This is what makes Memory Engineering different from everything else:
// Traditional chunking BREAKS this function in half: function processPayment(order) { // <- Chunk 1 ends here validateOrder(order); // <- Chunk 2 starts here, loses context! // ... 50 more lines } // Our chunking keeps it COMPLETE: function processPayment(order) { // <- Full function preserved validateOrder(order); // ... entire function included } // <- Chunk ends at semantic boundary
# Find similar implementations search --query "JWT refresh" --codeSearch "similar" # Find who implements an interface search --query "AuthProvider" --codeSearch "implements" # Find usage patterns search --query "error handling" --codeSearch "pattern" # Natural language → Code search --query "how do we validate users" # Automatically searches: authenticate, verify, check, validate patterns
Inspired by Cline, but enhanced with MongoDB persistence:
class Auth
and authenticate()
semantically// voyage-code-3 understands these are related: authenticate() → JWT.verify() → checkPermissions() → isAuthorized() // Even without shared keywords, it knows: "user login" → findByEmail() → bcrypt.compare() → generateToken() // Understands code patterns: try/catch → error handling → .catch() → Promise.reject()
auth
automatically searches for authentication, JWT, tokens, sessions// What gets captured in each chunk: interface CodeChunk { chunk: { type: 'function' | 'class' | 'method' | 'module'; signature: string; // Full signature with params content: string; // Complete code context: string; // Imports and dependencies startLine: number; endLine: number; }; contentVector: number[]; // 1024-dim embedding metadata: { patterns: string[]; // Detected patterns dependencies: string[]; // What it imports exports: string[]; // What it exports }; }
npm install -g memory-engineering-mcp
{ "mcpServers": { "memory-engineering-mcp": { "command": "npx", "args": ["memory-engineering-mcp"], "env": { "MONGODB_URI": "your-mongodb-atlas-uri", "VOYAGE_API_KEY": "your-voyage-api-key" } } } }
# Initialize (scans entire codebase, generates embeddings) memory_engineering_init # Now search your code semantically! memory_engineering_search --query "authentication flow" --codeSearch "pattern" # Update memories as you work memory_engineering_memory --name activeContext --content "Fixed JWT expiry..."
Aspect | voyage-code-3 | General Models (text-embedding-3) |
---|---|---|
Code Syntax | Understands AST-like structures | Treats code as text |
Variable Names | Knows userId ≈ user_id ≈ userID | Sees as different tokens |
Design Patterns | Recognizes Singleton, Factory, Repository | No pattern awareness |
Error Handling | Links try/catch ↔ .catch() ↔ error boundaries | Misses connections |
Import Relationships | Tracks dependency graphs | Ignores imports |
Context Window | 32K tokens (full files) | 8K tokens typical |
// Query: "user authentication" // voyage-code-3 finds (relevance score): verifyPassword() // 0.94 - Understands auth concept generateJWT() // 0.92 - Knows JWT = auth token checkPermissions() // 0.89 - Links to authorization validateSession() // 0.87 - Session = auth state // Generic model finds: authenticateUser() // 0.95 - Only exact match userAuth() // 0.88 - Keyword matching // Misses everything else!
search --query "payment processing" # voyage-code-3 finds: processPayment(), handleStripeWebhook(), validateCard() # Even without the word "payment" in those functions!
search --query "error" --codeSearch "pattern" # Returns ALL error handling patterns: # - try/catch blocks # - .catch() handlers # - error middleware # - validation errors
search --query "why Redis" # Finds the exact activeContext entry where you decided to use Redis # "Chose Redis for session storage because: 1) Fast lookups 2) TTL support..."
// voyage-code-3 understands these are the SAME pattern: // JavaScript promise.then(result => {}).catch(err => {}) // Python try: result = await async_func() except Exception as err: handle_error(err) // Go if err := doSomething(); err != nil { return err } // All recognized as: error-handling pattern
search --query "duplicate logic" --codeSearch "similar" # Finds semantically similar code blocks that could be refactored
search --query "null pointer exception possible" --codeSearch "pattern" # Finds: optional chaining missing, unchecked nulls, unsafe access
search --query "entry point main initialization" --codeSearch "implements" # Finds: main(), app.listen(), server.start(), bootstrap()
search --query "SQL injection vulnerable" --codeSearch "pattern" # Finds: string concatenation in queries, unparameterized SQL
The system understands natural language variations:
Only changed files are re-embedded:
// Detects changes via: - File modification time - Content hash comparison - Git diff integration - Automatic after 24h gap
Every code chunk maintains context:
// Original file: import { User } from './models'; import bcrypt from 'bcrypt'; class AuthService { async validateUser(email: string, password: string) { // ... implementation } } // Chunk includes: - Imports (User, bcrypt) - Class context (AuthService) - Full method implementation - Patterns detected: ["authentication", "async", "validation"]
Tool | Purpose | Key Features |
---|---|---|
memory_engineering_init | Initialize project | Scans code, creates memories, generates embeddings |
memory_engineering_memory | Read/Update memories | Unified interface for all 7 memories |
memory_engineering_search | Semantic search | Memory + code search with patterns |
memory_engineering_sync | Sync code embeddings | Smart chunking, incremental updates |
memory_engineering_system | Health & diagnostics | Status, environment, doctor mode |
MIT - See LICENSE file
Built with Model Context Protocol (MCP) by Anthropic