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 amemorylayer-embed-serverpeer for self-hosted text and multi-vector),openai,google, andmock(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
# Works out of the box: SQLite storage, `hash` embeddings, no API keypip 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-rpgThe 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:
export MEMORYLAYER_EMBEDDING_PROVIDER=embed_serverexport MEMORYLAYER_EMBED_SERVER_URL=http://embed-host:61051export MEMORYLAYER_EMBEDDING_DIMENSIONS=384 # match the embed server's modelRemoved in v0.1.x: the in-process
local(sentence-transformers),colpali, andqwen3-vlproviders were removed frommemorylayer-server. All self-hosted embedding now goes through thememorylayer-embed-serverpeer using theembed_serverprovider.
Quick Start
# Start the HTTP servermemorylayer serve --port 61001API Usage
from memorylayer import MemoryLayerClient
client = MemoryLayerClient(base_url="http://localhost:61001")
# Store a memorymemory = await client.remember( content="User prefers Python for backend development", type="semantic", importance=0.8, tags=["preferences", "programming"])
# Recall memoriesresults = 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.