agent-memory
MCP server for zero-config, traceable long-term memory using SQLite, enabling agents to store, search, trace, and monitor memory with tools like memory_store, memory_search, and memory_health.
README
agent-memory
Zero-config, traceable, MCP-native long-term memory for agents.
agent-memory targets a gap in the current memory stack: a local-first engine that works with pip install, runs on pure SQLite, and makes memory evolution explainable instead of opaque.
Install from PyPI with pip install agent-memory-engine.
Current packaged release: 0.2.1.
Documentation
- English docs index:
docs/README.md - 中文文档索引:
docs/zh-CN/README.md - Teaching series entry:
docs/teaching/01-project-overview.md - Delivery tutorial:
docs/project-delivery-and-tutorial.md - MCP guide:
docs/mcp-integration.md - Release guide:
docs/release-and-pypi.md - Benchmark report:
docs/benchmark-results.md
Why this exists
Mem0proves demand, but pulls in heavier infra such as Neo4j or Qdrant.- Local agents and personal copilots need a memory layer that is easy to embed, debug, export, and ship.
- The project spans a broad technical surface area: storage, retrieval, ranking, decay, provenance, conflict handling, MCP, and evaluation.
Current Status
- SQLite backend with WAL, FTS5, audit log, evolution log, entity index, and causal parent links
- Go service workspace with SQLite storage engine, schema migration, REST gateway, gRPC server, auth hooks, metrics, tracing bootstrap, and Cobra CLI
- Schema indexes for type, layer, recency, trust, source, relation, and audit hot paths
- Python SDK via
MemoryClient - Python
MemoryClientnow supportsembeddedandremotemodes throughSQLiteBackendandRemoteBackend - In service mode, fused retrieval orchestration can run inside the Go service over REST/gRPC
- Rule-based intent router with Reciprocal Rank Fusion
- Adaptive forgetting utilities with dual-threshold layer transitions
- Heuristic conflict detection with contradiction edges and trust-score adjustment
- Optional LLM-backed conflict adjudication for top semantic candidates
- Governance helpers for health reports, audit reads, and JSONL export/import
- Optional MCP server and REST API adapters with dependency-friendly fallbacks
sqlite-vecintegration with safe fallback to Python cosine scan when unavailable- Deterministic local fallback embeddings for testability and zero-friction startup
- LLM-first conversation extraction with heuristic fallback
- Trace graph reports with ancestors, descendants, relations, and evolution history
- Idempotent maintenance cycle for decay, promotion/demotion, conflict upkeep, and consolidation
- Benchmark helpers and LOCOMO-Lite style starter data
Quickstart
pip install agent-memory-engine
agent-memory store "User prefers SQLite for local-first agents." --source-id demo
agent-memory search "Why SQLite?"
agent-memory health
For development:
pip install -e '.[dev]'
.venv/bin/python -m pytest -q
from agent_memory import MemoryClient
client = MemoryClient()
item = client.add(
"The user prefers SQLite for local-first agent projects.",
source_id="demo-session",
)
results = client.search("What database does the user prefer?")
print(results[0].item.content)
trace = client.trace_graph(item.id)
print(trace.descendants)
health = client.health()
print(health.suggestions)
Service mode
make proto
cd go-server && go run ./cmd/server
export AGENT_MEMORY_MODE=remote
export AGENT_MEMORY_GO_SERVER_URL=http://127.0.0.1:8080
export AGENT_MEMORY_GRPC_TARGET=127.0.0.1:9090
agent-memory search "Why SQLite?"
Architecture
graph TD
A["Python SDK / MCP"] --> B["MemoryClient"]
B --> C{"Mode"}
C -->|"embedded"| D["SQLiteBackend (Python)"]
C -->|"remote"| E["RemoteBackend"]
E --> F["Go REST / gRPC"]
F --> G["SQLite Storage Engine"]
G --> H[("SQLite + WAL + vector fallback")]
B --> I["Intent Router / Conflict / Trust"]
Core components
src/agent_memory/client.py— high-level SDK entry pointsrc/agent_memory/storage/remote_backend.py— REST/gRPC bridge to the Go serviceproto/memory/v1/— shared Protobuf contractsgo-server/cmd/server/main.go— Go service entrypoint with graceful shutdowngo-server/internal/storage/sqlite.go— Go storage enginego-server/internal/gateway/handler.go— Go REST handlersgo-server/internal/grpc/server.go— Go gRPC implementationsrc/agent_memory/storage/sqlite_backend.py— SQLite persistence, FTS, vector fallback, trace queriessrc/agent_memory/controller/router.py— intent-aware retrieval routing and RRF fusionsrc/agent_memory/controller/forgetting.py— Ebbinghaus-inspired adaptive forgettingsrc/agent_memory/controller/conflict.py— contradiction detection and conflict recordssrc/agent_memory/controller/consolidation.py— overlap grouping and merge-draft generationsrc/agent_memory/controller/trust.py— multi-factor trust scoringsrc/agent_memory/governance/health.py— stale/orphan/conflict monitoringsrc/agent_memory/interfaces/mcp_server.py— eight MCP toolssrc/agent_memory/extraction/pipeline.py— conversation-to-memory extractionbenchmarks/— storage/retrieval microbenchmarks and synthetic eval seeds
Design choices
- SQLite + WAL keeps deployment zero-config while fitting agent workloads: many reads, occasional writes.
- Rule routing over LLM routing keeps routing latency predictable and testable.
- RRF instead of score averaging avoids calibration problems across lexical, entity, and semantic retrieval.
sqlite-vecplus fallback gives C/SQL vector search when available while keeping the package runnable everywhere.- Soft delete preserves provenance and causal trace integrity.
- Hash fallback embeddings make the package runnable even before a local embedding model is available.
- Unique relation edges keep maintenance idempotent and health metrics stable.
Project layout
agent-memory/
├── deploy/
├── go-server/
├── proto/
├── docs/plans/
├── examples/
├── src/agent_memory/
│ ├── controller/
│ ├── embedding/
│ ├── extraction/
│ └── storage/
└── tests/
Benchmarks
Synthetic LOCOMO-Lite run on the bundled starter dataset (30 dialogues / 150 questions):
| Metric | agent-memory |
Semantic-only baseline |
|---|---|---|
| Overall hit rate | 50.0% | 23.3% |
| Factual recall | 53.3% | 6.7% |
| Temporal recall | 36.7% | 3.3% |
| Causal recall | 53.3% | 6.7% |
| p95 retrieval latency | 16.64ms | 11.50ms |
- Full report:
docs/benchmark-results.md - Re-run locally:
python benchmarks/locomo_lite/evaluate.py
MCP Usage
Install MCP support and launch the stdio server:
pip install -e .[mcp]
python -m agent_memory.interfaces.mcp_server
Claude Desktop configuration:
{
"mcpServers": {
"agent-memory": {
"command": "python",
"args": ["-m", "agent_memory.interfaces.mcp_server"],
"env": {
"AGENT_MEMORY_DB_PATH": "/absolute/path/to/default.db"
}
}
}
}
Typical tools:
memory_store— store a memory with provenancememory_search— run intent-aware retrievalmemory_trace— inspect causal ancestry and evolutionmemory_health— inspect stale/conflict/orphan metrics
More details: docs/mcp-integration.md
Demos
python examples/demo_cross_session.py --db /tmp/agent-memory-demo.dbpython examples/interactive_chat.py --db chat_memory.db --provider nonepython examples/mcp_server.py
Release Notes
- Changelog:
CHANGELOG.md benchmarks/locomo_lite/latest_results.jsonis regenerated by the evaluation scriptdocs/screenshots/is reserved for verified MCP client screenshots- Delivery record and full tutorial:
docs/project-delivery-and-tutorial.md - Release and PyPI guide:
docs/release-and-pypi.md - Expansion and optimization review:
docs/plans/2026-03-24-agent-memory-expansion-review.md
Dev Notes
- Run all tests with
.venv/bin/python -m pytest -q - Run Go tests with
cd go-server && go test ./... - Run Go benchmarks with
make go-bench - Use the built-in CLI with
agent-memory --help sqlite-vecis installed as a package dependency; if the extension cannot be loaded at runtime, vector search safely falls back to Python cosine scan- Try microbenchmarks with
python benchmarks/bench_storage.pyandpython benchmarks/bench_retrieval.py - Compare Python and Go with
make bench-compare - Try the demo runner with
python examples/benchmark_runner.py
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。