Mem0Sharp 0.2.1

dotnet add package Mem0Sharp --version 0.2.1
                    
NuGet\Install-Package Mem0Sharp -Version 0.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mem0Sharp" Version="0.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mem0Sharp" Version="0.2.1" />
                    
Directory.Packages.props
<PackageReference Include="Mem0Sharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mem0Sharp --version 0.2.1
                    
#r "nuget: Mem0Sharp, 0.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mem0Sharp@0.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mem0Sharp&version=0.2.1
                    
Install as a Cake Addin
#tool nuget:?package=Mem0Sharp&version=0.2.1
                    
Install as a Cake Tool

<div align="center"> <img src="assets/banner.png" alt="Mem0Sharp Banner" width="100%" /> </div>

Mem0Sharp

NuGet version NuGet downloads GitHub Release .NET 10 License

Long-term cognitive memory engine for AI applications and agents in .NET 10.

Mem0Sharp is an independent, standalone C#/.NET implementation of the open-source Mem0 project. It delivers a unified service API for saving, searching, updating, and consolidating semantic memories with modular embedding and vector storage providers.

  • 🔒 100% Standalone & Local-First: Runs entirely in-process in .NET with zero telemetry or third-party cloud service requirements.
  • ðŸŠķ Zero-Dependency Core: Core runtime uses standard .NET 10 BCL. Persistence providers (PostgreSQL/pgvector, SQLite, Qdrant) are modular add-ons.
  • 🧠 Cognitive Memory Behaviors: Goes beyond raw vector storage with autonomous behaviors (dreaming/consolidation, spontaneous associations, and personality-shaped first-person recall).
  • 🔌 Native Model Context Protocol (MCP): Includes 9 local MCP tools out of the box for agentic developer tools (Cursor, Claude Desktop, Copilot).

Mem0Sharp is not affiliated with, sponsored by, or endorsed by Mem0 or mem0ai.


Quickstart

Get started immediately with in-memory storage, deterministic local embeddings, and no external services:

using Mem0Sharp;

var memory = new MemoryService();
await memory.AddAsync("I prefer C# over Python.", new MemoryAddOptions { UserId = "alice" });
var results = await memory.SearchAsync(
    "What language does Alice like?",
    new MemorySearchOptions { Filter = new MemoryFilter(UserId: "alice"), TopK = 1 });

Console.WriteLine(results[0].Memory.Text); // I prefer C# over Python.

Why Mem0Sharp? (Comparison Matrix)

Feature / Capability Mem0Sharp Python Mem0 (OSS) Hosted Mem0 SaaS Raw Vector DBs Ephemeral Chat Buffers
Ecosystem & Runtime Native .NET 10 / C# Python Cloud API Any Driver Any Framework
Local-First & Offline 100% (No Telemetry) 100% ❌ Cloud Only 100% 100%
Zero-Dependency Core Yes (Pure .NET BCL) ❌ Multi-package ❌ Client SDK ❌ Heavy client Yes
Cognitive Behaviors (Dreaming, Identity) Built-in ❌ (Static) ❌ (Static) ❌ (Raw vectors) ❌
Model Context Protocol (MCP) 9 Built-in Tools Separate repo ❌ Cloud only ❌ ❌
Hybrid Search + Cross-Encoder Reranking Built-in (BM25 + Dense) Basic Proprietary ❌ Manual setup ❌
Audit History & Temporal Tracking Built-in Basic Proprietary ❌ Manual setup ❌

Architecture & Memory Lifecycle

flowchart LR
    subgraph Ingestion["1. Memory Ingestion"]
        Msg["User & Agent Messages"] --> Extractor["LLM / Lexical Extractor"]
        Extractor --> Dedupe["Deduplication & Conflict Resolver"]
    end

    subgraph Behaviors["2. Cognitive Behaviors"]
        Dedupe --> Normal["Normal Fact Memory"]
        Dedupe --> Dream["Dreaming & Consolidation"]
        Dedupe --> Assoc["Spontaneous Associations"]
        Dedupe --> Identity["Personality / First-Person"]
    end

    subgraph Storage["3. Modular Persistence"]
        Normal & Dream & Assoc & Identity --> Store["Storage Engine<br/>(InMemory / SQLite / PostgreSQL pgvector / Qdrant)"]
    end

    subgraph Retrieval["4. Context Retrieval"]
        Query["Search Query"] --> Hybrid["Hybrid Search<br/>(Dense Vector + BM25)"]
        Store --> Hybrid
        Hybrid --> Rerank["Reranker (Cohere / Cross-Encoder / LLM)"]
        Rerank --> Context["Filtered Agent Context"]
    end

Installation

Install the dependency-free core package:

dotnet add package Mem0Sharp

For persistent database backends, install the optional provider packages:

