v0.1.0 • Self-improving agent memory

Agent Memory MCP

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.

11
MCP Tools
Cross-workspace
32
Tests Passing
MIT
Open Source

What It Does

Six core capabilities that make your assistant smarter every session.

Semantic + Keyword Recall

SQLite FTS5 full-text search plus lightweight vector similarity. Find memories by exact terms or conceptual meaning.

Personal Knowledge Graph

Auto-extracts entities and relations from memories. Explore connections like a personal CodeGraph — see how concepts link across your work.

Preference Learning

Learns style, formatting, workflow, and tool-selection preferences from explicit statements and corrections. Adapts to how you work.

Tool Recommender

Logs tool outcomes (success, tokens, duration) and ranks recommendations by historical performance. Optimizes token usage automatically.

Continuous Correction

Corrections link to memories, penalize confidence, and extract new preferences. Wrong memories fade; right ones strengthen.

Self-Improvement

Run reflect to merge duplicates, surface insights, flag low-confidence memories, and update preferences automatically.

Quick Start

Clone, build, and connect to your favorite MCP client in under a minute.

bash
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.

json
{
  "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).

json
{
  "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.

json
{
  "mcpServers": {
    "agent-memory": {
      "command": "node",
      "args": ["${workspaceFolder}/dist/index.js"]
    }
  }
}

The opencode.json is pre-configured. OpenCode discovers it on restart.

json
{
  "mcpServers": {
    "agent-memory": {
      "command": "node",
      "args": ["${workspaceFolder}/dist/index.js"]
    }
  }
}

How It Works

Five simple steps to make your assistant smarter every session.

Remember

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"
  }
}

Log Outcomes

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
  }
}

Recall

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
  }
}

Correct

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"
  }
}

Reflect

Run periodically to merge duplicates, surface insights, and update preferences. Keeps memory clean and useful.

{
  "tool": "reflect",
  "arguments": {}
}

All 11 MCP Tools

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

Context Injection

The server exposes resources and a prompt that MCP clients can pull into context automatically.

Resource

memory://preferences

All learned preferences as JSON. Includes key, value, confidence, and source memory IDs.

memory://preferences
Resource

memory://recent

Recent memories as JSON. Useful for quick context injection without a full recall query.

memory://recent
Resource

memory://stats

Database statistics: memory count, entity count, relation count, correction count.

memory://stats
Prompt

memory-context

Injects relevant memories and preferences for a task. Call with task and optional repo_path.

prompt: memory-context

Best Practices

Patterns that keep your memory useful and your assistant sharp.

Scope Intentionally

Use user for global preferences, repo for project-specific patterns, session for ephemeral context.

Be Specific in Queries

Short, topic-focused recall queries return better results than vague ones. Use repo_path and scope filters.

Log Tool Outcomes

After every meaningful tool call, log success, duration, and tokens. The recommender improves with more data.

Apply Corrections Promptly

Corrections update confidence and extract preferences automatically. Wrong memories fade; right ones strengthen.

Reflect Regularly

Run reflect daily or after large batches. Merges duplicates, surfaces insights, flags low-confidence memories.

Back Up the Database

Copy ~/.agent-memory-mcp/memories.db and its -wal/-shm files to another location periodically.

Troubleshooting

Common issues and solutions.

Server fails to start

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
SQLITE_MISMATCH or schema errors

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.

Assistant cannot find tools
  • Ensure MCP config points to the absolute path of dist/index.js
  • Restart the assistant/editor after editing config
  • Verify npm run build produced dist/index.js
Recall returns unrelated results
  • Use repo_path or scope filters
  • Raise min_confidence to filter weak memories
  • Apply corrections to bad memories so their confidence drops
Large database / slow queries
  • Run reflect to merge duplicates
  • Consider deleting old session scoped memories
  • Increase min_confidence threshold
OpenAI embeddings not working

Set 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

Ready to give your assistant a memory?

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

Core workflow

1. Store a preference

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"
  }
}

2. Log a tool outcome

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
  }
}

3. Recall relevant context

When starting a new task, recall what you have already learned:

{
  "tool": "recall",
  "arguments": {
    "query": "concise answers",
    "limit": 5,
    "min_confidence": 0.5
  }
}

4. Correct outdated memories

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"
  }
}

5. Reflect periodically

Run reflection to merge duplicates and surface insights:

{
  "tool": "reflect"
}

Tool reference

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.

Resources and prompts

The server exposes three resources and one prompt that MCP clients can pull:


Best practices

  1. Scope intentionally
    • user — global across all workspaces.
    • repo — tied to a specific repository.
    • session — short-lived, tied to a conversation.
  2. Be specific in recall queries — short, topic-focused queries return better results than vague ones.

  3. Log tool outcomes after every meaningful tool call — the recommender improves as it accumulates success/duration/token data.

  4. Apply corrections promptly — corrections update confidence and extract preferences automatically.

  5. Run reflect daily or after large batches of memories — it keeps the database clean and surfaces useful insights.

  6. Back up the database — copy ~/.agent-memory-mcp/memories.db and its -wal/-shm files to another location.

Troubleshooting

Server fails to start

npm run build
node dist/index.js

Check the log level with AGENT_MEMORY_LOG_LEVEL=debug.

SQLITE_MISMATCH or schema errors

The 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.

Assistant cannot find tools

Recall returns unrelated results

Large database

Run reflect to merge duplicates and consider deleting old session scoped memories.


Next steps

Last updated: July 14, 2026