Skip to main content
Glama

memory-mcp-server

A Model Context Protocol (MCP) server that provides persistent memory for AI assistants. Stores, searches, and associates conversation logs using hybrid search (FTS5 full-text + vector similarity) with A-MEM style note structuring.

Features

  • Hybrid Search -- FTS5 full-text search + vector similarity with RRF (Reciprocal Rank Fusion)

  • A-MEM Note Structuring -- Automatic summary, keywords, tags, and context extraction via LLM

  • Associative Search -- Serendipity-driven discovery through TF-IDF random walk and link exploration

  • Multi-backend Storage -- SQLite (local), Turso (cloud), or Hybrid (local + cloud sync)

  • MEMORY.md / CLAUDE.md Integration -- Auto-generated memory index and project context import

  • Data Export/Import -- JSONL format for backup and migration

  • Structured Logging -- Configurable log levels, output to stderr (MCP-safe)

  • Embedding Queue -- Batched, async embedding generation for performance

Related MCP server: MCP Memory Server

Installation

npm install memory-mcp-server

Or run directly:

npx memory-mcp-server

Quick Start

Claude Desktop Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "memory-mcp-server"],
      "env": {
        "MEMORY_DB_PATH": "/path/to/memory.db",
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

Environment Variables

Variable

Description

Default

MEMORY_DB_PATH

Path to SQLite database file

./memory.db

MEMORY_TENANT_ID

Tenant ID for multi-tenant isolation

default

MEMORY_STORAGE_TYPE

Storage backend: sqlite, turso, hybrid

sqlite

OPENAI_API_KEY

OpenAI API key for embeddings + LLM structuring

(optional)

MEMORY_INDEX_PATH

Path for auto-generated MEMORY.md

(optional)

CLAUDE_MD_PATH

Path to CLAUDE.md project context

(optional)

TURSO_DATABASE_URL

Turso database URL (for turso/hybrid mode)

(optional)

TURSO_AUTH_TOKEN

Turso auth token (for turso/hybrid mode)

(optional)

MEMORY_SYNC_INTERVAL

Hybrid sync interval in ms

30000

MEMORY_SYNC_ON_WRITE

Sync to cloud on every write

false

MEMORY_LOG_LEVEL

Log level: debug, info, warn, error

info

MEMORY_LOG_FORMAT

Log format: text or json

text

MCP Tools

memory_save

Save a conversation message as a memory note. Automatically generates summary, keywords, tags, embeddings, and links when OpenAI API key is configured.

Parameters:
  content    (string, required)  -- The content to save
  role       (enum, required)    -- user | assistant | system | summary
  session_id (string, optional)  -- Session ID
  project    (string, optional)  -- Project name
  keywords   (string[], optional) -- Keywords (auto-generated if omitted)
  tags       (string[], optional) -- Tags (auto-generated if omitted)

Search memories using hybrid search (FTS5 + vector similarity with RRF fusion).

Parameters:
  query      (string, required)  -- Search query (keywords or natural language)
  date_from  (string, optional)  -- Filter: earliest date (ISO 8601)
  date_to    (string, optional)  -- Filter: latest date (ISO 8601)
  project    (string, optional)  -- Filter: project name
  tags       (string[], optional) -- Filter: tags
  session_id (string, optional)  -- Filter: session ID
  limit      (number, optional)  -- Max results (default: 10)

memory_associate

Discover related memories through associative (serendipity) search.

Parameters:
  seed        (string, optional) -- Seed text (random if omitted)
  temperature (number, optional) -- 0.0=focused, 1.0=exploratory (default: 0.5)
  limit       (number, optional) -- Max results (default: 5)

memory_stats

Get statistics about stored memories: total notes, sessions, links, date range, and top keywords.

memory_summarize

Summarize memories for a given period or project using LLM.

Parameters:
  project   (string, optional) -- Filter by project
  date_from (string, optional) -- Start date (ISO 8601)
  date_to   (string, optional) -- End date (ISO 8601)

memory_update_index

Update the MEMORY.md index file and optionally import CLAUDE.md content.

memory_export

Export memory data as JSON Lines (JSONL) format for backup or migration.

Parameters:
  date_from        (string, optional)  -- Export from date
  date_to          (string, optional)  -- Export until date
  include_links    (boolean, optional) -- Include note links (default: true)
  include_sessions (boolean, optional) -- Include sessions (default: true)

memory_import

Import memory data from JSONL format (from a previous export).

Parameters:
  data           (string, required) -- JSONL content to import
  merge_strategy (enum, optional)   -- skip (default) or overwrite

memory_migrate

Migrate data between storage backends (e.g., SQLite to Turso).

memory_sync_status

(Hybrid mode only) Get sync status of the hybrid adapter.

Architecture

                    MCP Client (Claude Desktop, etc.)
                              |
                         stdio transport
                              |
                    +-------------------+
                    |   MCP Server      |
                    |   (10 tools)      |
                    +-------------------+
                              |
          +-------------------+-------------------+
          |                   |                   |
    NoteBuilder         SearchEngine       AssociateEngine
    (LLM + Embed)       (FTS + Vec)        (Random Walk)
          |                   |                   |
          +-------------------+-------------------+
                              |
                    +-------------------+
                    |  StorageAdapter    |
                    |  (interface)       |
                    +---+-------+---+---+
                        |       |       |
                   SQLite   Turso   Hybrid
                  (local)  (cloud)  (sync)

Key Components

  • NoteBuilder -- A-MEM style note structuring with LLM (summary, keywords, tags, context) and embedding generation

  • SearchEngine -- Hybrid search combining FTS5 BM25 scoring with vector cosine similarity via RRF

  • AssociateEngine -- Serendipity search using TF-IDF random walk, link exploration, and vector space exploration with MMR diversity

  • EmbeddingQueue -- Batched async embedding generation with configurable batch size and flush delay

  • ImportanceScorer -- Multi-signal importance scoring (content, links, freshness, role)

  • DataTransfer -- JSONL-based export/import for backup and migration

  • MemoryIndex -- Auto-generates MEMORY.md with recent memories, frequent topics, and user preferences

  • ClaudeContext -- Imports CLAUDE.md sections as searchable system notes

  • SessionManager -- Session lifecycle with timeout-based auto-end and MEMORY.md update triggers

  • Logger -- Structured logging to stderr with configurable levels (debug/info/warn/error)

Storage Backends

Backend

Use Case

Vector Search

FTS5

SQLite

Local development, single machine

Yes (sqlite-vec)

Yes

Turso

Cloud deployment, multi-device

No

LIKE fallback

Hybrid

Best of both -- local speed + cloud sync

Yes (via local)

Yes (via local)

Graceful Degradation

The server works without an OpenAI API key:

  • Without API key: FTS-only search, no auto-structuring, no embeddings

  • With API key: Full hybrid search, LLM structuring, vector embeddings, auto-linking

Development

# Install dependencies
npm install

# Run in development mode
npm run dev

# Run tests
npm test

# Type check
npm run typecheck

# Build
npm run build

License

MIT

Available Tools

9 tools
memory_associateA

Discover related memories through associative search (serendipity search). Uses TF-IDF random walk, note link exploration, and vector space exploration to find surprising connections.

Inputs: seed, limit, temperature.

memory_exportB

Export memory data as JSON Lines (JSONL) format. Includes notes, links, and sessions for backup or migration.

Inputs: date_to, date_from, include_links, include_sessions.

memory_importB

Import memory data from JSON Lines (JSONL) format. Restores notes, links, and sessions from a previous export.

Inputs: data (required), merge_strategy.

memory_migrateB

Migrate memory data from one storage backend to another (e.g., SQLite to Turso). Creates the target adapter, copies all tenants, sessions, notes, and links.

Inputs: target_type (required), target_db_path, target_turso_url, target_turso_token.

memory_saveB

Save a conversation message as a memory note. Automatically generates summary, keywords, tags, embeddings, and links using LLM and embedding models when available.

Inputs: role (required), content (required), tags, project, +2 more.

memory_statsA

Get statistics about stored memories: total notes, sessions, links, date range, etc.

Inputs: no named parameters.

memory_summarizeA

Summarize memories for a given period or project. Uses LLM to create a coherent summary from stored notes.

Inputs: date_to, project, date_from.

memory_update_indexB

Update the MEMORY.md index file with latest memory data. Also optionally imports CLAUDE.md content as searchable context.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 9 tools

    Disambiguation4/5

    Each tool has a distinct role: search (query-based retrieval), associate (serendipity/link exploration), and summarize (LLM aggregation) are separated by their retrieval strategy, and the storage tools (save, migrate, export, import, update_index) target clearly different operations. The only mild overlaps are search vs. associate (both surface related memories) and update_index's optional CLAUDE.md import vs. memory_import, but descriptions make the boundaries readable.

    Naming Consistency5/5

    Every tool follows the same memory_<verb> pattern (memory_search, memory_save, memory_export, memory_import), with only memory_stats deviating to a noun, which is conventional and still predictable. No style mixing (no camelCase or stray prefixes).

    Tool Count5/5

    Nine tools sit comfortably in the well-scoped 3-15 range, and each covers a genuinely distinct lifecycle concern (retrieval, persistence, maintenance, portability). Nothing appears redundant or padded.

    Completeness4/5

    The surface covers retrieval, creation, aggregation, maintenance, and full backup/restore (export/import/migrate), so major workflows are unblocked. However, there is no explicit delete/forget operation, no get-by-id for a single note, and no direct note edit, which are notable gaps for a persistent memory store where forgetting or correcting a memory matters.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to store and retrieve memories with semantic search capabilities using vector embeddings. Provides persistent memory storage with SQLite backend for context retention across conversations.
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to store and retrieve long-term memories with semantic search, supporting various memory types and tags via PostgreSQL and pgvector.
      -
    • F
      license
      Not graded
      quality
      B
      maintenance
      Persistent memory for AI agents. Stores verbatim conversation transcripts and makes them searchable by meaning via semantic embeddings.
      24
      -