ORM Lens — Claude Code MCP server: what it does, how to install
ORM Lens — an MCP server for Claude Code, Cursor, Codex and other platforms that statically analyzes Django and SQLAlchemy models, migrations, and N+1 queries.
MIT ★ 114 updated 2026-11-16
claude mcp add orm-lens -- uvx orm-lensWhat ORM Lens does
ORM Lens parses model graphs, detects migration risks, and surfaces N+1 query patterns without booting a live database or virtual environment. It reads Django models and migrations alongside SQLAlchemy and Alembic revisions directly from source code.
The server runs via uvx or uv, providing read-only MCP tools to answer schema questions from ground truth. Point the environment variable ORM_LENS_ROOT at your project absolute path to get started.
The package is distributed under the MIT license with no paid tiers, subscriptions, or account requirements.
What it helps with
- detect N+1 query loops in codebase
- check Django and Alembic migrations for table locks
- analyze model graphs without a running database
- inspect database schema relationships statically
Example prompts for the agent
- Show all N+1 queries using orm-lens
- Find risky database migrations
- Explain the Django model schema over MCP
How to install ORM Lens
Platform CLI
claude mcp add orm-lens -- uvx orm-lensuvx runs the command named after the package; if the README names another one, use uvx --from orm-lens <command>
Platform CLI
codex mcp add orm-lens -- uvx orm-lensuvx runs the command named after the package; if the README names another one, use uvx --from orm-lens <command>
Config file
{
"mcpServers": {
"orm-lens": {
"command": "uvx",
"args": [
"orm-lens"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from orm-lens <command>
Config file
{
"servers": {
"orm-lens": {
"type": "stdio",
"command": "uvx",
"args": [
"orm-lens"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from orm-lens <command>
Platform CLI
gemini mcp add orm-lens uvx orm-lensuvx runs the command named after the package; if the README names another one, use uvx --from orm-lens <command>
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 ORM Lens
How to install ORM Lens in Claude Code?
Run the command claude mcp add orm-lens -- uvx orm-lens in your terminal.
What does ORM Lens do?
It performs static analysis on Django and SQLAlchemy models, migrations, and queries without booting a database.
What is needed to run ORM Lens?
You need Python, uvx, and an absolute path to your target project configured via ORM_LENS_ROOT.