Skip to content

Server Overview

The MemoryLayer server (memorylayer-server, version 0.2.0) is a FastAPI-based HTTP server that provides the core memory infrastructure. It handles memory storage, hybrid vector + keyword search, relationship graphs, entities, session management, and embedding generation. It is part of MemoryLayer (core) and is licensed Apache-2.0. MemoryLayer Enterprise builds on this server; see Editions & Licensing.

Features

  • REST API — Full-featured HTTP API for all memory operations, with a live OpenAPI schema (see the REST API Reference)
  • MCP Compatible — Pairs with the separate MCP server package (@scitrera/memorylayer-mcp-server) for Claude and other LLMs
  • Hybrid Search — SQLite + sqlite-vec vector search fused with keyword search (Turso/libSQL also supported)
  • Embedding Providers — hash (default; dependency-free and lexical), embed_server (delegates to a memorylayer-embed-server peer for self-hosted text and multi-vector), openai, google, and mock (wiring tests only)
  • Cognitive Memory Types — Episodic, semantic, procedural, and working memory
  • Knowledge Graph — 85 typed relationship types across 12 categories for memory associations
  • Entities & Perspective — Canonical entity registry with aliases, provenance, and relatedness, plus observer/subject representations (/v1/entities, /v1/representation)
  • Context Environment — Server-side Python sandbox with RLM (Recursive Language Model) for memory analysis without consuming the client’s context window
  • Session Management — Persistent sessions with working memory, token-budget-aware extraction, raw checkpoints, and budgeted context packs
  • Plugins — Optional plugins such as memorylayer-server-rpg (Repository Planning Graph, /v1/rpg) are discovered automatically when installed

Installation

Terminal window
# Works out of the box: SQLite storage, `hash` embeddings, no API key
pip install memorylayer-server
# OpenAI embeddings (cloud)
pip install "memorylayer-server[openai]"
# Google GenAI embeddings (cloud)
pip install "memorylayer-server[google]"
# Cloud embedding extras bundled (openai + google)
pip install "memorylayer-server[embeddings]"
# All optional dependencies (cloud embeddings + LLMs + context sandbox + document parsers)
pip install "memorylayer-server[all]"
# Repository Planning Graph plugin (auto-enables /v1/rpg)
pip install memorylayer-server-rpg

The default hash provider matches on shared words, not meaning. For self-hosted semantic embeddings on CPU or GPU, run a memorylayer-embed-server peer and point the core server at it:

Terminal window
export MEMORYLAYER_EMBEDDING_PROVIDER=embed_server
export MEMORYLAYER_EMBED_SERVER_URL=http://embed-host:61051
export MEMORYLAYER_EMBEDDING_DIMENSIONS=384 # match the embed server's model

Removed in v0.1.x: the in-process local (sentence-transformers), colpali, and qwen3-vl providers were removed from memorylayer-server. All self-hosted embedding now goes through the memorylayer-embed-server peer using the embed_server provider.

Quick Start

Terminal window
# Start the HTTP server
memorylayer serve --port 61001

API Usage

from memorylayer import MemoryLayerClient
client = MemoryLayerClient(base_url="http://localhost:61001")
# Store a memory
memory = await client.remember(
content="User prefers Python for backend development",
type="semantic",
importance=0.8,
tags=["preferences", "programming"]
)
# Recall memories
results = await client.recall(
query="What programming languages does the user like?",
limit=5
)

Architecture

The server is organized into these layers:

┌──────────────────────────────────────────────┐
│ API Layer (FastAPI routes) │
│ - /v1/memories (recall, reflect, associate) │
│ - /v1/sessions, /v1/workspaces, /v1/threads │
│ - /v1/entities, /v1/representation │
│ - /v1/context/*, /health │
├──────────────────────────────────────────────┤
│ Service Layer │
│ - MemoryService, SessionService │
│ - WorkspaceService, AssociationService │
│ - ContradictionService, EmbeddingService │
│ - ContextEnvironmentService, LLMService │
├──────────────────────────────────────────────┤
│ Storage Layer │
│ - SQLite + sqlite-vec (or Turso/libSQL) │
│ - Embedding providers │
└──────────────────────────────────────────────┘

Source Code

The server source code is located at memorylayer-core-python/ and published to PyPI as memorylayer-server.