# orm-lens [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/FROWNINGdev/orm-lens  
**GitHub Stars:** 115  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/orm-lens

## Description
ER diagrams, N+1 detection, schema drift & migration-risk linting for Django and SQLAlchemy (Alembic) — VS Code, CLI and MCP server. Static analysis: no database, no app boot. Free & MIT. Formerly django-orm-lens.

## Claude Desktop Quick Installation
Install path inferred — verify against the README before running it. Uses `uvx` (confidence: medium):

```json
"mcpServers": {
  "orm-lens": {
    "command": "uvx",
    "args": ["orm-lens","orm-lens-mcp"],
    "env": {
      "ORM_LENS_ROOT": ""
    }
  }
}
```

**Requires environment variables:** `ORM_LENS_ROOT` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What orm-lens does

orm-lens gives AI agents a read-only view of a project's ORM structure through MCP. It analyzes Django models and migrations, along with SQLAlchemy models and Alembic revisions, to answer schema questions from source files rather than from a live database or running application.

The package is designed for static analysis. It can inspect projects even when the database is unavailable, the Django settings module cannot be loaded, or the project's virtual environment is not working. Its analysis covers model and relationship structure, entity-relationship information, likely N+1 query loops, schema drift, and migration risk.

## How it works

Install the package with its MCP extra, then configure an MCP client to launch it against the project being analyzed. The project path is supplied through `ORM_LENS_ROOT`, which should contain the absolute path to the codebase.

The parser reads ORM and migration source directly. It does not boot Django, run `runserver`, connect to a database, or depend on application runtime state. MCP tools are read-only, so the server reports findings and structure without modifying models, migrations, or project files.

## Setup and configuration

Install the MCP-enabled package with:

```bash
pip install "orm-lens[mcp]"
```

Add the server to an MCP-capable client using its standard JSON configuration format and set `ORM_LENS_ROOT` to the project's absolute path. The same package also provides command-line analysis, but the MCP distribution is the relevant installation for agent access.

The project formerly used the `django-orm-lens` package name; installing that name still resolves to orm-lens. The server is MIT-licensed and does not require a database, account, or telemetry configuration.

## Tools and capabilities

The MCP interface provides 14 read-only tools for inspecting ORM projects. Supported analysis includes:

- Exploring Django and SQLAlchemy model structure
- Examining relationships and schema shape
- Generating or reviewing entity-relationship information
- Finding likely N+1 query loops and relevant eager-loading options
- Detecting schema drift
- Reviewing Django migration and Alembic revision risks
- Assessing the impact or blast radius of schema changes

The broader orm-lens package also offers terminal commands, SARIF output, pull-request annotations, pre-commit hooks, a GitHub Action, and editor features. Those surfaces are separate from the MCP tool interface but use the same parser core.

## Limitations and notes

Analysis is source-based rather than runtime-based. Results do not come from database contents, live query execution, or a booted application. The MCP tools are read-only, making them suitable for inspection and review rather than applying migrations or editing project files.

Support is focused on Django and SQLAlchemy ecosystems: Django migrations are analyzed alongside SQLAlchemy models and Alembic revisions. The MCP server should be pointed at the repository whose models and migration files the agent needs to inspect.

_Full upstream README: https://allmcps.com/mcp/orm-lens/readme_

