Semantic + Keyword Recall
SQLite FTS5 full-text search plus lightweight vector similarity. Find memories by exact terms or conceptual meaning.
A local, self-improving memory server for AI assistants. Captures, organizes, and shares memories across all your workspaces — builds a personal knowledge graph, learns your preferences, and recommends the right tools to limit token usage.
Six core capabilities that make your assistant smarter every session.
SQLite FTS5 full-text search plus lightweight vector similarity. Find memories by exact terms or conceptual meaning.
Auto-extracts entities and relations from memories. Explore connections like a personal CodeGraph — see how concepts link across your work.
Learns style, formatting, workflow, and tool-selection preferences from explicit statements and corrections. Adapts to how you work.
Logs tool outcomes (success, tokens, duration) and ranks recommendations by historical performance. Optimizes token usage automatically.
Corrections link to memories, penalize confidence, and extract new preferences. Wrong memories fade; right ones strengthen.
Run reflect to merge duplicates, surface insights, flag low-confidence memories, and update preferences automatically.
Clone, build, and connect to your favorite MCP client in under a minute.
git clone https://github.com/jthiruveedula/agent-memory-mcp.git
cd agent-memory-mcp
npm install
npm run build
node dist/index.js
Server starts on stdio. Press Ctrl+C to stop.
The .vscode/mcp.json is pre-configured. GitHub Copilot discovers it automatically.
{
"servers": {
"agent-memory": {
"type": "stdio",
"command": "node",
"args": ["${workspaceFolder}/dist/index.js"]
}
}
}
Add to ~/Library/Application Support/Claude/settings.json (macOS) or %APPDATA%\Claude\settings.json (Windows).
{
"mcpServers": {
"agent-memory": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/agent-memory-mcp/dist/index.js"]
}
}
}
The .cursor/mcp.json is pre-configured. Restart Cursor to discover.
{
"mcpServers": {
"agent-memory": {
"command": "node",
"args": ["${workspaceFolder}/dist/index.js"]
}
}
}
The opencode.json is pre-configured. OpenCode discovers it on restart.
{
"mcpServers": {
"agent-memory": {
"command": "node",
"args": ["${workspaceFolder}/dist/index.js"]
}
}
}
Five simple steps to make your assistant smarter every session.
Store facts, preferences, code patterns, or workflow insights. The server extracts entities and learns preferences automatically.
{
"tool": "remember",
"arguments": {
"content": "I prefer flat error handling over throwing.",
"type": "preference",
"scope": "user"
}
}
After tool calls, log success/failure, duration, and tokens. The recommender uses this to optimize future suggestions.
{
"tool": "remember_tool_outcome",
"arguments": {
"tool_name": "grep_search",
"task_summary": "Find helper usages",
"success": true,
"duration_ms": 120,
"tokens_used": 200
}
}
Search memories by semantic similarity or keywords. Filter by scope, type, repo, or confidence threshold.
{
"tool": "recall",
"arguments": {
"query": "error handling preference",
"limit": 5,
"min_confidence": 0.5
}
}
Fix outdated memories. Corrections lower old confidence and extract new preferences automatically.
{
"tool": "remember_correction",
"arguments": {
"original_content": "I prefer flat error handling.",
"correction_text": "Actually, I prefer Result<T, E> types.",
"context": "Rust project"
}
}
Run periodically to merge duplicates, surface insights, and update preferences. Keeps memory clean and useful.
{
"tool": "reflect",
"arguments": {}
}
Complete reference for every tool the server exposes.
| Tool | Description | Key Arguments |
|---|---|---|
remember |
Store a memory, fact, preference, code pattern, or workflow insight. Extracts KG and learns preferences. | content, type, scope, confidence |
recall |
Search memories by semantic similarity and FTS5 full-text search. | query, type, scope, limit, min_confidence |
recall_recent |
List recently accessed or created memories. | limit, scope, repo_path |
remember_correction |
Record a correction linked to a memory by ID or content match. Penalizes confidence and extracts preferences. | correction_text, memory_id, original_content |
remember_tool_outcome |
Log tool call result (success, tokens, duration) for future recommendations. | tool_name, task_summary, success, duration_ms, tokens_used |
get_preferences |
Retrieve learned preferences, filterable by key prefix or exact key. | prefix, key, min_confidence, limit |
set_preference |
Manually set a preference with high confidence. | key, value, confidence |
get_tool_recommendations |
Get ranked tool recommendations for a task based on historical success, token usage, speed, and similarity. | task, context, limit |
get_knowledge_graph |
Explore entities and relations around a query. | query, depth, limit |
reflect |
Run self-improvement: merge duplicates, extract prefs, flag low confidence, surface insights. | workspace, repo_path, since |
update_memory_confidence |
Reinforce or penalize a memory's confidence score by ID. | memory_id, delta, reason |
The server exposes resources and a prompt that MCP clients can pull into context automatically.
All learned preferences as JSON. Includes key, value, confidence, and source memory IDs.
memory://preferences
Recent memories as JSON. Useful for quick context injection without a full recall query.
memory://recent
Database statistics: memory count, entity count, relation count, correction count.
memory://stats
Injects relevant memories and preferences for a task. Call with task and optional repo_path.
prompt: memory-context
Patterns that keep your memory useful and your assistant sharp.
Use user for global preferences, repo for project-specific patterns, session for ephemeral context.
Short, topic-focused recall queries return better results than vague ones. Use repo_path and scope filters.
After every meaningful tool call, log success, duration, and tokens. The recommender improves with more data.
Corrections update confidence and extract preferences automatically. Wrong memories fade; right ones strengthen.
Run reflect daily or after large batches. Merges duplicates, surfaces insights, flags low-confidence memories.
Copy ~/.agent-memory-mcp/memories.db and its -wal/-shm files to another location periodically.
Common issues and solutions.
Run npm run build then node dist/index.js. Check logs with AGENT_MEMORY_LOG_LEVEL=debug.
AGENT_MEMORY_LOG_LEVEL=debug node dist/index.js
The server uses schema versioning. For very old databases, stop the server and delete the database files:
rm -f ~/.agent-memory-mcp/memories.db ~/.agent-memory-mcp/memories.db-*
Then restart — it will create a fresh v2 schema.
dist/index.jsnpm run build produced dist/index.jsrepo_path or scope filtersmin_confidence to filter weak memoriesreflect to merge duplicatessession scoped memoriesmin_confidence thresholdSet OPENAI_API_KEY environment variable. The server auto-detects and uses text-embedding-3-small.
export OPENAI_API_KEY=sk-...
npm run build && node dist/index.js
Install in under a minute. Works with Claude, VS Code, Cursor, and OpenCode.
|———-|———|————-|
| AGENT_MEMORY_DIR | ~/.agent-memory-mcp | Where the SQLite database lives |
| AGENT_MEMORY_LOG_LEVEL | info | debug, info, warn, error |
| OPENAI_API_KEY | — | Optional; enables OpenAI text-embedding-3-small |
| OPENAI_EMBEDDING_MODEL | text-embedding-3-small | Which OpenAI embedding model to use |
| ANTHROPIC_API_KEY | — | Optional; enables Anthropic-based reflections |
Set them before launching the server, for example:
export AGENT_MEMORY_DIR="$HOME/.agent-memory-mcp"
export AGENT_MEMORY_LOG_LEVEL=debug
Ask your assistant to remember a preference:
“Remember that I prefer concise answers with bullets.”
Or call the tool directly:
{
"tool": "remember",
"arguments": {
"content": "I prefer concise answers with bullets.",
"type": "preference",
"scope": "user"
}
}
After a tool call, log whether it succeeded and how expensive it was:
{
"tool": "remember_tool_outcome",
"arguments": {
"tool_name": "web_search",
"task_summary": "Search MCP specification",
"success": true,
"duration_ms": 850,
"tokens_used": 1200
}
}
When starting a new task, recall what you have already learned:
{
"tool": "recall",
"arguments": {
"query": "concise answers",
"limit": 5,
"min_confidence": 0.5
}
}
If a memory is wrong, correct it:
{
"tool": "remember_correction",
"arguments": {
"original_content": "I prefer concise answers with bullets.",
"correction_text": "Actually, I prefer short paragraphs over bullets.",
"context": "README editing"
}
}
Run reflection to merge duplicates and surface insights:
{
"tool": "reflect"
}
| Tool | When to use |
|---|---|
remember |
Store any memory, fact, preference, or code pattern. |
recall |
Search memories by text or meaning. |
recall_recent |
List recently accessed memories. |
remember_correction |
Record a correction and lower the confidence of the old memory. |
remember_tool_outcome |
Log success/failure and token usage for tool calls. |
get_tool_recommendations |
Get ranked tool suggestions for a task. |
get_preferences |
Retrieve learned preferences. |
set_preference |
Manually set a preference with high confidence. |
get_knowledge_graph |
Explore the entity/relation graph around a topic. |
reflect |
Run self-improvement analysis. |
update_memory_confidence |
Reinforce or penalize a memory by ID. |
The server exposes three resources and one prompt that MCP clients can pull:
memory://preferences — all learned preferences as JSON.memory://recent — recent memories as JSON.memory://stats — database statistics as JSON.memory-context prompt — injects relevant memories and preferences for a task.user — global across all workspaces.repo — tied to a specific repository.session — short-lived, tied to a conversation.Be specific in recall queries — short, topic-focused queries return better results than vague ones.
Log tool outcomes after every meaningful tool call — the recommender improves as it accumulates success/duration/token data.
Apply corrections promptly — corrections update confidence and extract preferences automatically.
Run reflect daily or after large batches of memories — it keeps the database clean and surfaces useful insights.
~/.agent-memory-mcp/memories.db and its -wal/-shm files to another location.npm run build
node dist/index.js
Check the log level with AGENT_MEMORY_LOG_LEVEL=debug.
SQLITE_MISMATCH or schema errorsThe server now uses schema versioning. If you have a very old database, stop the server and delete the database files:
rm -f ~/.agent-memory-mcp/memories.db ~/.agent-memory-mcp/memories.db-*
Then restart.
dist/index.js.npm run build produced dist/index.js.repo_path or scope filters.min_confidence to filter out weak memories.Run reflect to merge duplicates and consider deleting old session scoped memories.
npm testsrc/Last updated: July 14, 2026