MC

MCP Server: Semantic Memory & Consolidation for AI

Enable AI assistants with persistent semantic search, storage, and autonomous consolidation using the MCP server across 13+ AI applications.

Quick Install
npx -y @doobidoo/mcp-memory-service

Overview

MCP (Model Context Protocol) Server is a lightweight service that gives AI assistants persistent, searchable semantic memory and automated consolidation workflows. It exposes APIs to store, search, and manage memory items (text snippets, embeddings, metadata) and can consolidate those items over time into higher-level summaries or longer-term memories. This makes it easier to build assistants that remember and reason over past interactions, files, and knowledge without re-querying external sources every time.

The server is designed to integrate with different embedding providers and vector stores, and it supports operational workflows for periodic consolidation. Developers can use MCP Server to add persistent context to chatbots, enable retrieval-augmented generation (RAG), keep user- or app-specific memories, and centralize semantic search across multiple applications.

Features

  • Persistent semantic storage of memory items with metadata
  • Vector-based search using embeddings from any provider
  • Automated consolidation pipelines to summarize and merge memories
  • RESTful API for inserting, querying, and managing memories
  • Pluggable backends for storage and vector databases (SQLite/PG, pgvector, etc.)
  • Configurable embedding provider (OpenAI, local models, or custom API)
  • Multi-application support (works across many AI apps and agents)
  • Lightweight, container-friendly deployment (Docker / Docker Compose)
  • Logging, metrics, and basic admin endpoints

Installation / Configuration

Quick start with Docker Compose:

# docker-compose.yml
version: "3.8"
services:
  mcp-server:
    image: ghcr.io/doobidoo/mcp-memory-service:latest
    ports:
      - "8080:8080"
    environment:
      MCP_STORAGE_URL: "sqlite:///data/mcp.db"
      MCP_EMBEDDING_PROVIDER: "openai"
      OPENAI_API_KEY: "${OPENAI_API_KEY}"
      MCP_CONSOLIDATION_SCHEDULE: "0 */6 * * *" # every 6 hours
    volumes:
      - ./data:/data

Start the server:

docker compose up -d

Environment variables (examples):

  • MCP_STORAGE_URL — Storage backend URL (e.g., sqlite:///data/mcp.db, postgres://user:pass@host/db)
  • MCP_EMBEDDING_PROVIDER — Embedding provider key (openai, local, custom)
  • OPENAI_API_KEY — API key for OpenAI (if used)
  • MCP_CONSOLIDATION_SCHEDULE — Cron expression for automated consolidation
  • MCP_SERVER_PORT — Port to listen on (default 8080)

Configuration can also be passed via a YAML/JSON config file or CLI flags depending on deployment.

Available Resources

The MCP Server exposes HTTP endpoints suited for programmatic integration:

  • POST /memory/add — Add one or more memory items (text + metadata)
  • POST /memory/query — Semantic search over stored memories
  • POST /memory/consolidate — Trigger consolidation pipeline (manual or scheduled)
  • GET /memory/{id} — Retrieve a memory item by ID
  • GET /stats — Server and storage metrics

Example: add a memory item

curl -X POST http://localhost:8080/memory/add \
  -H "Content-Type: application/json" \
  -d '{
    "app_id": "chat-assistant",
    "items": [
      {"text":"User prefers email updates", "metadata":{"user_id":"u123","source":"conversation"}}
    ]
  }'

Example: query similar memories

curl -X POST http://localhost:8080/memory/query \
  -H "Content-Type: application/json" \
  -d '{"query":"contact preference for user u123","top_k":5,"app_id":"chat-assistant"}'

For SDKs, integrations, and additional examples see the GitHub repository: https://github.com/doobidoo/mcp-memory-service

Use Cases

  • Persistent chat assistant memory:

    • Store user preferences, past decisions, and follow-ups. On each new conversation, query recent and consolidated memories to inform responses (e.g., “User prefers email”).
  • Retrieval-Augmented Generation (RAG) for documents:

    • Ingest documents, create embeddings, and perform semantic search to fetch relevant passages for the model to use as context when answering user queries.
  • Long-term consolidation:

    • Run scheduled consolidation jobs to merge many low-level memory items (chat turns, logs) into summarized high-level memories (e.g., monthly summaries, action items) to reduce noise and improve retrieval quality.
  • Multi-agent coordination:

    • Share a central memory service among agents so they can store outputs, plan steps, and query shared context for consistent state across workflows.
  • Application analytics and audits:

    • Use stored metadata and stats endpoints to analyze memory access patterns, retention, and consolidation effects.

Example Memory Item Schema

FieldTypeDescription
idstringUnique ID (generated if omitted)
app_idstringApplication/tenant identifier
textstringRaw content used to generate embedding
embeddingfloat[]Vector produced by the embedding provider
metadataobjectArbitrary key/value pairs (user_id, source, timestamp)
created_attimestampInsertion time

Tips for Developers

  • Choose a vector store that fits scale: SQLite/PG for small-medium deployments, managed vector DBs for large scale.
  • Tune consolidation frequency and criteria to avoid over-aggregating recent important context.
  • Encrypt or restrict access to sensitive memories; use per-app namespaces and authentication.
  • Monitor embedding costs when using external providers; consider local embedding models if required.

For full API documentation, examples, and deployment recipes, consult the repository: https://github.com/doobidoo/mcp-memory-service