coccobas/agent-memory

1

stars

506

commits

TypeScript

primary language

Feb 25, 2026

updated

README

Agent Memory

Give Your AI Agents Persistent, Queryable Memory

npm version License: MIT Node.js Tests


Stop cramming entire knowledge bases into context.
Query specific memory on-demand with sub-millisecond latency.


Get Started · Documentation · MCP Tools


The Problem

Every conversation, your AI agent starts from scratch. You copy-paste context, repeat instructions, and watch tokens burn. Knowledge gets lost between sessions.

The Solution

┌─────────────────────────────────────────────────────────────────┐
│                                                                 │
│   Before: Load everything → 🔥 Token explosion                  │
│                                                                 │
│   After:  Query what you need → ⚡ Sub-ms response              │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Agent Memory is an MCP server that gives AI agents persistent, structured memory. Instead of stuffing context, agents query specific knowledge on-demand.

Agent Memory is the high-speed memory layer for AI agents—persistent, permissioned, and enforceable—so your agents remember the right things, at the right time, without bloating context.

What makes it different:

  • Hierarchical scopes with inheritance (global → org → project → session)
  • Action-based MCP tool suite (plus optional REST API) for storing/querying memory
  • Built-in governance: permissions, auditability, conflict handling, file locks, verification hooks
  • Fast search stack: SQLite WAL/FTS plus optional semantic search (embeddings)

⚡ Quick Start

One command. That's it.

npx agent-memory@latest mcp

Add to your MCP client config:

Claude Desktopclaude_desktop_config.json

Config file location:

OSPath
macOS~/Library/Application Support/Claude/claude_desktop_config.json
Linux~/.config/claude/claude_desktop_config.json
Windows%APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "agent-memory": {
      "command": "npx",
      "args": ["-y", "agent-memory@latest", "mcp"]
    }
  }
}
Cursor.cursor/mcp.json
{
  "mcpServers": {
    "agent-memory": {
      "command": "npx",
      "args": ["-y", "agent-memory@latest", "mcp"]
    }
  }
}
VS Codesettings.json
{
  "mcp.servers": {
    "agent-memory": {
      "command": "npx",
      "args": ["-y", "agent-memory@latest", "mcp"]
    }
  }
}

Restart your client. Done.


🏗️ Architecture

                    ┌─────────────────────────────────────┐
                    │           HIERARCHICAL SCOPES       │
                    └─────────────────────────────────────┘

     ┌──────────────────────────────────────────────────────────────┐
     │  GLOBAL                                                      │
     │  └── Security best practices, universal patterns             │
     │      │                                                       │
     │      ├── ORGANIZATION                                        │
     │      │   └── Team standards, shared tooling                  │
     │      │       │                                               │
     │      │       ├── PROJECT                                     │
     │      │       │   └── Architecture decisions, code style      │
     │      │       │       │                                       │
     │      │       │       └── SESSION                             │
     │      │       │           └── Current working context         │
     │      │       │                                               │
     └──────┴───────┴───────────────────────────────────────────────┘

                         Queries inherit up the chain

🎯 Three Memory Types

TypePurposeExample
🔧 ToolsCommand registry — CLI, APIs, scripts{"name": "test-coverage", "command": "npm run test:cov"}
📏 GuidelinesRules & standards — code style, security{"name": "no-any", "content": "Never use 'any' type"}
💡 KnowledgeFacts & decisions — architecture, gotchas{"title": "Auth", "content": "Using JWT with RS256"}

🚀 Performance

Built for speed. SQLite WAL mode + intelligent caching.

OperationThroughputp99 Latency
Simple query4.5M ops/sec< 0.3ms
Scoped + inheritance3.6M ops/sec< 0.4ms
Full-text search3.5M ops/sec< 0.4ms
Semantic search3.1M ops/sec< 0.5ms

✨ Features

