# ORM Lens MCP server

> Performs static analysis on Django and SQLAlchemy models to detect N+1 queries, migration risks, and schema relationships without a database.

- Repository: https://github.com/FROWNINGdev/django-orm-lens
- Page: https://hostedmcp.org/servers/frowningdev/django-orm-lens
- Transport: stdio
- Stars: 106
- License: MIT
- Latest version: 1.15.0

## Install

### Claude Code

```sh
claude mcp add django-orm-lens -- uvx django-orm-lens
```

### Cursor (`~/.cursor/mcp.json`)

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

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "django-orm-lens": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "django-orm-lens"
      ]
    }
  }
}
```

### Claude Desktop (`claude_desktop_config.json`)

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

### Codex (`~/.codex/config.toml`)

```toml
[mcp_servers.django-orm-lens]
command = "uvx"
args = ["django-orm-lens"]
```

### Gemini CLI (`~/.gemini/settings.json`)

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

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `ORM_LENS_ROOT` | no | no |  |

## FAQ

### Does it require a running database or environment?

No, it uses static parsing so it works without a database, a running server, or a working virtual environment.

### What can the MCP server do for AI agents?

The MCP server provides 14 read-only tools that allow AI agents to answer questions about your database schema using ground truth.

### Which ORMs are supported?

The tool supports both Django models and SQLAlchemy models.
