django-orm-lens
Static-analysis MCP server for Django models. 5 read-only tools for AI coding agents.
README
<div align="center">
<img src="media/hero.png" alt="Django ORM Lens β live sidebar and ER diagram for your Django models" width="100%"/>
<br/> <br/>
Django ORM Lens
See your entire Django schema β in your editor, in your terminal, and from your AI agent.
Every app. Every model. Every field. Every relationship. Grouped, navigable, and one keystroke away from a live ER diagram.
<br/>
<br/>
</div>
π― Pick your path
Django ORM Lens ships as three distributions on one core β pick the one that matches your workflow. Each takes under 60 seconds.
Editor user (VS Code / Cursor / Windsurf): install the extension β open any Django project β sidebar tree + ER diagram appear.
code --install-extension frowningdev.django-orm-lens
Terminal / CI user: install from PyPI β run django-orm-lens in any directory that contains Django apps.
pip install django-orm-lens
django-orm-lens # welcome + commands
django-orm-lens scan # scan cwd for apps and models
AI coding agent user (Cursor / Aider / Continue / Zed): install with MCP extras β add one JSON block to your client config.
pip install "django-orm-lens[mcp]"
Then the MCP config snippet in the Integrations section below. Point DJANGO_ORM_LENS_ROOT at your Django project's absolute path.
β‘ Install
VS Code / Cursor / Windsurf / any Code fork:
code --install-extension frowningdev.django-orm-lens
Or search Django ORM Lens in the Extensions view.
Terminal & AI coding agents:
pip install django-orm-lens # CLI only
pip install "django-orm-lens[mcp]" # + MCP server for AI agents
Requires Python 3.9+. Zero runtime dependencies for the CLI.
<br/>
π― The problem
You open a Django project. It has 20 apps. You need to answer a simple question:
"Which app owns the
Ordermodel, and how is it connected toUser?"
Today, that means: Ctrl+P, "models", scroll through 30 hits, open five files, Ctrl+F for class Order, read through 400 lines of ForeignKey('otherapp.Something') strings, try to remember what you learned two files ago.
Half a day gone. Every time. On every project.
<br/>
β¨ With Django ORM Lens
<table> <tr> <td width="50%" valign="top">
π A tree of everything
Every app β every model β every field β every Meta option. Grouped by application, sorted alphabetically, expandable.
Icons distinguish CharField from ForeignKey from ManyToManyField at a glance.
</td> <td width="50%" valign="top">
πΈοΈ A live ER diagram
One command opens a Mermaid entity-relationship diagram of your entire schema. Watch it redraw as you edit. Export to SVG.
ForeignKey, OneToOneField, and ManyToManyField become proper cardinality arrows.
</td> </tr> <tr> <td width="50%" valign="top">
π Hover for relations
Hover over ForeignKey('app.Model') in any Python file β a card pops up with the target model's fields, relations, and a "Jump to" link. No Ctrl+F, no file dialog.
</td> <td width="50%" valign="top">
π§ Jump-to-definition
Click any field in the tree β cursor lands on the exact line. Filter the tree by app or model name. Split models/ packages are fully supported.
</td> </tr> <tr> <td width="50%" valign="top">
β‘ Zero configuration
No DJANGO_SETTINGS_MODULE. No runserver. Parses models.py statically. Works with a broken venv, a missing dependency, or on someone else's laptop.
</td> <td width="50%" valign="top">
π¨ Native VS Code UI
Dark theme. Light theme. Your theme. Follows your icon theme, your font, your key bindings. Nothing garish, nothing branded.
</td> </tr> </table>
<br/>
πΈ What it looks like
<div align="center"> <img src="media/hero.png" alt="Django ORM Lens sidebar showing an app's models with fields, relations, and Meta options" width="90%"/> </div>
Also included in the extension:
- πΈοΈ Live ER diagram β Mermaid cardinality arrows, edge labels (
CASCADE,through Model,as related_name), theme-aware, one-click SVG export - π Hover cards β over any
ForeignKey('app.Model')orManyToManyField(...), with a one-click jump link - π§ CodeLens β above every
class Modelline: field count, relation count, and an Open ER diagram action - π¨ Named themes β
auto/default/dark/forest/neutralfor the diagram webview
<br/>
π€ For terminals and AI coding agents
The same parser that powers the VS Code extension ships as a standalone Python package β with an optional MCP (Model Context Protocol) server so any MCP-compatible AI agent can navigate your Django schema without importing Django or booting your app.
CLI
django-orm-lens scan -f json # every app, every model, every field
django-orm-lens describe blog.Post # one model in Markdown
django-orm-lens hover blog.Post # compact hover card
django-orm-lens list | fzf # flat app.Model β pipes anywhere
django-orm-lens er > schema.mmd # Mermaid ER diagram
Every command accepts --path <dir> and --exclude <glob>.
MCP server
Register it once with your agent and it exposes five read-only tools:
| Tool | Purpose |
|---|---|
list_apps |
Every Django app in the workspace with model counts |
list_models |
Flat app.Model list, optional app filter |
describe_model |
Full field / relation / Meta detail for one model |
find_relations |
Inbound + outbound relations for one model |
er_diagram |
Mermaid erDiagram for the whole workspace |
# Start it directly
django-orm-lens-mcp
# Or via the CLI subcommand
django-orm-lens mcp
Set DJANGO_ORM_LENS_ROOT=/abs/path/to/project to point it anywhere.
<br/>
π Integrations
| Client | How to enable | Status |
|---|---|---|
| VS Code | code --install-extension frowningdev.django-orm-lens |
β |
| Cursor | same VSIX + optional MCP entry in ~/.cursor/mcp.json |
β |
| Windsurf / VSCodium / any Code fork | install the VSIX from the Marketplace or GitHub Releases | β |
| Aider | add django-orm-lens-mcp to your mcp.json |
β (via MCP) |
| Continue.dev | register the MCP server in ~/.continue/config.json |
β (via MCP) |
| Zed | register the MCP server in Zed settings | β (via MCP) |
| Any MCP-compatible client | point command at django-orm-lens-mcp, set DJANGO_ORM_LENS_ROOT |
β |
| Discoverable via MCP Registry | official Model Context Protocol server directory | β |
| Plain terminal / CI | pip install django-orm-lens && django-orm-lens scan |
β |
Example: Cursor / any MCP client
{
"mcpServers": {
"django-orm-lens": {
"command": "django-orm-lens-mcp",
"env": { "DJANGO_ORM_LENS_ROOT": "/abs/path/to/your/project" }
}
}
}
<br/>
π Get started (30 seconds)
In VS Code:
code --install-extension frowningdev.django-orm-lens- Open a folder with a
manage.pyormodels.py - Click the Django ORM Lens icon in the activity bar
- Expand apps β models β fields
- Click the type-hierarchy icon at the top of the panel β ER diagram opens beside your code
In a terminal:
pip install django-orm-lens
cd my-django-project
django-orm-lens scan -f table
As an AI agent tool:
pip install "django-orm-lens[mcp]"
β¦then register django-orm-lens-mcp in your agent's MCP config (see the Integrations table above).
No settings screen. No sign-in. No telemetry.
<br/>
π― Who this is for
- Django developers joining a codebase with 10+ apps and getting lost in
models.pysprawl. - Contract / freelance engineers who need to grasp an unfamiliar Django project in the first hour, not the first week.
- Teams onboarding new hires who want a one-glance schema view without spinning up documentation infrastructure.
- AI-agent power users (Cursor / Aider / Claude Desktop / Zed / Continue) who need the agent to answer schema questions accurately β without giving it database credentials or booting Django.
- CI pipelines that verify schema shape (e.g. "did we accidentally break a
related_name?") without importing the project. - Solo indie devs on a broken venv or someone else's laptop β no
runserver, nomanage.py migrate, still works.
<br/>
πΊοΈ Market position
Django ORM Lens sits at the intersection of editor tooling and AI-agent tooling β a slot no existing package covers:
| Segment | Existing option | What it costs you |
|---|---|---|
| Boot-and-graph | django-extensions graph_models |
Requires Graphviz + Django settings + a working DB URL |
| Web-based viewer | django-schema-graph |
Requires a running Django server; hosts one more thing to break |
| Admin panel | Django Admin | Requires runserver + auth + database β great for data, not for architecture |
| Editor plugin | PyCharm's Django Structure | Locked to PyCharm; no CLI, no AI-agent story |
| MCP server | (none until now) | AI agents guess your schema from source, imperfectly |
Django ORM Lens is the only tool that ships three surfaces from one parser: a VS Code extension (any Code fork), a zero-dep CLI (terminals + CI), and an MCP server (AI agents). All static. All free. All MIT.
<br/>
π€ How is this different?
| Django ORM Lens | django-extensions graph_models |
django-schema-graph |
Django Admin | PyCharm Django Structure | |
|---|---|---|---|---|---|
| Works without a bootable Django project | β | β | β | β | β οΈ |
| Zero-install (no graphviz, no server) | β | β | β | β | β (needs PyCharm) |
| Works in VS Code / Cursor / any Code fork | β | β | β | β | β |
| Sidebar tree inside the editor | β | β | β | β | β |
| Live ER diagram | β | β | β | β | β |
Hover cards on ForeignKey |
β | β | β | β | β οΈ |
| CodeLens on model classes | β | β | β | β | β |
Split models/ package support |
β | β οΈ | β οΈ | β | β |
| CLI for terminal / CI | β | β οΈ | β | β | β |
| MCP server for AI agents | β | β | β | β | β |
| Discoverable in the MCP Registry | β | β | β | β | β |
| Free & open-source (MIT) | β | β | β | β | β (paid IDE) |
<br/>
βοΈ Configuration
The defaults are opinionated and sensible. If you need to tweak:
// .vscode/settings.json
{
"djangoOrmLens.excludeGlobs": [
"**/migrations/**",
"**/node_modules/**",
"**/venv/**",
"**/.venv/**",
"**/env/**"
],
"djangoOrmLens.autoRefresh": true
}
| Setting | Type | Default | What it does |
|---|---|---|---|
djangoOrmLens.excludeGlobs |
string[] |
See above | Glob patterns to skip when scanning |
djangoOrmLens.autoRefresh |
boolean |
true |
Rescan on models.py changes |
<br/>
π§ Commands
Open the command palette (Ctrl+Shift+P / Cmd+Shift+P) and type "Django ORM Lens":
| Command | What it does |
|---|---|
Django ORM Lens: Refresh |
Force-rescan the workspace |
Django ORM Lens: Show ER Diagram |
Open the Mermaid ER diagram side-by-side |
Django ORM Lens: Filter Models |
Filter the tree by app / model / field name |
Django ORM Lens: Clear Filter |
Restore the full tree |
Django ORM Lens: Jump to Model |
Programmatic β triggered by tree clicks and hover cards |
<br/>
πΊοΈ Roadmap
Shipped
- [x] Sidebar tree grouped by app
- [x] Live Mermaid ER diagram
- [x] Hover cards over
ForeignKey('app.Model') - [x] Filter tree by name
- [x] Split
models/package support - [x] Export ER diagram as SVG
- [x] Python CLI + MCP server for terminals and AI agents
- [x] Welcome view for empty workspaces
- [x] Path-safe jump-to-definition and sanitized hover markdown
- [x] v0.3.0 β CodeLens above each model class (
N fields Β· N relations Β· Open ER diagram) - [x] v0.3.0 β Edge labels on the diagram (
CASCADE,SET_NULL,PROTECT,related_name) - [x] v0.3.0 β Named color themes (
auto/default/dark/forest/neutral) - [x] v0.3.1 β
through_modelon M2M edges (contributed by @kingrubic) - [x] v0.3.1 β Listed in the official MCP Registry + Glama.ai
Next
- [ ] Zoom + minimap + auto-layout inside the webview (#4)
- [ ] ORM query autocomplete inside
.filter()/.exclude()/.annotate()(#3) - [ ] App / model toggle checkboxes to declutter huge schemas
Later
- [ ] Migration dependency graph
- [ ] Third-party field support (
django-mptt,django-taggit,django-model-utils) - [ ] JetBrains / PyCharm plugin (if there is demand)
Vote by π-ing the corresponding issue.
<br/>
β FAQ
<details> <summary><b>Do you send any of my code to a server?</b></summary> <br/> No. Every byte stays on your machine. The parser is pure TypeScript (extension) or pure Python (CLI). No LLM calls, no telemetry, no analytics, no error reporting. The Mermaid renderer runs inside VS Code's webview sandbox. </details>
<details> <summary><b>Does it work with Poetry / uv / conda / no venv at all?</b></summary> <br/> Yes. The extension reads Python source directly β it does not import Django and does not care what package manager you use. The CLI requires Python 3.9+, but that is it. </details>
<details> <summary><b>My models are split across multiple files inside a <code>models/</code> package. Does that work?</b></summary> <br/> Yes, since v0.2.0. Both the extension and the CLI walk <code>models/*.py</code> alongside classic <code>models.py</code>. </details>
<details> <summary><b>Can I use it with DRF serializers, Wagtail, Oscar, or third-party base models?</b></summary> <br/> Any class that looks like a Django model is picked up: subclasses of <code>models.Model</code>, abstract bases starting with <code>Abstract</code>, common mixins ending in <code>Mixin</code>, and known base names like <code>TimeStampedModel</code> or <code>PolymorphicModel</code>. Non-model classes (<code>ModelAdmin</code>, <code>ModelSerializer</code>, <code>Form</code>, <code>View</code>, <code>Manager</code>, β¦) are filtered out. </details>
<details> <summary><b>Which AI agents can use the MCP server?</b></summary> <br/> Any MCP-compatible client β Cursor, Aider, Continue.dev, Zed, and any other tool that speaks the protocol. Just point <code>command</code> at the installed <code>django-orm-lens-mcp</code> binary. See the <a href="#-integrations">Integrations</a> section. </details>
<details> <summary><b>Is there a JetBrains / PyCharm version?</b></summary> <br/> Not yet. PyCharm's Django Structure tool window is already good, so the value delta is smaller. If enough people ask, it becomes worth doing. </details>
<br/>
π Support
- π Bug reports β GitHub Issues (please include a minimal
models.pysnippet) - π‘ Feature requests / ideas β GitHub Discussions
- π Marketplace reviews β rate the extension (the fastest signal that keeps this project moving)
- π PyPI page β pypi.org/project/django-orm-lens
- π Sponsor β github.com/sponsors/FROWNINGdev
<br/>
π License
MIT Β© FROWNINGdev
<br/>
<div align="center">
Made for developers who care about their codebase.
Marketplace Β· PyPI Β· GitHub Β· Issues Β· Discussions Β· Sponsor
</div>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.