Smart SearchMulti-Agent ReadyProduction Grade
Semantic search (OpenAI/local)File lockingVersion history
Full-text search (FTS5)Conflict detectionQuery caching
Hybrid searchPer-agent permissionsRate limiting

🪝 IDE Hooks

Runtime enforcement via pre/post tool call checks. Hooks intercept MCP tool execution and validate against critical guidelines.

┌─────────────────────────────────────────────────────────────────┐
│  Agent tries to edit file                                       │
│         ↓                                                       │
│  PreToolUse hook fires → Checks critical guidelines             │
│         ↓                                                       │
│  Violation? → ❌ BLOCKED with explanation                       │
│  Clean?     → ✅ Proceed with edit                              │
└─────────────────────────────────────────────────────────────────┘
HookTriggerPurpose
PreToolUseBefore Edit/Write/BashBlock unsafe actions before execution
StopSession end attemptEnforce memory review workflow
UserPromptSubmitUser sends messageParse !am commands for session control
SessionEndSession terminatesAuto-ingest transcript to memory

Install hooks for Claude Code:

npx agent-memory hook install --ide claude --project-path .

→ Hooks Guide


📐 Rules Sync

Agent guidelines for interacting with the MCP server. Rules teach AI assistants the memory workflow — synced directly to your IDE.

# Sync to Claude Code (writes to ~/.claude/CLAUDE.md)
npm run sync-rules -- --ide claude

# Sync to Cursor (writes .mdc files to .cursor/rules/)
npm run sync-rules -- --ide cursor

# Watch mode — auto-sync on changes
npm run sync-rules:watch

What gets synced:

Rule FileContent
auto-memory-core.mdEssential workflow (query → store → tag)
auto-memory-reference.mdAll 50 MCP tools with parameters
auto-memory-examples.mdReal-world usage patterns
auto-memory-strategies.mdOptimization and best practices

→ Rules Sync Guide


🔌 Server Modes

# MCP Server (default) — Claude Desktop, Cursor, etc.
npx agent-memory mcp

# REST API — Custom integrations
AGENT_MEMORY_REST_ENABLED=true AGENT_MEMORY_REST_API_KEY=secret npx agent-memory rest

# Both simultaneously
AGENT_MEMORY_REST_ENABLED=true AGENT_MEMORY_REST_API_KEY=secret npx agent-memory both
EndpointDescription
GET /healthHealth check
POST /v1/querySearch memory
POST /v1/contextGet aggregated context

⚙️ Configuration

# Where to store data (default: ~/.agent-memory for npm installs, ./data for development)
AGENT_MEMORY_DATA_DIR=~/.agent-memory

# Enable semantic search (optional)
AGENT_MEMORY_OPENAI_API_KEY=sk-...

# REST API (disabled by default)
AGENT_MEMORY_REST_ENABLED=true
AGENT_MEMORY_REST_API_KEY=your-secret

# Single-agent mode (skip permissions)
AGENT_MEMORY_PERMISSIONS_MODE=permissive

→ Full configuration reference


📚 Documentation

ResourceDescription
QuickstartGet running in 2 minutes
First WorkflowFull setup guide
MCP ToolsAll 50 tools documented
Hooks GuideIDE hooks for enforcement
Rules SyncSync guidelines to IDEs
IDE SetupClaude, Cursor, VS Code
TroubleshootingCommon issues

🗺️ Roadmap

FeatureStatus
macOS✅ Supported
Windows📝 Documented
Linux📝 Documented
Claude Code hooks✅ Supported
Cursor hooks🚧 In development
VS Code hooks🚧 In development
Other IDE hooks📋 Planned
Task manager (status, assignment, priorities)📋 Planned

Request a feature


🛠️ Development

git clone https://github.com/anthropics/agent-memory.git
cd agent-memory
npm install
npm run build
npm run validate  # lint + typecheck + tests

📄 License

MIT — see LICENSE


Built for the AI-native era

Get Started · Report Bug · Request Feature

Contributors

claude

327 commits

coccobas

179 commits

coccobas/agent-memory

