McpEngramMemory.Core
0.6.1
dotnet add package McpEngramMemory.Core --version 0.6.1
NuGet\Install-Package McpEngramMemory.Core -Version 0.6.1
<PackageReference Include="McpEngramMemory.Core" Version="0.6.1" />
<PackageVersion Include="McpEngramMemory.Core" Version="0.6.1" />
<PackageReference Include="McpEngramMemory.Core" />
paket add McpEngramMemory.Core --version 0.6.1
#r "nuget: McpEngramMemory.Core, 0.6.1"
#:package McpEngramMemory.Core@0.6.1
#addin nuget:?package=McpEngramMemory.Core&version=0.6.1
#tool nuget:?package=McpEngramMemory.Core&version=0.6.1
<p align="center"> <img src="images/banner.svg" alt="MCP Engram Memory" width="900"/> </p>
<p align="center"> <a href="https://dotnet.microsoft.com/"><img src="https://img.shields.io/badge/.NET-8%20%7C%209%20%7C%2010-512BD4" alt=".NET"/></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"/></a> <a href="https://www.nuget.org/packages/McpEngramMemory.Core"><img src="https://img.shields.io/nuget/v/McpEngramMemory.Core" alt="NuGet"/></a> <img src="https://img.shields.io/badge/tests-842%20passed-brightgreen" alt="Tests"/> <img src="https://img.shields.io/badge/MCP%20tools-52-blue" alt="MCP Tools"/> </p>
Give your AI agent persistent memory that survives across sessions. Store decisions, recall context, and build expertise — all locally, no cloud required.
A cognitive memory engine exposed as an MCP server with hybrid search (BM25 + vector), knowledge graph, lifecycle management, and hierarchical expert routing.
<p align="center"> <img src="images/features.svg" alt="Features" width="900"/> </p>
Quickstart
Option 1 — Clone and build
git clone https://github.com/wyckit/mcp-engram-memory.git
cd mcp-engram-memory
dotnet build
Option 2 — Docker
docker build -t mcp-engram-memory .
docker run -i -v memory-data:/app/data mcp-engram-memory
Option 3 — NuGet library (embed the engine in your own app)
dotnet add package McpEngramMemory.Core --version 0.6.1
Add to your MCP client config (Claude Code, Copilot, Gemini, Codex):
{
"mcpServers": {
"engram-memory": {
"command": "dotnet",
"args": ["run", "--project", "/path/to/mcp-engram-memory/src/McpEngramMemory"],
"env": { "MEMORY_TOOL_PROFILE": "minimal" }
}
}
}
First build downloads a ~5.7 MB embedding model (bge-micro-v2) — subsequent builds are instant.
See examples/ for ready-to-use config files and AI assistant harness templates.
Tool Profiles
Control how many tools are exposed with MEMORY_TOOL_PROFILE:
| Profile | Tools | What's included |
|---|---|---|
minimal |
16 | Core CRUD + composite + admin + multi-agent — recommended starting point |
standard |
35 | Adds graph, lifecycle, clustering, intelligence |
full |
52 | Everything including expert routing, debate, synthesis, benchmarks (default) |
At a Glance
| Metric | Value |
|---|---|
| MCP tools | 52 (profiles: 16 / 35 / 52) |
| Retrieval | Hybrid BM25 + vector with synonym expansion, cascade retrieval, MMR diversity, auto-PRF |
| Embedding | bge-micro-v2 (384-dim, ONNX, MIT license, runs locally, concurrent inference) |
| Best recall | 0.792 realworld dataset, 0.771 scale dataset (hybrid mode) |
| Search latency | ~2.7 ms production, ~0.04 ms benchmark |
| Storage | JSON (default) or SQLite (WAL mode) |
| Frameworks | net8.0, net9.0, net10.0 |
| Tests | 842 across 46 files |
| CI/CD | GitHub Actions: build + test on push, nightly MSA benchmarks |
System Layers
| Layer | Stability | Components |
|---|---|---|
| Core | Stable | Storage, Embeddings, Retrieval, Lifecycle, Graph |
| Advanced | Stable | Clustering, Multi-Agent Sharing, Intelligence |
| Orchestration | Maturing | Expert Routing (HMoE), Debate, Benchmarks |
<p align="center"> <img src="images/how-it-works.svg" alt="How It Works" width="900"/> </p>
<p align="center"> <img src="images/retrieval-pipeline.svg" alt="Retrieval Pipeline" width="900"/> </p>
AI Assistant Setup
Copy the reference harness for your tool — each includes recall/store/routing patterns:
| Tool | Harness File | MCP Config |
|---|---|---|
| Claude Code | examples/CLAUDE.md → ~/.claude/CLAUDE.md |
examples/claude-code.json |
| GitHub Copilot | examples/copilot-instructions.md → .github/ |
examples/vscode-copilot.json |
| Google Gemini | GEMINI.md → workspace root |
Gemini CLI config |
| OpenAI Codex | examples/AGENTS.md → project root |
Codex config |
Claude Code users: Route memory sub-agents to Sonnet (
model: "sonnet") and utility sub-agents to Haiku (model: "haiku") to maximize your subscription. See the harness for details.
For step-by-step setup prompts, see AI Assistant Setup.
Cost-Optimized Usage (Claude Code)
| Tier | Model | What runs here |
|---|---|---|
| Main thread | Opus | Coding, architecture, reasoning, decisions |
| Memory sub-agents | Sonnet (model: "sonnet") |
All engram MCP tool calls: search, store, dispatch, link, merge |
| Utility sub-agents | Haiku (model: "haiku") |
Codebase exploration, file searches, grep research, simple lookups |
Opus thinks, Sonnet remembers, Haiku explores.
MCP Tools (52)
| Group | Tools | Description |
|---|---|---|
| Core Memory | store_memory, store_batch, search_memory, delete_memory |
Vector CRUD with namespace isolation, batch import, and lifecycle-aware search |
| Composite | remember, recall, reflect, get_context_block |
High-level wrappers with auto-dedup, auto-linking, expert routing, and context assembly |
| Knowledge Graph | link_memories, unlink_memories, get_neighbors, traverse_graph |
Directed graph with 7 relation types and multi-hop BFS traversal |
| Clustering | create_cluster, update_cluster, store_cluster_summary, get_cluster, list_clusters |
Semantic grouping with auto-computed centroids |
| Lifecycle | promote_memory, memory_feedback, deep_recall, decay_cycle, configure_decay |
State transitions (STM/LTM/archived), activation energy decay |
| Intelligence | detect_duplicates, find_contradictions, merge_memories, uncollapse_cluster, list_collapse_history |
Dedup, contradiction detection, merge, collapse reversal |
| Expert Routing | dispatch_task, create_expert, get_domain_tree, link_to_parent |
HMoE semantic routing with 3-level domain tree |
| Multi-Agent | cross_search, share_namespace, unshare_namespace, list_shared, whoami |
Namespace sharing, permissions, cross-namespace RRF search |
| Debate | consult_expert_panel, map_debate_graph, resolve_debate, purge_debates |
Multi-perspective analysis with debate tracking |
| Synthesis | synthesize_memories |
Map-reduce synthesis via local SLM (Ollama) |
| Accretion | get_pending_collapses, collapse_cluster, dismiss_collapse, trigger_accretion_scan |
DBSCAN cluster detection and two-phase summarization |
| Admin | get_memory, cognitive_stats, get_metrics, reset_metrics |
Inspection, system-wide statistics, and latency metrics |
| Maintenance | rebuild_embeddings, compression_stats |
Re-embed entries and storage diagnostics |
| Benchmarks | run_benchmark |
IR quality validation (Recall@K, MRR, nDCG@K) |
Full tool documentation: MCP Tools Reference
Environment Variables
| Variable | Default | Description |
|---|---|---|
MEMORY_TOOL_PROFILE |
full |
Tool profile: minimal (16), standard (35), full (52) |
AGENT_ID |
default |
Agent identity for multi-agent namespace sharing |
MEMORY_STORAGE |
json |
Storage backend: json or sqlite |
MEMORY_SQLITE_PATH |
data/memory.db |
SQLite database path (when MEMORY_STORAGE=sqlite) |
MEMORY_MAX_NAMESPACE_SIZE |
unlimited | Max entries per namespace |
MEMORY_MAX_TOTAL_COUNT |
unlimited | Max total entries across all namespaces |
NuGet Library
The core engine is available as a NuGet package for embedding in your own .NET applications:
dotnet add package McpEngramMemory.Core --version 0.6.1
using McpEngramMemory.Core.Services;
using McpEngramMemory.Core.Services.Storage;
var persistence = new PersistenceManager();
var embedding = new OnnxEmbeddingService();
var index = new CognitiveIndex(persistence);
// Store
var vector = embedding.Embed("The capital of France is Paris");
var entry = new CognitiveEntry("fact-1", vector, "default", "The capital of France is Paris", "facts");
index.Upsert(entry);
// Search
var results = index.Search(embedding.Embed("French capital"), "default", k: 5);
Documentation
| Doc | Description |
|---|---|
| First 5 Minutes | Store, close, recall — the whole loop |
| Cheat Sheet | One-page quick reference |
| MCP Tools Reference | Full documentation for all 52 tools |
| Architecture | System design, retrieval pipeline, data flow |
| Services | All services with descriptions |
| Internals | Retrieval, quantization, persistence deep dive |
| Project Structure | File tree and module organization |
| AI Assistant Setup | Step-by-step setup prompts for each tool |
| Sample Prompts | Power prompts and usage patterns |
| Benchmarks | IR quality results and mode selection guide |
| Testing | Test coverage breakdown (842 tests) |
Build & Test
cd mcp-engram-memory
dotnet build
dotnet test # 842 tests across 46 files
Tech Stack
- .NET 8/9/10, C#
- ModelContextProtocol 1.0.0
- FastBertTokenizer 0.4.67
- Microsoft.ML.OnnxRuntime 1.17.0
- bge-micro-v2 ONNX (384-dim, MIT license)
- Microsoft.Data.Sqlite 8.0.11
- xUnit (tests)
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- FastBertTokenizer (>= 0.4.67)
- Microsoft.Data.Sqlite (>= 8.0.11)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.ML.OnnxRuntime (>= 1.17.0)
- System.Numerics.Tensors (>= 8.0.0)
-
net8.0
- FastBertTokenizer (>= 0.4.67)
- Microsoft.Data.Sqlite (>= 8.0.11)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.ML.OnnxRuntime (>= 1.17.0)
- System.Numerics.Tensors (>= 8.0.0)
-
net9.0
- FastBertTokenizer (>= 0.4.67)
- Microsoft.Data.Sqlite (>= 8.0.11)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.ML.OnnxRuntime (>= 1.17.0)
- System.Numerics.Tensors (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.