Dense Mem

Dense Mem

About Self-hosted AI agent memory server with MCP, evidence provenance, typed claims, conflict detection, embeddings, recall, PostgreSQL, and Neo4j.

Category
访问服务器

README

<h1 align="center">Dense-Mem</h1>

<p align="center"> <a href="README.md">English</a> · <a href="README.zh-CN.md">简体中文</a> </p>

<p align="center"> <img src="https://img.shields.io/badge/Dense--Mem-trustworthy_AI_memory-0f766e?style=for-the-badge&logo=github&logoColor=white" alt="Dense-Mem" /> </p>

<p align="center"> <strong>Self-hosted memory for AI agents that preserves evidence, detects conflicts, and never silently rewrites facts.</strong> </p>

<p align="center"> <a href="https://demo-dense-mem.markhuang.ai"><img src="https://img.shields.io/badge/Try%20Dense--Mem%20live-Open%20hosted%20demo-0f766e?style=for-the-badge" alt="Try Dense-Mem live" /></a> </p>

<p align="center"> <strong>Create a temporary isolated team and test Dense-Mem before self-hosting.</strong> </p>

<p align="center"> <a href="https://github.com/markhuangai/dense-mem"><img src="https://img.shields.io/github/stars/markhuangai/dense-mem?style=flat-square&logo=github" alt="GitHub stars" /></a> <a href="https://github.com/markhuangai/dense-mem/issues"><img src="https://img.shields.io/github/issues/markhuangai/dense-mem?style=flat-square&logo=github" alt="GitHub issues" /></a> <a href="https://github.com/markhuangai/dense-mem/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache--2.0-blue?style=flat-square" alt="License: Apache-2.0" /></a> <img src="https://img.shields.io/badge/Go-1.26-00ADD8?style=flat-square&logo=go&logoColor=white" alt="Go 1.26" /> <a href="https://github.com/markhuangai/dense-mem/pkgs/container/dense-mem"><img src="https://img.shields.io/badge/Docker-GHCR-2496ED?style=flat-square&logo=docker&logoColor=white" alt="Docker image on GHCR" /></a> </p>

<p align="center"> <img src="https://img.shields.io/badge/MCP-Streamable_HTTP-111827?style=flat-square" alt="MCP Streamable HTTP" /> <img src="https://img.shields.io/badge/Neo4j-5.26-008CC1?style=flat-square&logo=neo4j&logoColor=white" alt="Neo4j 5.26" /> <img src="https://img.shields.io/badge/PostgreSQL-18-4169E1?style=flat-square&logo=postgresql&logoColor=white" alt="PostgreSQL 18" /> <img src="https://img.shields.io/badge/OpenAPI-3.0-6BA539?style=flat-square&logo=openapiinitiative&logoColor=white" alt="OpenAPI 3.0" /> <img src="https://visitor-badge.laobi.icu/badge?page_id=markhuangai.dense-mem&style=flat-square" alt="Visitors" /> </p>

<p align="center"> <a href="https://zenodo.org/records/20519039"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.20519039.svg" alt="DOI: 10.5281/zenodo.20519039" /></a> </p>

Dense-Mem gives MCP clients a durable memory layer with provenance, typed claims and facts, verification gates, server-side embeddings, recall, team isolation, REST/OpenAPI, and a token-protected control portal. The host LLM owns conversation and judgment; Dense-Mem owns durable memory state and returns structured outcomes the host can explain to users.

Under the hood, Dense-Mem is a standalone HTTP MCP memory server. HTTP MCP is the v1 supported MCP transport and is served at /mcp from the main HTTP process.

Dense-Mem is part of the research preprint Governed Enterprise AI Memory Beyond RAG: From Vector Retrieval to Permissioned Knowledge Graphs.

Project Intro

<p align="center"> <a href="https://cdn.markhuang.ai/videos/dense-mem/intro.mp4" target="_blank" rel="noopener noreferrer"> <img src="assets/thumbnail.png" alt="Watch the Dense-Mem intro video" width="100%" /> </a> </p>

<p align="center"> <a href="https://cdn.markhuang.ai/videos/dense-mem/intro.mp4" target="_blank" rel="noopener noreferrer"><strong>Watch the Dense-Mem intro video</strong></a> </p>

Try the Hosted Demo

Create a temporary isolated team at https://demo-dense-mem.markhuang.ai and test Dense-Mem before self-hosting.