1

stars

506

commits

TypeScript

primary language

Feb 25, 2026

updated

README

Agent Memory

Give Your AI Agents Persistent, Queryable Memory

npm version License: MIT Node.js Tests


Stop cramming entire knowledge bases into context.
Query specific memory on-demand with sub-millisecond latency.


Get Started · Documentation · MCP Tools


The Problem

Every conversation, your AI agent starts from scratch. You copy-paste context, repeat instructions, and watch tokens burn. Knowledge gets lost between sessions.

The Solution

┌─────────────────────────────────────────────────────────────────┐
│                                                                 │
│   Before: Load everything → 🔥 Token explosion                  │
│                                                                 │
│   After:  Query what you need → ⚡ Sub-ms response              │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Agent Memory is an MCP server that gives AI agents persistent, structured memory. Instead of stuffing context, agents query specific knowledge on-demand.

Agent Memory is the high-speed memory layer for AI agents—persistent, permissioned, and enforceable—so your agents remember the right things, at the right time, without bloating context.

What makes it different:

  • Hierarchical scopes with inheritance (global → org → project → session)
  • Action-based MCP tool suite (plus optional REST API) for storing/querying memory
  • Built-in governance: permissions, auditability, conflict handling, file locks, verification hooks
  • Fast search stack: SQLite WAL/FTS plus optional semantic search (embeddings)

⚡ Quick Start

One command. That's it.

npx agent-memory@latest mcp

Add to your MCP client config:

Claude Desktopclaude_desktop_config.json

Config file location:

OSPath
macOS~/Library/Application Support/Claude/claude_desktop_config.json
Linux~/.config/claude/claude_desktop_config.json
Windows%APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "agent-memory": {
      "command": "npx",
      "args": ["-y", "agent-memory@latest", "mcp"]
    }
  }
}
Cursor.cursor/mcp.json
{
  "mcpServers": {
    "agent-memory": {
      "command": "npx",
      "args": ["-y", "agent-memory@latest", "mcp"]
    }
  }
}
VS Codesettings.json
{
  "mcp.servers": {
    "agent-memory": {
      "command": "npx",
      "args": ["-y", "agent-memory@latest", "mcp"]
    }
  }
}

Restart your client. Done.


🏗️ Architecture

                    ┌─────────────────────────────────────┐
                    │           HIERARCHICAL SCOPES       │
                    └─────────────────────────────────────┘

     ┌──────────────────────────────────────────────────────────────┐
     │  GLOBAL                                                      │
     │  └── Security best practices, universal patterns             │
     │      │                                                       │
     │      ├── ORGANIZATION                                        │
     │      │   └── Team standards, shared tooling                  │
     │      │       │                                               │
     │      │       ├── PROJECT                                     │
     │      │       │   └── Architecture decisions, code style      │
     │      │       │       │                                       │
     │      │       │       └── SESSION                             │
     │      │       │           └── Current working context         │
     │      │       │                                               │
     └──────┴───────┴───────────────────────────────────────────────┘

                         Queries inherit up the chain

🎯 Three Memory Types

TypePurposeExample
🔧 ToolsCommand registry — CLI, APIs, scripts{"name": "test-coverage", "command": "npm run test:cov"}
📏 GuidelinesRules & standards — code style, security{"name": "no-any", "content": "Never use 'any' type"}
💡 KnowledgeFacts & decisions — architecture, gotchas{"title": "Auth", "content": "Using JWT with RS256"}

🚀 Performance

Built for speed. SQLite WAL mode + intelligent caching.

OperationThroughputp99 Latency
Simple query4.5M ops/sec< 0.3ms
Scoped + inheritance3.6M ops/sec< 0.4ms
Full-text search3.5M ops/sec< 0.4ms
Semantic search3.1M ops/sec< 0.5ms

✨ Features

Smart SearchMulti-Agent ReadyProduction Grade
Semantic search (OpenAI/local)File lockingVersion history
Full-text search (FTS5)Conflict detectionQuery caching
Hybrid searchPer-agent permissionsRate limiting

