Lex
Local-first work memory for coding agents: decisions, blockers and next steps
- Pricing
- Open source
- Platforms
- CLI, self-hosted
- Runs
- Locally
- Version
- 4.4.4
- Listing updated
- today
Similar MCP servers
About Lex
Lex is an open-source MCP server for knowledge and memory. It runs locally on your machine and is started by your AI client.
Lex stores checkpoints called Frames instead of whole transcripts. A Frame records what changed, what mattered, what is blocked and what should happen next, so a fresh agent session can pick up without a human retelling the work. The README is explicit that a Frame is a deliberate handoff, not continuous recording.
The core loop is three commands: remember writes a checkpoint, recall finds it again by topic, and context turns matching Frames into a bounded, read-only bootstrap with a token cap. SQLite is the default store, kept under .smartergpt/lex in the project; PostgreSQL is offered when context must be shared across trusted hosts or workspaces.
Beyond memory, Lex can enforce repository policy, give nearby module context through Policy Neighborhoods, project canonical assistant instructions and keep typed Markdown knowledge snapshots. The MCP package, @smartergpt/lex-mcp, exposes this to assistants and reads its workspace root and store settings from environment variables. It needs Node.js 24 or newer. The README suggests a five-minute pilot with one non-sensitive checkpoint, and says Lex is a poor fit for short-lived work.
Install
Run in a terminal
claude mcp add lex --env LEX_DATABASE_URL='<LEX_DATABASE_URL>' --env LEX_POSTGRES_PASSWORD='<LEX_POSTGRES_PASSWORD>' -- npx -y @smartergpt/lex-mcpAdd to claude_desktop_config.json
{
"mcpServers": {
"lex": {
"command": "npx",
"args": [
"-y",
"@smartergpt/lex-mcp"
],
"env": {
"LEX_DATABASE_URL": "<LEX_DATABASE_URL>",
"LEX_POSTGRES_PASSWORD": "<LEX_POSTGRES_PASSWORD>"
}
}
}
}Add to ~/.cursor/mcp.json
{
"mcpServers": {
"lex": {
"command": "npx",
"args": [
"-y",
"@smartergpt/lex-mcp"
],
"env": {
"LEX_DATABASE_URL": "<LEX_DATABASE_URL>",
"LEX_POSTGRES_PASSWORD": "<LEX_POSTGRES_PASSWORD>"
}
}
}
}Add to .vscode/mcp.json
{
"servers": {
"lex": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@smartergpt/lex-mcp"
],
"env": {
"LEX_DATABASE_URL": "<LEX_DATABASE_URL>",
"LEX_POSTGRES_PASSWORD": "<LEX_POSTGRES_PASSWORD>"
}
}
}
}Add to ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"lex": {
"command": "npx",
"args": [
"-y",
"@smartergpt/lex-mcp"
],
"env": {
"LEX_DATABASE_URL": "<LEX_DATABASE_URL>",
"LEX_POSTGRES_PASSWORD": "<LEX_POSTGRES_PASSWORD>"
}
}
}
}Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"lex": {
"command": "npx",
"args": [
"-y",
"@smartergpt/lex-mcp"
],
"env": {
"LEX_DATABASE_URL": "<LEX_DATABASE_URL>",
"LEX_POSTGRES_PASSWORD": "<LEX_POSTGRES_PASSWORD>"
}
}
}
}Using several servers? Build one config file with the MCP config generator.
Configuration
LEX_WORKSPACE_ROOTProject root directory for Lex runtime discovery. Defaults to current working directory.LEX_STOREFrame-store backend: sqlite or postgres. Defaults to sqlite unless LEX_DATABASE_URL selects PostgreSQL.LEX_DB_PATHPath to SQLite database file. Defaults to .smartergpt/lex/memory.db under the project root.LEX_MEMORY_DBAlias for LEX_DB_PATH (backwards compatibility). Same behavior.LEX_DATABASE_URLPostgreSQL connection URL for the compatibility adapter. Treat as secret because it may contain credentials.LEX_POSTGRES_PASSWORDPostgreSQL password supplied separately when LEX_DATABASE_URL omits one.LEX_POSTGRES_POOL_MAXMaximum PostgreSQL compatibility-adapter pool size. Defaults to 10.LEX_DEBUGSet to any value to enable debug logging to stderr.
What it does
- Frames as checkpoints
- Records the decision, blockers and next action at a deliberate handoff point.
- Bounded context output
- Builds a prompt-safe, read-only bootstrap limited by a token budget.
- SQLite or PostgreSQL
- Stores locally by default and can use PostgreSQL for shared context.
- Policy checks
- Enforces repository boundaries and infers module scope from policy.
- Policy Neighborhoods
- Supplies context from modules near the one being worked on.
- Knowledge snapshots
- Derives KnowledgeFrame snapshots from typed Markdown project knowledge.
Good for
- Resume a coding session without re-explaining earlier decisions
- Hand work between agents with blockers and next steps recorded
- Keep a failed approach from being tried again
- Share agent context across trusted hosts via PostgreSQL
- Check an agent's changes against repository module boundaries
Pricing
Open source
Lex FAQ
Where is memory stored?
In a local SQLite file at .smartergpt/lex/memory.db by default; LEX_DB_PATH changes the path and PostgreSQL is available through LEX_DATABASE_URL.
What does it need to run?
Node.js 24 or newer. Linux glibc installs need glibc 2.35 or newer.
Does it store full conversations?
No. It stores deliberate Frames, not transcripts.
How do I try it safely?
The README's pilot writes one non-sensitive Frame to the local SQLite store, then recalls it in a fresh session.
When is it not useful?
For short-lived work, or where the repository already has an effective continuity system.
Is Lex free?
Yes. Lex is open source, so you can use and self-host it for free.
How do I add Lex to Claude Code?
Run this command in your terminal: claude mcp add lex --env LEX_DATABASE_URL='<LEX_DATABASE_URL>' --env LEX_POSTGRES_PASSWORD='<LEX_POSTGRES_PASSWORD>' -- npx -y @smartergpt/lex-mcp
What are the best alternatives to Lex?
The closest alternatives to Lex are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.
Where this comes from
- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.