<p align="center"> <img src="assets/readme-hero.jpg" alt="Cartoon architecture illustration: AI clients send evidence into a secure Dense-Mem vault where claims become facts, conflicts become clarification questions, and durable storage sits behind the service." /> </p>

Why Dense-Mem?

AI agents need memory that can be trusted later, not only text that can be retrieved later.

  • Evidence is first-class. Memories start as source fragments before they become claims or facts.
  • Facts pass through typed claims, verification, and promotion gates.
  • Comparable conflicts become clarifications[]; Dense-Mem does not silently overwrite active facts.
  • The host LLM stays responsible for extracting candidates and asking the user questions. Dense-Mem stays responsible for durable state, gates, audit metadata, and recall.
  • Operators keep control of storage, team/profile isolation, API keys, and data egress boundaries.

60-Second Quickstart

Download the base local-only compose example and env template, set the required secrets, and start Dense-Mem:

mkdir dense-mem-local
cd dense-mem-local

curl -fsSLo docker-compose.yml \
  https://raw.githubusercontent.com/markhuangai/dense-mem/main/examples/docker-compose.base.yml
curl -fsSLo .env.example \
  https://raw.githubusercontent.com/markhuangai/dense-mem/main/examples/.env.example

cp .env.example .env
# Fill in POSTGRES_PASSWORD, NEO4J_PASSWORD, CONTROL_PORTAL_TOKEN, and AI_API_KEY.
${EDITOR:-vi} .env

docker compose up -d
docker compose exec server /app/provision-team --name "primary-memory"

The base compose example provisions Postgres, neo4j:5.26-community with the Neo4j Graph Data Science plugin, and the Dense-Mem server. It exposes only local host ports:

MCP/API:        http://127.0.0.1:8080/mcp
User portal:    http://127.0.0.1:8080/ui
Control portal: http://127.0.0.1:8090/

Cold image pulls can take longer than 60 seconds. Redis and public HTTPS are intentionally omitted from the base example; use the expert example when you need those deployment options.

