Orm Lens logo

Orm Lens

Read-only MCP tools for inspecting Django and SQLAlchemy schemas, relationships, N+1 risks, drift, and migration impact.

Install Orm Lens

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "orm-lens": {
      "command": "uvx",
      "args": [
        "orm-lens",
        "orm-lens-mcp"
      ],
      "env": {
        "ORM_LENS_ROOT": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

Claude Code command
claude mcp add --env ORM_LENS_ROOT=YOUR_VALUE_HERE --transport stdio orm-lens -- uvx orm-lens orm-lens-mcp

Run in your terminal. Add --scope project to share it with your team through .mcp.json.

We couldn’t confirm it starts correctly

The install command installed and started the server, which then stopped for configuration (such as an API key) that our sandbox does not have — expected for servers that connect to your account.

uvx orm-lens orm-lens-mcp

Process exited before answering initialize.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

orm-lens exposes static analysis of Django and SQLAlchemy projects through 14 read-only MCP tools. It parses Django models and migrations plus SQLAlchemy models and Alembic revisions without connecting to a database, starting the application, or requiring a working virtual environment. Use it when an AI agent needs grounded answers about model structure, relationships, N+1 patterns, schema drift, or migration risk.

Use cases

  • Inspect model relationships while working in an AI coding client
  • Find likely N+1 query loops and suggested eager-loading patterns
  • Review Django migrations and Alembic revisions for risk
  • Check source-defined schemas for drift without database access
  • Assess the impact of removing or changing a model field

Key features

  • 14 read-only MCP tools
  • Django model and migration analysis
  • SQLAlchemy and Alembic analysis
  • N+1 query detection
  • Schema drift and migration-risk checks
  • Static parsing without database or app startup

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

12/12 checks healthy over the last 27d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 10d ago via OSV.dev · orm-lens (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars115Stargazers on the source repository.
Last commit2d agoMost recent push to the default branch.
Install checkRunsOur sandbox started it; it then asked for an API key or config.

How Orm Lens works

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:

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

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Orm Lens

orm-lens is an MCP server that connects AI agents to Django and SQLAlchemy project source files. Its 14 read-only tools inspect models, relationships, migrations, and revisions to answer schema questions, detect likely N+1 loops, identify drift, and review migration risk without connecting to a database or booting the application.

Install it with `pip install "orm-lens[mcp]"`. Configure the server in your MCP client’s JSON settings and set `ORM_LENS_ROOT` to the project’s absolute path. The older `django-orm-lens` package name still installs orm-lens.

Yes, orm-lens is listed for Cursor use. Install the MCP extra, add the server to Cursor’s MCP configuration, and point `ORM_LENS_ROOT` at the project directory.

Yes, orm-lens analyzes migration source statically without connecting to a database or starting the application. It covers Django migrations and SQLAlchemy Alembic revisions, including migration-risk checks.

orm-lens supports Django and SQLAlchemy projects. Its static analysis covers Django models and migrations, plus SQLAlchemy models and Alembic revisions.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewOrm Lens AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/orm-lens?style=directory)](https://allmcps.com/mcp/orm-lens)
HTML Embed
<a href="https://allmcps.com/mcp/orm-lens"><img src="https://allmcps.com/api/badge/orm-lens?style=directory" alt="Orm Lens on AllMCPs" /></a>