# Lex

Preserves decisions, blockers, and next steps across agent sessions without dumping conversation history.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI
- Author: SmarterGPT
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/SmarterGPT/lex
- Updated: 2026-10-21
- HTML: https://affpapa.org/en/nevibecode/mcp/lex

## What it does

Lex captures deliberate work checkpoints called Frames rather than logging entire chat transcripts. Each checkpoint stores the reasoning behind an architectural choice, blockers, and concrete next actions. When a new session opens, the agent retrieves only the matching topic context, skipping repetitive code inspections and prompt reconstruction.

Storage defaults to local SQLite inside `.smartergpt/lex/`. Teams that need shared context across machines can configure PostgreSQL instead through environment variables.

Runtime requires Node.js 24 or newer, and Linux systems need glibc 2.35 or higher to run bundled SQLite binaries.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `LEX_WORKSPACE_ROOT`, `LEX_STORE`, `LEX_DB_PATH`, `LEX_MEMORY_DB`, `LEX_DATABASE_URL`, `LEX_POSTGRES_PASSWORD`, `LEX_POSTGRES_POOL_MAX`, `LEX_DEBUG` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env LEX_WORKSPACE_ROOT=<LEX_WORKSPACE_ROOT> --env LEX_STORE=<LEX_STORE> --env LEX_DB_PATH=<LEX_DB_PATH> --env LEX_MEMORY_DB=<LEX_MEMORY_DB> --env LEX_DATABASE_URL=<LEX_DATABASE_URL> --transport stdio lex -- npx -y @smartergpt/lex-mcp
```
Replace <…> with your own values. 3 more environment variables are in the server README

### Codex

**Platform CLI**
```bash
codex mcp add lex --env LEX_WORKSPACE_ROOT=<LEX_WORKSPACE_ROOT> --env LEX_STORE=<LEX_STORE> --env LEX_DB_PATH=<LEX_DB_PATH> --env LEX_MEMORY_DB=<LEX_MEMORY_DB> --env LEX_DATABASE_URL=<LEX_DATABASE_URL> -- npx -y @smartergpt/lex-mcp
```
Replace <…> with your own values. 3 more environment variables are in the server README

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "lex": {
            "command": "npx",
            "args": [
                "-y",
                "@smartergpt/lex-mcp"
            ],
            "env": {
                "LEX_WORKSPACE_ROOT": "<LEX_WORKSPACE_ROOT>",
                "LEX_STORE": "<LEX_STORE>",
                "LEX_DB_PATH": "<LEX_DB_PATH>",
                "LEX_MEMORY_DB": "<LEX_MEMORY_DB>",
                "LEX_DATABASE_URL": "<LEX_DATABASE_URL>"
            }
        }
    }
}
```
Replace <…> with your own values. 3 more environment variables are in the server README

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "lex": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "@smartergpt/lex-mcp"
            ],
            "env": {
                "LEX_WORKSPACE_ROOT": "<LEX_WORKSPACE_ROOT>",
                "LEX_STORE": "<LEX_STORE>",
                "LEX_DB_PATH": "<LEX_DB_PATH>",
                "LEX_MEMORY_DB": "<LEX_MEMORY_DB>",
                "LEX_DATABASE_URL": "<LEX_DATABASE_URL>"
            }
        }
    }
}
```
Replace <…> with your own values. 3 more environment variables are in the server README

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e LEX_WORKSPACE_ROOT=<LEX_WORKSPACE_ROOT> -e LEX_STORE=<LEX_STORE> -e LEX_DB_PATH=<LEX_DB_PATH> -e LEX_MEMORY_DB=<LEX_MEMORY_DB> -e LEX_DATABASE_URL=<LEX_DATABASE_URL> lex npx -y @smartergpt/lex-mcp
```
Replace <…> with your own values. 3 more environment variables are in the server README

## When to use it
- pass architectural decisions and blockers to future agent sessions
- record failed attempts so agents do not repeat them
- bound context retrieval to specific topics with token limits
- preserve work continuity across git branch switches

## Example prompts
- Save a checkpoint: token validation moved to middleware, blocked by PermissionService grant
- Recall stored Lex decisions about authentication before touching the middleware
- Retrieve Lex context for authentication bounded to 500 tokens

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 392262
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33989
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81163
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119231
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47577
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43902

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
