AI Memory (mcp-ai-memory)

MCP数据服务

提供方 scanadi

数据服务 未标注 无需鉴权 社区 / 第三方

Enables AI agents to store, retrieve, and manage contextual knowledge across sessions using semantic search with PostgreSQL and vector embeddings. Supports memory relationships, clustering, multi-agent isolation, and intelligent caching for persistent conversational context.

一句话选型结论

按资料字段整理

AI Memory (mcp-ai-memory) 属于数据服务类 MCP 服务器,传输方式未标注,无需鉴权,没有现成安装命令,需按官方文档接入。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类数据服务 传输方式未标注 鉴权无需鉴权 部署方式未标注
GitHub 星标 未标注 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

数据服务
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

安装与配置

未标注 无需鉴权
上游未给出传输方式
  1. 1
    准备运行环境

    按官方文档确认运行环境(常见为 Node.js 或 Python),装好后再执行安装命令。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
数据库查询

用自然语言查库、取数,不用手写 SQL。

数据同步与清洗

把多来源数据拉到一处做整理。

报表取数

按口径快速拉出统计结果。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 资料标注无需鉴权,装好就能连。

先想清楚的地方

  • 没有现成安装命令,需要按官方文档自己填启动命令和参数。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在数据服务场景里让模型直接调用外部能力的人。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
AI Memory (mcp-ai-memory)当前 未标注 未标注 未标注 无 2026-05-17
Memory 9d25f64e 9 未标注 未标注 无 2026-05-17
Getzep MCP 9 stdio · 本地进程 本地部署 有 2026-05-17
anything-llm 未标注 stdio · 本地进程 本地部署 有 2026-04-11
Prisma MCP Server 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Astr Bot 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

数据服务
字段来自项目仓库与公开索引,中文说明由本站标注
提供方scanadi上游标注的维护方 scanadi
分类数据服务本站按上游分类展示
连接方式未标注上游未给出传输方式
鉴权方式无需鉴权远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · 未标注本地安装时用到的包标识与运行时
部署类型未标注上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

11.5 KB
来自项目仓库与上游目录的原文,未做删改

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)```bash

npm install -g mcp-ai-memory


### From Source

1. Install dependencies:```bash
bun install
  1. Set up PostgreSQL with pgvector:```sql
    CREATE DATABASE mcp_ai_memory;
    \c mcp_ai_memory
    CREATE EXTENSION IF NOT EXISTS vector;

3. Create environment file:```bash
# Create .env with your database credentials
touch .env
  1. Run migrations:```bash
    bun run migrate

## Usage

### Development```bash
bun run dev

Production```bash

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:

  1. Option 1: Reset and Re-embed (Recommended for new installations)bash # Clear existing memories and start fresh psql -d your_database -c "TRUNCATE TABLE memories CASCADE;"

  2. Option 2: Specify a Consistent Model
    Add EMBEDDING_MODEL to your Claude Desktop config:json { "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)

  3. Option 3: Run Migration for Flexible Dimensions
    If you're using the source version:bash bun run migrate
    This allows mixing different embedding dimensions in the same database.

Database Connection Issues

Ensure your PostgreSQL has the pgvector extension:```sql
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):```json
{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "mcp-ai-memory"],
      "env": {
        "DATABASE_URL": "postgresql://username:password@localhost:5432/memory_db"
      }
    }
  }
}

With Optional Redis Cache```json

{
"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 duplicates
- `memory_update` - UPDATE MODIFY EDIT - Update existing memory metadata
- `memory_delete` - DELETE REMOVE FORGET - Delete specific memories

### Advanced Operations
- `memory_batch` - BATCH BULK IMPORT - Store multiple memories efficiently
- `memory_batch_delete` - Delete multiple memories at once
- `memory_graph_search` - GRAPH RELATED - Search with relationship traversal (alias for memory_traverse)
- `memory_consolidate` - MERGE CLUSTER - Group similar memories
- `memory_stats` - STATS INFO - Database statistics
- `memory_relate` - LINK CONNECT - Create memory relationships
- `memory_unrelate` - UNLINK DISCONNECT - Remove relationships
- `memory_get_relations` - Show all relationships for a memory

### Graph & Decay Operations (New)
- `memory_traverse` - TRAVERSE EXPLORE - Traverse memory graph with BFS/DFS algorithms
- `memory_graph_analysis` - ANALYZE CONNECTIONS - Analyze graph connectivity and relationship patterns
- `memory_decay_status` - DECAY STATUS - Check decay status of a memory
- `memory_preserve` - PRESERVE PROTECT - Preserve important memories from decay

## Resources

- `memory://stats` - Database statistics
- `memory://types` - Available memory types
- `memory://tags` - All unique tags
- `memory://relationships` - Memory relationships
- `memory://clusters` - Memory clusters

## Prompts

- `load-context` - Load relevant context for a task
- `memory-summary` - Generate topic summaries
- `conversation-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```bash

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:

1. **Redis Cache** (if available) - Distributed, persistent caching
2. **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```bash
# 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```bash

bun run typecheck


### Linting```bash
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:

  1. Include the System Prompt: Copy the content from SYSTEM_PROMPT.md and include it in your initial conversation or system prompt
  2. Key Behaviors to Reinforce:
    - Always use memory_search FIRST before any operation
    - Use memory_list as 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

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

常见问题

5 问
答案由本站依据条目字段整理,不引用上游原文
AI Memory (mcp-ai-memory) 怎么安装?

资料没有给出安装命令,请到官方仓库或文档按说明接入;这类条目多数是生态应用,或尚未发布可安装包。

AI Memory (mcp-ai-memory) 怎么在客户端里配置?

它的传输方式未标注,在客户端 MCP 配置里按官方文档填写启动命令和参数,保存后重启客户端生效。

AI Memory (mcp-ai-memory) 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

AI Memory (mcp-ai-memory) 需要 API Key 吗?

资料标注为无需认证,装好就能连;如果实际调用时报鉴权错误,按官方文档补上凭据。

AI Memory (mcp-ai-memory) 能提供哪些能力?

资料显示能力标签包括 数据分析、API集成、知识管理。具体工具清单以官方文档为准。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。