🪝 IDE Hooks

Runtime enforcement via pre/post tool call checks. Hooks intercept MCP tool execution and validate against critical guidelines.

┌─────────────────────────────────────────────────────────────────┐
│  Agent tries to edit file                                       │
│         ↓                                                       │
│  PreToolUse hook fires → Checks critical guidelines             │
│         ↓                                                       │
│  Violation? → ❌ BLOCKED with explanation                       │
│  Clean?     → ✅ Proceed with edit                              │
└─────────────────────────────────────────────────────────────────┘
HookTriggerPurpose
PreToolUseBefore Edit/Write/BashBlock unsafe actions before execution
StopSession end attemptEnforce memory review workflow
UserPromptSubmitUser sends messageParse !am commands for session control
SessionEndSession terminatesAuto-ingest transcript to memory

Install hooks for Claude Code:

npx agent-memory hook install --ide claude --project-path .

→ Hooks Guide


📐 Rules Sync

Agent guidelines for interacting with the MCP server. Rules teach AI assistants the memory workflow — synced directly to your IDE.

# Sync to Claude Code (writes to ~/.claude/CLAUDE.md)
npm run sync-rules -- --ide claude

# Sync to Cursor (writes .mdc files to .cursor/rules/)
npm run sync-rules -- --ide cursor

# Watch mode — auto-sync on changes
npm run sync-rules:watch

What gets synced:

Rule FileContent
auto-memory-core.mdEssential workflow (query → store → tag)
auto-memory-reference.mdAll 50 MCP tools with parameters
auto-memory-examples.mdReal-world usage patterns
auto-memory-strategies.mdOptimization and best practices

→ Rules Sync Guide


🔌 Server Modes

# MCP Server (default) — Claude Desktop, Cursor, etc.
npx agent-memory mcp

# REST API — Custom integrations
AGENT_MEMORY_REST_ENABLED=true AGENT_MEMORY_REST_API_KEY=secret npx agent-memory rest

# Both simultaneously
AGENT_MEMORY_REST_ENABLED=true AGENT_MEMORY_REST_API_KEY=secret npx agent-memory both
EndpointDescription
GET /healthHealth check
POST /v1/querySearch memory
POST /v1/contextGet aggregated context

⚙️ Configuration

# Where to store data (default: ~/.agent-memory for npm installs, ./data for development)
AGENT_MEMORY_DATA_DIR=~/.agent-memory

# Enable semantic search (optional)
AGENT_MEMORY_OPENAI_API_KEY=sk-...

# REST API (disabled by default)
AGENT_MEMORY_REST_ENABLED=true
AGENT_MEMORY_REST_API_KEY=your-secret

# Single-agent mode (skip permissions)
AGENT_MEMORY_PERMISSIONS_MODE=permissive

→ Full configuration reference


📚 Documentation

ResourceDescription
QuickstartGet running in 2 minutes
First WorkflowFull setup guide
MCP ToolsAll 50 tools documented
Hooks GuideIDE hooks for enforcement
Rules SyncSync guidelines to IDEs
IDE SetupClaude, Cursor, VS Code
TroubleshootingCommon issues

🗺️ Roadmap

FeatureStatus
macOS✅ Supported
Windows📝 Documented
Linux📝 Documented
Claude Code hooks✅ Supported
Cursor hooks🚧 In development
VS Code hooks🚧 In development
Other IDE hooks📋 Planned
Task manager (status, assignment, priorities)📋 Planned

Request a feature


🛠️ Development

git clone https://github.com/anthropics/agent-memory.git
cd agent-memory
npm install
npm run build
npm run validate  # lint + typecheck + tests

📄 License

MIT — see LICENSE


Built for the AI-native era

Get Started · Report Bug · Request Feature

Contributors

claude

327 commits

coccobas

179 commits

Languages

TypeScript

99.2%