Lex — Claude Code MCP server: what it does, how to install
Preserves decisions, blockers, and next steps across agent sessions without dumping conversation history.
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-mcpWhat Lex 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.
What it helps with
- 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 for the agent
- 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
How to install Lex
Platform CLI
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-mcpReplace <…> with your own values. 3 more environment variables are in the server README
Platform CLI
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-mcpReplace <…> with your own values. 3 more environment variables are in the server README
Config file
{
"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
Config file
{
"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
Platform CLI
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-mcpReplace <…> with your own values. 3 more environment variables are in the server README
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Lex
How do I install Lex in Claude Code?
Run `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`.
What does Lex store?
It records discrete checkpoints containing task summaries, module scopes, blockers, and next steps. It discards raw chat dialogs to keep prompt sizes bounded.
Which database does Lex use?
Local SQLite is the default storage engine. You can switch to PostgreSQL via the LEX_STORE environment variable when sharing memory across environments.