# ORM Lens

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.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 114 repo stars
- Author: FROWNINGdev
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/FROWNINGdev/orm-lens
- Updated: 2026-11-16
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/mcp/orm-lens

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

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add orm-lens -- uvx orm-lens
```
uvx runs the command named after the package; if the README names another one, use uvx --from orm-lens <command>

### Codex

**Platform CLI**
```bash
codex mcp add orm-lens -- uvx orm-lens
```
uvx runs the command named after the package; if the README names another one, use uvx --from orm-lens <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "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>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "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>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add orm-lens uvx orm-lens
```
uvx runs the command named after the package; if the README names another one, use uvx --from orm-lens <command>

## When to use it
- 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
- Show all N+1 queries using orm-lens
- Find risky database migrations
- Explain the Django model schema over MCP

## Similar
- [Django ORM Lens](https://affpapa.org/en/nevibecode/mcp/django-orm-lens.md) — MCP server · ★ 96 repo stars
- [SQLAlchemy ORM Expert](https://affpapa.org/en/nevibecode/skills/sqlalchemy-orm-expert.md) — skill · 472 installs
- [django-orm-patterns](https://affpapa.org/en/nevibecode/skills/django-orm-patterns.md) — skill · 136 installs
- [django-orm](https://affpapa.org/en/nevibecode/rules/django-orm.md) — rule · ★ 3589 repo stars
- [sqlalchemy-alembic-expert-best-practices-code-review](https://affpapa.org/en/nevibecode/skills/sqlalchemy-alembic-expert-best-practices-code-review.md) — skill · 2200 installs
- [alembic](https://affpapa.org/en/nevibecode/skills/alembic.md) — skill · 645 installs

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