Memstate Documentation

Give your AI agents structured, versioned memory they can navigate. Custom LLM models extract keypaths automatically, detect conflicts, and compress context.

Setup guide for AI assistants

Canonical checklist for any AI system helping a user install Memstate: API keys, npx @memstate/mcp setup, MCP JSON, per-agent docs, and verification. Linked from /llms.txt.

Core Concepts

Custom LLM Intelligence

Our custom-trained models extract structured memories from raw text. Just send content via memstate_remember and we handle keypath extraction, conflict detection, and versioning automatically.

Keypaths

Memories are organized hierarchically using dot-separated paths like auth.provider or database.schema.users. This gives agents a navigable structure rather than a flat list.

Version Control

Every memory is versioned. When content is updated via supersede, the previous version is preserved in history. Agents can trace decisions back through time.

Conflict Detection & Versioning

When memories conflict or a parent keypath changes, the system automatically resolves it by versioning — both versions are preserved in history. Every change is fully auditable without any manual review step.

Token Efficiency

Structured keypath = value atoms instead of text blobs. Agents get precision facts, not context soup. Typically reduces token usage by 80% compared to traditional RAG.

Time-Travel Queries

Use memstate_get_keypaths with the at_revision parameter to see memory state at any point in history. Understand what your agent knew when decisions were made.

Context Compression

Summaries are generated automatically. Agents get a compressed view of their memory first, then drill into full content only when needed.

Keypath Hierarchy

project/
├── auth
├── auth.provider → "SuperTokens Cloud"
└── auth.session → "JWT with refresh"
├── database
├── database.schema → "Users, memories..."
└── database.migrations → "Auto on startup"
└── api
├── api.endpoints → "REST + MCP"
└── api.auth → "API key based"

Which integration should I use?

MCP Server is the recommended integration for AI coding agents like Claude, Cursor, Cline, and Windsurf. It connects directly via the Model Context Protocol.

LangChain & LangGraph — install langchain-memstate for a drop-in LangGraph BaseStore, retriever, chat history, and agent tools. See the LangChain integration docs.

REST API is for backend services and custom applications like chatbot memory, knowledge bases, multi-agent orchestration, and any system that needs programmatic memory management.