Mcp Ai Memory MCP Server
A production-ready Model Context Protocol (MCP) server for semantic memory management
Mcp Ai Memory scores 35 (Limited), licensed MIT and written in TypeScript. It installs as a local process. It declares 17 tools. Filed under AI and memory. GitHub shows 50 stars. Package registries report about 31 downloads a week. Install configs are generated for 10 clients. Being listed in the registry is not the same as being vendor-official.
Limited trust
35 of 100 from six public signals. Nobody can buy a point.
- OSI-style license: mit.
License, quality and maintenance
Quality: Grade A
90/100 for listing completeness. Lost points: short summary, no docs link.
How quality is graded
Where the 35 comes from
0 + 5 + 6 + 10 + 4 + 10 = 35. Each factor is capped, so no single signal can carry a listing.
Active in the official MCP registry, plus a known vendor namespace.
Registry: 0 of 30 points.How recently the repository saw a commit or release.
Maintenance: 5 of 20 points.GitHub stars and weekly downloads, on a log scale.
Popularity: 6 of 20 points.A clear, OSI-style open-source license.
License: 10 of 10 points.Not archived, a secure install path, a pinned version.
Security: 4 of 10 points.A real summary, a README with depth, listed tools.
Docs: 10 of 10 points.Install
Pick your client, copy the config, paste it in.
Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.
{ "mcpServers": { "scanadi-mcp-ai-memory": { "command": "npx", "args": [ "-y", "mcp-ai-memory" ] } }}
Environment variables
This server does not declare environment variables.
Tools17Tool docs quality grade D
All capabilitiesmemory_batchtoolBATCH BULK IMPORT - Store multiple memories efficiently
Delete multiple memories at once
MERGE CLUSTER - Group similar memories
DECAY STATUS - Check decay status of a memory
memory_deletetoolDELETE REMOVE FORGET - Delete specific memories
Show all relationships for a memory
ANALYZE CONNECTIONS - Analyze graph connectivity and relationship patterns
GRAPH RELATED - Search with relationship traversal (alias for memorytraverse)
memory_listtoolLIST BROWSE SHOW - List all memories chronologically (fallback when search fails, default limit: 10)
memory_preservetoolPRESERVE PROTECT - Preserve important memories from decay
memory_relatetoolLINK CONNECT - Create memory relationships
memory_searchtoolSEARCH FIND RECALL - Search stored information using natural language (USE THIS FIRST! Default limit: 10)
About
MCP AI Memory
A production-ready Model Context Protocol (MCP) server for semantic memory management that enables AI agents to store, retrieve, and manage contextual knowledge across sessions.
๐ System Prompt Available: See SYSTEM_PROMPT.md for a comprehensive guide on how to instruct AI models to use this memory system effectively. This prompt helps models understand when and how to use memory tools, especially for proactive memory retrieval.
Features
Core Capabilities
- TypeScript - Full type safety with strict mode
- PostgreSQL + pgvector - Vector similarity search with HNSW indexing
- Kysely ORM - Type-safe SQL queries
- Local Embeddings - Uses Transformers.js (no API calls)
- Intelligent Caching - Redis + in-memory fallback for blazing fast performance
- Multi-Agent Support - User context isolation
- Token Efficient - Embeddings removed from responses
Advanced Memory Management
- Graph Relationships - Rich relationship types (references, contradicts, supports, extends, causes, precedes, etc.)
- Graph Traversal - BFS/DFS algorithms with depth limits and filtering
- Memory Decay - Automatic lifecycle management with exponential decay
- Memory States - Active, dormant, archived, and expired states
- Preservation - Protect important memories from decay
- Soft Deletes - Data recovery with deleted_at timestamps
- Clustering - Automatic memory consolidation
- Compression - Automatic compression of archived memories
Prerequisites
- Node.js 18+ or Bun
- PostgreSQL with pgvector extension
- Redis (optional - falls back to in-memory cache if not available)
Installation
NPM Package (Recommended for Claude Desktop)
npm install -g mcp-ai-memory
From Source
- Install dependencies:
bun install
- Set up PostgreSQL with pgvector:
CREATE DATABASE mcp_ai_memory;
\c mcp_ai_memory
CREATE EXTENSION IF NOT EXISTS vector;
- Create environment file:
# Create .env with your database credentials
touch .env
- Run migrations:
bun run migrate
Usage
Development
bun run dev
Production
bun run build
bun run start
Troubleshooting
Embedding Dimension Mismatch Error
If you see an error like:
Failed to generate embedding: Error: Embedding dimension mismatch: Model produces 384-dimensional embeddings, but database expects 768
This occurs when the embedding model changes between sessions. To fix:
-
Option 1: Reset and Re-embed (Recommended for new installations)
# Clear existing memories and start fresh psql -d your_database -c "TRUNCATE TABLE memories CASCADE;" -
Option 2: Specify a Consistent Model Add
EMBEDDING_MODELto your Claude Desktop config:{ "mcpServers": { "memory": { "command": "npx", "args": ["-y", "mcp-ai-memory"], "env": { "MEMORY_DB_URL": "postgresql://...", "EMBEDDING_MODEL": "Xenova/all-mpnet-base-v2" } } } }Common models:
Xenova/all-mpnet-base-v2(768 dimensions - default, best quality)Xenova/all-MiniLM-L6-v2(384 dimensions - smaller/faster)
-
Option 3: Run Migration for Flexible Dimensions If you're using the source version:
bun run migrateThis allows mixing different embedding dimensions in the same database.
Database Connection Issues
Ensure your PostgreSQL has the pgvector extension:
CREATE EXTENSION IF NOT EXISTS vector;
Claude Desktop Integration
๐ก For Best Results: Include the SYSTEM_PROMPT.md content in your Claude Desktop system prompt or initial conversation to help Claude understand how to use the memory tools effectively.
Quick Setup (NPM)
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "mcp-ai-memory"],
"env": {
"DATABASE_URL": "postgresql://username:password@localhost:5432/memory_db"
}
}
}
}
With Optional Redis Cache
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "mcp-ai-memory"],
"env": {
"DATABASE_URL": "postgresql://username:password@localhost:5432/memory_db",
"REDIS_URL": "redis://localhost:6379",
"EMBEDDING_MODEL": "Xenova/all-MiniLM-L6-v2",
"LOG_LEVEL": "info"
}
}
}
}
Environment Variables
| Variable | Description | Default |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | Required |
REDIS_URL | Redis connection string (optional) | None - uses in-memory cache |
EMBEDDING_MODEL | Transformers.js model | Xenova/all-MiniLM-L6-v2 |
LOG_LEVEL | Logging level | info |
CACHE_TTL | Cache TTL in seconds | 3600 |
MAX_MEMORIES_PER_QUERY | Max results per search | 10 |
MIN_SIMILARITY_SCORE | Min similarity threshold | 0.5 |
Available Tools
๐ก Token Efficiency: Default limits are set to 10 results to optimize token usage. Increase only when needed.
Core Operations (Most Important)
memory_search- SEARCH FIND RECALL - Search stored information using natural language (USE THIS FIRST! Default limit: 10)memory_list- LIST BROWSE SHOW - List all memories chronologically (fallback when search fails, default limit: 10)memory_store- STORE SAVE REMEMBER - Store new information after checking for duplicatesmemory_update- UPDATE MODIFY EDIT - Update existing memory metadatamemory_delete- DELETE REMOVE FORGET - Delete specific memories
Advanced Operations
memory_batch- BATCH BULK IMPORT - Store multiple memories efficientlymemory_batch_delete- Delete multiple memories at oncememory_graph_search- GRAPH RELATED - Search with relationship traversal (alias for memory_traverse)memory_consolidate- MERGE CLUSTER - Group similar memoriesmemory_stats- STATS INFO - Database statisticsmemory_relate- LINK CONNECT - Create memory relationshipsmemory_unrelate- UNLINK DISCONNECT - Remove relationshipsmemory_get_relations- Show all relationships for a memory
Graph & Decay Operations (New)
memory_traverse- TRAVERSE EXPLORE - Traverse memory graph with BFS/DFS algorithmsmemory_graph_analysis- ANALYZE CONNECTIONS - Analyze graph connectivity and relationship patternsmemory_decay_status- DECAY STATUS - Check decay status of a memorymemory_preserve- PRESERVE PROTECT - Preserve important memories from decay
Resources
memory://stats- Database statisticsmemory://types- Available memory typesmemory://tags- All unique tagsmemory://relationships- Memory relationshipsmemory://clusters- Memory clusters
Prompts
load-context- Load relevant context for a taskmemory-summary- Generate topic summariesconversation-context- Load conversation history
Architecture
src/
โโโ server.ts # MCP server implementation
โโโ types/ # TypeScript definitions
โโโ schemas/ # Zod validation schemas
โโโ services/ # Business logic
โโโ database/ # Kysely migrations and client
โโโ config/ # Configuration management
Environment Variables
# Required
MEMORY_DB_URL=postgresql://user:password@localhost:5432/mcp_ai_memory
# Optional - Caching (falls back to in-memory if Redis unavailable)
REDIS_URL=redis://localhost:6379
CACHE_TTL=3600 # 1 hour default cache
EMBEDDING_CACHE_TTL=86400 # 24 hours for embeddings
SEARCH_CACHE_TTL=3600 # 1 hour for search results
MEMORY_CACHE_TTL=7200 # 2 hours for individual memories
# Optional - Model & Performance
EMBEDDING_MODEL=Xenova/all-mpnet-base-v2
LOG_LEVEL=info
MAX_CONTENT_SIZE=1048576
DEFAULT_SEARCH_LIMIT=10 # Default 10 for token efficiency
DEFAULT_SIMILARITY_THRESHOLD=0.7
# Optional - Async Processing (requires Redis)
ENABLE_ASYNC_PROCESSING=true # Enable background job processing
BULL_CONCURRENCY=3 # Worker concurrency
ENABLE_REDIS_CACHE=true # Enable Redis caching
Caching Architecture
The server implements a two-tier caching strategy:
- Redis Cache (if available) - Distributed, persistent caching
- In-Memory Cache (fallback) - Local NodeCache for when Redis is unavailable
Async Job Processing
When Redis is available and ENABLE_ASYNC_PROCESSING=true, the server uses BullMQ for background job processing:
Features
- Async Embedding Generation: Offloads CPU-intensive embedding generation to background workers
- Batch Import: Processes large memory imports without blocking the main server
- Memory Consolidation: Runs clustering and merging operations in the background
- Automatic Retries: Failed jobs are retried with exponential backoff
- Dead Letter Queue: Permanently failed jobs are tracked for manual intervention
Running Workers
# Start all workers
bun run workers
# Or start individual workers
bun run worker:embedding # Embedding generation worker
bun run worker:batch # Batch import and consolidation worker
# Test async processing
bun run test:async
Queue Monitoring
The memory_stats tool includes queue statistics when async processing is enabled:
- Active, waiting, completed, and failed job counts
- Processing rates and performance metrics
- Worker health status
Cache Invalidation
- Memory updates/deletes automatically invalidate relevant caches
- Search results are cached with query+filter combinations
- Embeddings are cached for 24 hours (configurable)
Development
Type Checking
bun run typecheck
Linting
bun run lint
Using with AI Models
System Prompt for Better Memory Usage
The memory tools include enhanced descriptions with keywords to help models understand when to use each tool. However, for best results with models like Gemma3, Qwen, or other open-source models:
- Include the System Prompt: Copy the content from SYSTEM_PROMPT.md and include it in your initial conversation or system prompt
- Key Behaviors to Reinforce:
- Always use
memory_searchFIRST before any operation - Use
memory_listas a fallback when search returns no results - Search for user information at conversation start (e.g., "user name preferences")
- Store structured JSON in the content field
- Always use
Example Initial Prompt for Models
You have access to a memory system. ALWAYS start by using memory_search with query="user name preferences personal information" to check for stored user details. If no results, use memory_list to see recent memories. Default limits are 10 results for token efficiency - only increase if needed. Follow the patterns in the system prompt for best results.
Implementation Status
โ Fully Integrated Features
- DBSCAN Clustering: Advanced clustering algorithm for memory consolidation
- Smart Compression: Automatic compression for large memories (>100KB)
- Context Window Management: Token counting and intelligent truncation
- Input Sanitization: Comprehensive validation and sanitization
- All Workers Active: Embedding, batch, and clustering workers all operational
Testing
The project includes a comprehensive test suite covering:
- Memory service operations (store, search, update, delete)
- Input validation and sanitization
- Clustering and consolidation
- Compression for large content
Run tests with bun test.
License
MIT
Frequently asked questions
What is Mcp Ai Memory MCP Server?
A production-ready Model Context Protocol (MCP) server for semantic memory management
How do I install Mcp Ai Memory MCP Server in Claude Desktop, Cursor, or VS Code?
Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. Mcp Ai Memory MCP Server runs locally from the npm package mcp-ai-memory with the command npx -y mcp-ai-memory.
Is Mcp Ai Memory MCP Server free and open source?
Yes. Mcp Ai Memory MCP Server is released under the MIT license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.
Does Mcp Ai Memory MCP Server support remote (HTTP) connections?
No remote endpoint is listed for Mcp Ai Memory MCP Server. It runs locally on your machine over stdio, started by your MCP client.
What tools does Mcp Ai Memory MCP Server provide?
Mcp Ai Memory MCP Server provides 17 tools, including memory_batch, memory_batch_delete, memory_consolidate, and memory_decay_status. See the full tool list for descriptions and parameters.
How is Mcp Ai Memory MCP Server's trust score calculated?
Mcp Ai Memory MCP Server scores 35 out of 100 (Limited). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.
Reviews
No reviews yetโBe the first to review
No published reviews yet. Used it? Tell the next person how it went.
Sign inA verified email is required to review this server.
Add badge to your README
Paste either snippet into the repository README. The image links to this listing.