dotnet add package Mem0Sharp.PostgreSQL
dotnet add package Mem0Sharp.SQLite

Features

  • Semantic & Hybrid Retrieval: Dense vector search combined with BM25 keyword scoring and LLM/Cohere/Cross-Encoder reranking.
  • Model Support: Built-in support for OpenAI-compatible, Anthropic, and Ollama model APIs.
  • Cognitive Behaviors:
    • Normal: Standard factual extraction and recall.
    • Dreaming: Background memory consolidation, compressing repeated facts into long-term insights.
    • Random Thoughts: Spontaneous associations and creative prompt injections.
    • Personal/Identity: First-person perspective memory shaping.
  • Audit & History: Persistent ADD, UPDATE, and DELETE history with audit timestamps, actor, and role tracking.
  • Scoped Organization: User, session, and agent-level memory partitioning with run filters and metadata matching.
  • Model Context Protocol (MCP): 9 built-in tools ready to plug into Claude Desktop, Cursor, and VS Code.
  • Batch Operations: High-throughput transactional batch embeddings and searches.

Usage Examples

1. Basic In-Memory Operations

using Mem0Sharp;

var memory = new MemoryService();

// Add a memory
await memory.AddAsync("I prefer dark mode and vim keybindings", userId: "alice");

// Search memories
var results = await memory.SearchAsync(
    "What editor settings does Alice prefer?",
    new MemoryFilter(UserId: "alice"),
    topK: 3);

foreach (var result in results)
{
    Console.WriteLine($"{result.Score:F3}: {result.Memory.Text}");
}

// Update and History
var allMemories = await memory.GetAllAsync(new MemoryFilter(UserId: "alice"));
var memoryId = allMemories[0].Id;
await memory.UpdateAsync(memoryId, "I prefer dark mode and Neovim keybindings");
var history = await memory.GetHistoryAsync(memoryId);

2. Multi-turn Conversation Extraction

await memory.AddAsync(
[
    new Message("user", "I live in Berlin and work as a .NET architect."),
    new Message("assistant", "Nice to meet you! I will remember that.")
],
userId: "alice",
scope: MemoryScope.User);

3. Persistent PostgreSQL with pgvector

using Mem0Sharp;

var embeddings = new LocalEmbeddingGenerator(384);
await using var store = new PostgresMemoryStore(new PostgresMemoryStoreOptions
{
    ConnectionString = Environment.GetEnvironmentVariable("MEM0_POSTGRES")!,
    EmbeddingDimensions = 384,
    TableName = "mem0_memories"
});
await store.InitializeAsync();

var memory = new MemoryService(store, embeddings);

4. Portable SQLite Store

using Mem0Sharp;

await using var store = new SqliteMemoryStore("data/mem0sharp.db");
await store.InitializeAsync();

var memory = new MemoryService(store, new LocalEmbeddingGenerator(384));

Ecosystem Integration & Samples

Explore practical runnable examples in the samples/ folder:

  • Getting Started: Zero-setup CRUD, search, and history tracking.
  • Memory Behaviors: Fact extraction, dreaming/consolidation, spontaneous associations, and personality-shaped memory.
  • Ollama Integration: Fully offline local LLM extraction and embeddings.
  • PostgreSQL + OpenAI: Enterprise persistent pgvector storage with OpenAI models.
  • Agent Framework Memory: Cross-session persistent memory for Microsoft Agent Framework.
  • MCP Server: Standalone Model Context Protocol server exposing Mem0Sharp tools to Claude Desktop & Cursor.

Documentation


Build & Test

dotnet build .\Mem0Sharp.slnx
dotnet test .\tests\Mem0Sharp.Tests\Mem0Sharp.Tests.csproj

Attribution and Trademarks

Mem0Sharp is an independent .NET implementation inspired by the open-source Mem0 project. The original Mem0 project is copyright 2023 Taranjeet Singh and is licensed under the Apache License 2.0. Copyright for the Mem0Sharp implementation and its modifications is held by Jihad Khawaja and contributors. See NOTICE and LICENSE for details.

Mem0 and related marks belong to their respective owners. Mem0Sharp is not affiliated with, sponsored by, or endorsed by Mem0 or mem0ai.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Mem0Sharp:

Package Downloads
Mem0Sharp.PostgreSQL

PostgreSQL and pgvector persistence providers for Mem0Sharp.

Mem0Sharp.SQLite

SQLite persistence provider for Mem0Sharp.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.1 110 8/16/2026
0.2.0 102 8/15/2026
0.1.7 94 8/15/2026
0.1.6 104 8/11/2026
0.1.5 384 8/1/2026
0.1.4 97 8/1/2026
0.1.3 96 7/26/2026
0.1.2 620 7/14/2026
0.1.1 108 7/13/2026