Memory MCP
A production-grade memory server for LibreChat that stores conversation turns and distills durable memories like decisions, constraints, and assumptions. It provides hybrid retrieval and consistency auditing to ensure AI plans remain aligned with established context and previous decisions.
README
Memory MCP
Production-grade Memory MCP server for single-tenant LibreChat workspaces. It stores raw conversation turns, distills durable memory (decisions/constraints/mistakes/assumptions/open questions), and provides hybrid retrieval plus plan consistency auditing.
Özellikler
- Raw turn log + embedding + full-text indeksleme.
- Distilled memory çıkarımı: kararlar, kısıtlar, hatalar, varsayımlar, açık sorular.
- Dedup + supersede zinciri (eski kararlar korunur, stale tespit yapılır).
- Hybrid retrieval: pgvector + PostgreSQL full-text + RRF fusion.
- Fast / Deep modlar: öngörülebilir gecikme, token budget yönetimi.
- Audit: plan/metinleri aktif karar/kısıtlar ve superseded öğelerle kontrol.
- Shared import/export: HMAC imzalı paketlerle kontrollü paylaşım.
- Gözlemlenebilirlik: JSON log + Prometheus metrikleri.
Kurulum
1) Ortam değişkenleri
.env dosyasını .env.example üzerinden oluşturun:
cp .env.example .env
Özellikle şunları ayarlayın:
DATABASE_URLLLM_API_KEYSHARED_HMAC_SECRET
2) Docker Compose
make up
3) Migrasyonlar
make migrate
4) Testler
make test
MCP Endpoint
MCP endpointi /mcp altında çalışır. Bu servis tool + arguments ile JSON alır.
Örnek:
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"tool": "thread.create",
"arguments": {}
}'
LibreChat MCP yapılandırması
LibreChat MCP URL’nizi şu şekilde ayarlayın:
- Uğur:
https://mcp.datasins.com/mcp - Gökçe:
https://mcp.gokce.ai/mcp
Plan Registry (Topic Separation)
Planlar ayrı çalışma konuları olarak yönetilir ve her thread bir plana bağlıdır.
plan.create
{
"tool": "plan.create",
"arguments": {
"name": "memory-mcp-core",
"meta": {"owner": "ugur"}
}
}
thread.create
{
"tool": "thread.create",
"arguments": {
"plan_id": "<plan_uuid>",
"meta": {"topic": "ingest-pipeline"}
}
}
Örnek Tool Payloadları
turn.ingest
{
"tool": "turn.ingest",
"arguments": {
"thread_id": "<uuid>",
"role": "user",
"text": "Yeni karar: Postgres kullanılacak.",
"external_turn_id": "librechat-turn-123",
"embed_now": true
}
}
external_turn_id aynı değerle gelen tekrar çağrılarda idempotent davranır.
distill.extract
{
"tool": "distill.extract",
"arguments": {
"thread_id": "<uuid>",
"turn_id": "<uuid>",
"include_recent_turns": 4,
"write_to_memory": true
}
}
retrieve.context
{
"tool": "retrieve.context",
"arguments": {
"thread_id": "<uuid>",
"query": "Hangi kararlar aktif?",
"mode": "fast",
"scope": "distilled_only",
"top_k": 8,
"token_budget": 800,
"recency_bias": 0.1,
"explain": true
}
}
audit.check_consistency
{
"tool": "audit.check_consistency",
"arguments": {
"thread_id": "<uuid>",
"proposed_plan_text": "SQLite kullanalım.",
"deep": true
}
}
shared.export
{
"tool": "shared.export",
"arguments": {
"thread_id": "<uuid>",
"types": ["decision", "constraint"],
"include_mistakes": false,
"expires_in_minutes": 60
}
}
shared.import
{
"tool": "shared.import",
"arguments": {
"payload": {"...": "..."},
"signature": "<hmac>"
}
}
Güvenlik
- Pydantic doğrulama + sıkı enumlar.
- Prompt injection güvenliği için sistem promptlarında açık uyarı.
- HMAC imza ile export/import.
- API anahtarları loglanmaz.
Notlar
EMBEDDING_DIMfarklıysa migration güncellenmeli.ENABLE_LLM_RERANK=trueise low-confidence deep retrieval’da LLM rerank aktif olur.- Retention politikaları
.enviçindekiRETENTION_*değişkenleriyle kontrol edilir.
LibreChat Uçtan Uca Kullanım Örnekleri
1) Yeni Plan Başlatma
plan.createile yeni plan oluşturun.thread.createile plan altında bir thread açın.turn.ingestile ilk kararları gönderin.
2) Mevcut Planı Devam Ettirme
plan.listile planları bulun.- Mevcut planın thread ID’sini takip edin veya yeni thread ekleyin.
distill.extractile yeni turn’lerden karar/kısıt çıkarın.
3) Deep Audit
retrieve.contextilemode=deepveexplain=truekullanın.audit.check_consistencyile plan metnini doğrulatın.stale_referencesçıktısını kontrol ederek superseded kararları güncelleyin.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.