# Lex

> Lex is an open-source MCP server for knowledge and memory. Local-first work memory for coding agents: decisions, blockers and next steps. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, self-hosted
- **Repository:** https://github.com/smartergpt/lex
- **MCP Registry name:** dev.smartergpt/lex
- **Categories:** [knowledge and memory](https://ai-powered.com/categories/knowledge-and-memory), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-18

## About

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.

## Features

- **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

## Install

### Claude Code (Terminal)

```sh
claude mcp add lex --env LEX_DATABASE_URL='<LEX_DATABASE_URL>' --env LEX_POSTGRES_PASSWORD='<LEX_POSTGRES_PASSWORD>' -- npx -y @smartergpt/lex-mcp
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "lex": {
      "command": "npx",
      "args": [
        "-y",
        "@smartergpt/lex-mcp"
      ],
      "env": {
        "LEX_DATABASE_URL": "<LEX_DATABASE_URL>",
        "LEX_POSTGRES_PASSWORD": "<LEX_POSTGRES_PASSWORD>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "lex": {
      "command": "npx",
      "args": [
        "-y",
        "@smartergpt/lex-mcp"
      ],
      "env": {
        "LEX_DATABASE_URL": "<LEX_DATABASE_URL>",
        "LEX_POSTGRES_PASSWORD": "<LEX_POSTGRES_PASSWORD>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```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>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "lex": {
      "command": "npx",
      "args": [
        "-y",
        "@smartergpt/lex-mcp"
      ],
      "env": {
        "LEX_DATABASE_URL": "<LEX_DATABASE_URL>",
        "LEX_POSTGRES_PASSWORD": "<LEX_POSTGRES_PASSWORD>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "lex": {
      "command": "npx",
      "args": [
        "-y",
        "@smartergpt/lex-mcp"
      ],
      "env": {
        "LEX_DATABASE_URL": "<LEX_DATABASE_URL>",
        "LEX_POSTGRES_PASSWORD": "<LEX_POSTGRES_PASSWORD>"
      }
    }
  }
}
```

## 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.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Context7](https://ai-powered.com/mcp/context7): Context7 is a freemium MCP server for developer tools.
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): Chrome DevTools MCP is an open-source MCP server for browser automation.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github-2): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [awesome-mcp-servers](https://ai-powered.com/mcp/awesome-mcp-servers-2): awesome-mcp-servers is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.

---
Source: https://ai-powered.com/mcp/lex-2