The server requires a complete embedding configuration at startup: AI_API_URL, AI_API_KEY, AI_API_EMBEDDING_MODEL, and AI_API_EMBEDDING_DIMENSIONS. The compose examples provide OpenAI defaults for the URL, model, and dimensions (https://api.openai.com/v1, text-embedding-3-small, 1536), so the minimal local setup only needs you to fill in AI_API_KEY. Override those values together when using a different embedding provider or model.

Telemetry Overlay

Prometheus telemetry is optional and off by default. To collect usage, performance, verifier token, embedding token, recall, and promotion metrics for the /ui app and control portal dashboards, run the base stack with the telemetry overlay:

curl -fsSLo prometheus.yml \
  https://raw.githubusercontent.com/markhuangai/dense-mem/main/examples/prometheus.yml
curl -fsSLo docker-compose.telemetry.yml \
  https://raw.githubusercontent.com/markhuangai/dense-mem/main/examples/docker-compose.telemetry.yml

export TELEMETRY_SCRAPE_TOKEN="$(openssl rand -hex 32)"
docker compose -f docker-compose.yml -f docker-compose.telemetry.yml up -d

The overlay starts Prometheus on 127.0.0.1:9090, retains 30 days of samples, passes TELEMETRY_SCRAPE_TOKEN to Prometheus as a scrape secret, and points Dense-Mem at http://prometheus:9090 for telemetry queries. It also sets TELEMETRY_PROMETHEUS_JOB=dense-mem so dashboards query only the dense-mem scrape job when Prometheus is shared.

Online recall-quality cards use densemem_recall_feedback_total and densemem_recall_feedback_quality_score. They stay at zero until RECALL_FEEDBACK_ENABLED=true registers the submit_recall_feedback tool and a host LLM submits compact feedback for recall_memory results. Normal production recall traffic still contributes request volume, result count, and latency.

For the disposable demo image, keep the control portal disabled and use the demo telemetry overlay instead:

curl -fsSLo prometheus.demo.yml \
  https://raw.githubusercontent.com/markhuangai/dense-mem/main/examples/prometheus.demo.yml
curl -fsSLo docker-compose.demo.telemetry.yml \
  https://raw.githubusercontent.com/markhuangai/dense-mem/main/examples/docker-compose.demo.telemetry.yml

export TELEMETRY_SCRAPE_TOKEN="$(openssl rand -hex 32)"
docker compose -f docker-compose.yml -f docker-compose.demo.telemetry.yml up -d

The demo overlay scrapes the demo service at demo:8091 on the private Compose network and sets TELEMETRY_PROMETHEUS_JOB=dense-mem-demo. Do not publish that metrics listener publicly.

Compare

Capability Dense-Mem File memory Vector DB Generic MCP memory
Evidence provenance Source fragments are stored before claims or facts Usually absent or informal Stores chunks, not truth history Varies by implementation
Fact changes Verification gates and promotion rules Manual edits Similarity updates can obscure history Often tool-specific
Conflict handling Comparable conflicts return clarification tasks Caller must notice Similar vectors do not mean contradiction Usually caller-managed
Recall Facts, claims, fragments, contradictions, and clarifications Text search Vector similarity Varies
Agent boundary Host LLM judges; Dense-Mem stores and enforces Blurred Retrieval only Often blurred
Operations Teams, profiles, API keys, audit metadata, REST, OpenAPI, MCP Minimal Database operations Varies

Redis is optional for single-node deployments and required for multi-instance deployments.

Documentation

The README is the product overview. The full user documentation lives in the Dense-Mem wiki:

Goal Wiki page
Run Dense-Mem locally Quick Start
Use memory day to day Using Dense-Mem
Configure providers, Redis, and Traefik Configuration
Understand the system design Architecture
Review API and operations details Technical Reference

Responsibility Boundary

Area Dense-Mem owns Host LLM owns
Memory writes Evidence fragments, typed claims, verification, gates, promotion Extracting candidate memories from chat text
Embeddings Fragment embeddings and recall-query embeddings through the configured provider No vectors for normal writes or recall
Retrieval Facts, validated claims, fragments, contradictions, clarification tasks Choosing what to ask or cite in the conversation
Truth changes Comparable-conflict detection, confirmation-driven supersession Asking the user which uncertain memory is correct
Operations Teams, named profiles, API keys, audit metadata, control portal Client-side MCP configuration

Dense-Mem is not an agent brain, planner, or external truth arbiter. It stores memory, applies explicit gates, and returns structured outcomes.

Memory Workflow

Tool Purpose
remember Normal chat-session memory insertion. Saves evidence, creates typed claims, verifies, promotes when gates pass, and returns structured outcomes.
import_memories Ingests summarized historical conversations. By default it records evidence and validated claims without auto-promotion.
recall_memory Retrieves facts, validated claims, fragments, and clarifications[] for the authenticated team.
trace_memory Expands one fact or claim into bounded evidence, promotion lineage, contradictions, and supersession links.
assemble_context Builds a bounded prompt-ready context block plus structured facts, claims, fragments, and clarifications.
reflect_memories Reviews active facts, candidate or disputed claims, contradictions, stale memories, and clarification needs.
confirm_memory Applies the user's answer to a clarification task, either accepting a claim and superseding comparable active facts or keeping/rejecting it.

Low-level tools remain available for advanced callers: save_memory, post_claim, verify_claim, promote_claim, search tools, graph query tools, community tools, and retraction tools.

Memory moves through this path:

source fragment -> typed claim -> verification -> promotion gate -> active fact
                                                   |
                                                   v
                                            clarification task

Comparable conflicts are not resolved silently. Dense-Mem returns clarifications[], and the host LLM asks the user which memory is correct. After the user answers, the host calls confirm_memory.

Data Egress

Dense-Mem forwards fragment text and recall queries to the configured embedding provider. Claim verification can send candidate claims and supporting evidence to the configured verifier provider. Self-hosted providers keep that traffic inside your boundary; hosted providers do not. See the wiki Configuration and Technical Reference for provider settings and egress details.

Embedding Model Consistency

Dense-Mem owns embeddings for normal writes and recall. It checks the stored embedding model and dimension on startup so vectors from incompatible models are not mixed silently. Rotation requires re-embedding or rebuilding vector indexes; the step-by-step process belongs in the wiki Configuration.

Tool Discoverability

Dense-Mem exposes three discoverability surfaces backed by one registry:

Surface Path Purpose
Tool catalog GET /api/v1/tools Runtime tool discovery
Runtime OpenAPI GET /api/v1/openapi.json Agents, codegen, integrations
MCP Streamable HTTP POST /mcp, GET /mcp MCP clients over the main HTTP service

The full route list and client examples live in the wiki Technical Reference and Quick Start.

Design Notes

License

Apache-2.0

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选