django-orm-lens 1.0.2__tar.gz → 1.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,191 +1,193 @@
1
- Metadata-Version: 2.4
2
- Name: django-orm-lens
3
- Version: 1.0.2
4
- Summary: Static analysis + MCP server for Django models. Sidebar tree, ER diagrams, and JSON output for terminals and AI coding agents.
5
- Author: frowningdev
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/FROWNINGdev/django-orm-lens
8
- Project-URL: Repository, https://github.com/FROWNINGdev/django-orm-lens
9
- Project-URL: Bug Tracker, https://github.com/FROWNINGdev/django-orm-lens/issues
10
- Project-URL: Changelog, https://github.com/FROWNINGdev/django-orm-lens/blob/main/CHANGELOG.md
11
- Project-URL: VS Code Marketplace, https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens
12
- Keywords: django,orm,models,er-diagram,mermaid,mcp,ai-agents,cursor,aider,code-analysis,static-analysis
13
- Classifier: Development Status :: 5 - Production/Stable
14
- Classifier: Environment :: Console
15
- Classifier: Framework :: Django
16
- Classifier: Framework :: Django :: 4.0
17
- Classifier: Framework :: Django :: 4.1
18
- Classifier: Framework :: Django :: 4.2
19
- Classifier: Framework :: Django :: 5.0
20
- Classifier: Framework :: Django :: 5.1
21
- Classifier: Intended Audience :: Developers
22
- Classifier: License :: OSI Approved :: MIT License
23
- Classifier: Operating System :: OS Independent
24
- Classifier: Programming Language :: Python
25
- Classifier: Programming Language :: Python :: 3
26
- Classifier: Programming Language :: Python :: 3 :: Only
27
- Classifier: Programming Language :: Python :: 3.9
28
- Classifier: Programming Language :: Python :: 3.10
29
- Classifier: Programming Language :: Python :: 3.11
30
- Classifier: Programming Language :: Python :: 3.12
31
- Classifier: Programming Language :: Python :: 3.13
32
- Classifier: Topic :: Software Development :: Documentation
33
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
34
- Classifier: Topic :: Utilities
35
- Classifier: Typing :: Typed
36
- Requires-Python: >=3.9
37
- Description-Content-Type: text/markdown
38
- Provides-Extra: mcp
39
- Requires-Dist: mcp>=1.0; extra == "mcp"
40
- Provides-Extra: dev
41
- Requires-Dist: pytest>=8; extra == "dev"
42
- Requires-Dist: ruff>=0.5; extra == "dev"
43
- Requires-Dist: mypy>=1.10; extra == "dev"
44
- Requires-Dist: build>=1.2; extra == "dev"
45
- Requires-Dist: twine>=5.1; extra == "dev"
46
-
47
- # django-orm-lens
48
-
49
- <!-- mcp-name: io.github.frowningdev/django-orm-lens -->
50
-
51
- **Static analysis + MCP server for Django models.** Terminal- and AI-agent-friendly.
52
-
53
- Ships with a zero-dependency parser, a JSON/Markdown/table CLI, and an optional
54
- MCP (Model Context Protocol) server so any AI coding agent — Cursor, Aider,
55
- Continue, and any other MCP client can navigate your Django schema without
56
- importing Django or spinning up your app.
57
-
58
- Companion to the [Django ORM Lens VS Code
59
- extension](https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens).
60
-
61
- ---
62
-
63
- ## Install
64
-
65
- ```bash
66
- # Core CLI (zero third-party deps)
67
- pip install django-orm-lens
68
-
69
- # With the MCP server (adds the `mcp` package)
70
- pip install "django-orm-lens[mcp]"
71
- ```
72
-
73
- Requires Python **3.9+**. Works on Linux, macOS, and Windows.
74
-
75
- ---
76
-
77
- ## CLI usage
78
-
79
- ```bash
80
- # Scan a Django project for models (JSON, Markdown, or table)
81
- django-orm-lens scan -f json
82
- django-orm-lens scan -f markdown
83
- django-orm-lens scan -f table
84
-
85
- # Describe one model
86
- django-orm-lens describe blog.Post
87
- django-orm-lens describe Post -f json
88
-
89
- # Compact hover card (great for pipeing into your editor)
90
- django-orm-lens hover blog.Post
91
-
92
- # Flat list — pipes into fzf, grep, etc.
93
- django-orm-lens list | fzf
94
-
95
- # Emit a Mermaid ER diagram
96
- django-orm-lens er > schema.mmd
97
- django-orm-lens er -o schema.mmd
98
- ```
99
-
100
- Every command accepts `--path <dir>` and repeatable `--exclude <glob>`. Defaults
101
- skip `migrations/`, `venv/`, `.venv/`, `env/`, and `node_modules/`.
102
-
103
- ---
104
-
105
- ## MCP server — for AI coding agents
106
-
107
- The MCP server exposes five read-only tools that any MCP-compatible agent can
108
- call while it edits your Django project:
109
-
110
- | Tool | Purpose |
111
- | --- | --- |
112
- | `list_apps` | Every Django app in the workspace with model counts |
113
- | `list_models` | Flat `app.Model` list, optional app filter |
114
- | `describe_model` | Full field / relation / Meta detail for one model |
115
- | `find_relations` | Inbound + outbound relations for one model |
116
- | `er_diagram` | Mermaid `erDiagram` string for the whole workspace |
117
-
118
- ### Start the server manually
119
-
120
- ```bash
121
- django-orm-lens-mcp # dedicated entry point
122
- # or
123
- django-orm-lens mcp # subcommand
124
- ```
125
-
126
- By default the server scans the current working directory. Override with
127
- `DJANGO_ORM_LENS_ROOT=/abs/path/to/project`.
128
-
129
- ### Register it with an agent
130
-
131
- **Cursor** add to `~/.cursor/mcp.json`:
132
-
133
- ```json
134
- {
135
- "mcpServers": {
136
- "django-orm-lens": {
137
- "command": "django-orm-lens-mcp",
138
- "env": { "DJANGO_ORM_LENS_ROOT": "/abs/path/to/your/project" }
139
- }
140
- }
141
- }
142
- ```
143
-
144
- **Aider / Continue.dev / Zed / any MCP client** — same shape, the tool is
145
- generic. Point `command` at the installed `django-orm-lens-mcp` binary and set
146
- the workspace root via env.
147
-
148
- ---
149
-
150
- ## Why?
151
-
152
- Django's ORM is Python, and Python is dynamic. AI agents that only see
153
- `models.py` as raw text miss:
154
-
155
- * which fields belong to which model;
156
- * the direction and cardinality of every relation;
157
- * what `Meta.ordering`, `unique_together`, and `constraints` actually contain;
158
- * which app owns which model when the project uses split `models/` packages.
159
-
160
- `django-orm-lens` gives them a **static, deterministic, JSON view** of the
161
- schema — no Django boot, no database, no side effects. And you get a nice CLI
162
- for humans too.
163
-
164
- ---
165
-
166
- ## Programmatic API
167
-
168
- ```python
169
- from django_orm_lens import scan_workspace
170
-
171
- index = scan_workspace(".")
172
- for app in index.apps:
173
- for model in app.models:
174
- print(f"{app.name}.{model.name} {len(model.fields)} fields")
175
-
176
- # The full parsed tree serialises to the same JSON schema the VS Code
177
- # extension emits, so tools can share it interchangeably.
178
- import json
179
- json.dumps(index.to_dict(), indent=2)
180
- ```
181
-
182
- ---
183
-
184
- ## Links
185
-
186
- * Repo: <https://github.com/FROWNINGdev/django-orm-lens>
187
- * Issues: <https://github.com/FROWNINGdev/django-orm-lens/issues>
188
- * Changelog: <https://github.com/FROWNINGdev/django-orm-lens/blob/main/CHANGELOG.md>
189
- * VS Code extension: <https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens>
190
-
191
- MIT licensed.
1
+ Metadata-Version: 2.4
2
+ Name: django-orm-lens
3
+ Version: 1.0.4
4
+ Summary: Static analysis + MCP server for Django models. Sidebar tree, ER diagrams, and JSON output for terminals and AI coding agents.
5
+ Author: frowningdev
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/FROWNINGdev/django-orm-lens
8
+ Project-URL: Repository, https://github.com/FROWNINGdev/django-orm-lens
9
+ Project-URL: Bug Tracker, https://github.com/FROWNINGdev/django-orm-lens/issues
10
+ Project-URL: Changelog, https://github.com/FROWNINGdev/django-orm-lens/blob/main/CHANGELOG.md
11
+ Project-URL: VS Code Marketplace, https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens
12
+ Keywords: django,orm,models,er-diagram,mermaid,mcp,ai-agents,cursor,aider,code-analysis,static-analysis
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Environment :: Console
15
+ Classifier: Framework :: Django
16
+ Classifier: Framework :: Django :: 4.0
17
+ Classifier: Framework :: Django :: 4.1
18
+ Classifier: Framework :: Django :: 4.2
19
+ Classifier: Framework :: Django :: 5.0
20
+ Classifier: Framework :: Django :: 5.1
21
+ Classifier: Intended Audience :: Developers
22
+ Classifier: License :: OSI Approved :: MIT License
23
+ Classifier: Operating System :: OS Independent
24
+ Classifier: Programming Language :: Python
25
+ Classifier: Programming Language :: Python :: 3
26
+ Classifier: Programming Language :: Python :: 3 :: Only
27
+ Classifier: Programming Language :: Python :: 3.9
28
+ Classifier: Programming Language :: Python :: 3.10
29
+ Classifier: Programming Language :: Python :: 3.11
30
+ Classifier: Programming Language :: Python :: 3.12
31
+ Classifier: Programming Language :: Python :: 3.13
32
+ Classifier: Topic :: Software Development :: Documentation
33
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
34
+ Classifier: Topic :: Utilities
35
+ Classifier: Typing :: Typed
36
+ Requires-Python: >=3.9
37
+ Description-Content-Type: text/markdown
38
+ Provides-Extra: mcp
39
+ Requires-Dist: mcp>=1.0; extra == "mcp"
40
+ Provides-Extra: dev
41
+ Requires-Dist: pytest>=8; extra == "dev"
42
+ Requires-Dist: ruff>=0.5; extra == "dev"
43
+ Requires-Dist: mypy>=1.10; extra == "dev"
44
+ Requires-Dist: build>=1.2; extra == "dev"
45
+ Requires-Dist: twine>=5.1; extra == "dev"
46
+
47
+ # django-orm-lens
48
+
49
+ <!-- mcp-name: io.github.FROWNINGdev/django-orm-lens -->
50
+
51
+ **Static analysis + MCP server for Django models.** Terminal- and AI-agent-friendly.
52
+
53
+ Listed in the official [MCP Registry](https://registry.modelcontextprotocol.io/servers/io.github.FROWNINGdev%2Fdjango-orm-lens) as `io.github.FROWNINGdev/django-orm-lens`.
54
+
55
+ Ships with a zero-dependency parser, a JSON/Markdown/table CLI, and an optional
56
+ MCP (Model Context Protocol) server so any AI coding agent — Cursor, Aider,
57
+ Continue, and any other MCP client — can navigate your Django schema without
58
+ importing Django or spinning up your app.
59
+
60
+ Companion to the [Django ORM Lens VS Code
61
+ extension](https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens).
62
+
63
+ ---
64
+
65
+ ## Install
66
+
67
+ ```bash
68
+ # Core CLI (zero third-party deps)
69
+ pip install django-orm-lens
70
+
71
+ # With the MCP server (adds the `mcp` package)
72
+ pip install "django-orm-lens[mcp]"
73
+ ```
74
+
75
+ Requires Python **3.9+**. Works on Linux, macOS, and Windows.
76
+
77
+ ---
78
+
79
+ ## CLI usage
80
+
81
+ ```bash
82
+ # Scan a Django project for models (JSON, Markdown, or table)
83
+ django-orm-lens scan -f json
84
+ django-orm-lens scan -f markdown
85
+ django-orm-lens scan -f table
86
+
87
+ # Describe one model
88
+ django-orm-lens describe blog.Post
89
+ django-orm-lens describe Post -f json
90
+
91
+ # Compact hover card (great for pipeing into your editor)
92
+ django-orm-lens hover blog.Post
93
+
94
+ # Flat list — pipes into fzf, grep, etc.
95
+ django-orm-lens list | fzf
96
+
97
+ # Emit a Mermaid ER diagram
98
+ django-orm-lens er > schema.mmd
99
+ django-orm-lens er -o schema.mmd
100
+ ```
101
+
102
+ Every command accepts `--path <dir>` and repeatable `--exclude <glob>`. Defaults
103
+ skip `migrations/`, `venv/`, `.venv/`, `env/`, and `node_modules/`.
104
+
105
+ ---
106
+
107
+ ## MCP server for AI coding agents
108
+
109
+ The MCP server exposes five read-only tools that any MCP-compatible agent can
110
+ call while it edits your Django project:
111
+
112
+ | Tool | Purpose |
113
+ | --- | --- |
114
+ | `list_apps` | Every Django app in the workspace with model counts |
115
+ | `list_models` | Flat `app.Model` list, optional app filter |
116
+ | `describe_model` | Full field / relation / Meta detail for one model |
117
+ | `find_relations` | Inbound + outbound relations for one model |
118
+ | `er_diagram` | Mermaid `erDiagram` string for the whole workspace |
119
+
120
+ ### Start the server manually
121
+
122
+ ```bash
123
+ django-orm-lens-mcp # dedicated entry point
124
+ # or
125
+ django-orm-lens mcp # subcommand
126
+ ```
127
+
128
+ By default the server scans the current working directory. Override with
129
+ `DJANGO_ORM_LENS_ROOT=/abs/path/to/project`.
130
+
131
+ ### Register it with an agent
132
+
133
+ **Cursor** — add to `~/.cursor/mcp.json`:
134
+
135
+ ```json
136
+ {
137
+ "mcpServers": {
138
+ "django-orm-lens": {
139
+ "command": "django-orm-lens-mcp",
140
+ "env": { "DJANGO_ORM_LENS_ROOT": "/abs/path/to/your/project" }
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ **Aider / Continue.dev / Zed / any MCP client** — same shape, the tool is
147
+ generic. Point `command` at the installed `django-orm-lens-mcp` binary and set
148
+ the workspace root via env.
149
+
150
+ ---
151
+
152
+ ## Why?
153
+
154
+ Django's ORM is Python, and Python is dynamic. AI agents that only see
155
+ `models.py` as raw text miss:
156
+
157
+ * which fields belong to which model;
158
+ * the direction and cardinality of every relation;
159
+ * what `Meta.ordering`, `unique_together`, and `constraints` actually contain;
160
+ * which app owns which model when the project uses split `models/` packages.
161
+
162
+ `django-orm-lens` gives them a **static, deterministic, JSON view** of the
163
+ schema — no Django boot, no database, no side effects. And you get a nice CLI
164
+ for humans too.
165
+
166
+ ---
167
+
168
+ ## Programmatic API
169
+
170
+ ```python
171
+ from django_orm_lens import scan_workspace
172
+
173
+ index = scan_workspace(".")
174
+ for app in index.apps:
175
+ for model in app.models:
176
+ print(f"{app.name}.{model.name} {len(model.fields)} fields")
177
+
178
+ # The full parsed tree serialises to the same JSON schema the VS Code
179
+ # extension emits, so tools can share it interchangeably.
180
+ import json
181
+ json.dumps(index.to_dict(), indent=2)
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Links
187
+
188
+ * Repo: <https://github.com/FROWNINGdev/django-orm-lens>
189
+ * Issues: <https://github.com/FROWNINGdev/django-orm-lens/issues>
190
+ * Changelog: <https://github.com/FROWNINGdev/django-orm-lens/blob/main/CHANGELOG.md>
191
+ * VS Code extension: <https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens>
192
+
193
+ MIT licensed.
@@ -1,9 +1,11 @@
1
1
  # django-orm-lens
2
2
 
3
- <!-- mcp-name: io.github.frowningdev/django-orm-lens -->
3
+ <!-- mcp-name: io.github.FROWNINGdev/django-orm-lens -->
4
4
 
5
5
  **Static analysis + MCP server for Django models.** Terminal- and AI-agent-friendly.
6
6
 
7
+ Listed in the official [MCP Registry](https://registry.modelcontextprotocol.io/servers/io.github.FROWNINGdev%2Fdjango-orm-lens) as `io.github.FROWNINGdev/django-orm-lens`.
8
+
7
9
  Ships with a zero-dependency parser, a JSON/Markdown/table CLI, and an optional
8
10
  MCP (Model Context Protocol) server so any AI coding agent — Cursor, Aider,
9
11
  Continue, and any other MCP client — can navigate your Django schema without
@@ -4,7 +4,7 @@ Terminal / editor-agnostic parser for Django models.py files.
4
4
  Ships a CLI and an optional MCP server for AI coding agents.
5
5
  """
6
6
 
7
- __version__ = "1.0.2"
7
+ __version__ = "1.0.4"
8
8
 
9
9
  from .models import ParsedApp, ParsedField, ParsedModel, WorkspaceIndex
10
10
  from .parser import parse_models_file, scan_workspace
@@ -40,6 +40,8 @@ class ParsedField:
40
40
  out["onDelete"] = self.on_delete
41
41
  if self.related_name is not None:
42
42
  out["relatedName"] = self.related_name
43
+ if self.through_model is not None:
44
+ out["throughModel"] = self.through_model
43
45
  return out
44
46
 
45
47
 
@@ -258,6 +258,8 @@ def parse_models_file(file_path: str, content: str) -> List[ParsedModel]:
258
258
  field.related_model = _extract_related(inner)
259
259
  field.on_delete = _extract_on_delete(inner)
260
260
  field.related_name = _extract_related_name(inner)
261
+ if ftype == "ManyToManyField":
262
+ field.through_model = _extract_through_model(inner)
261
263
  model.fields.append(field)
262
264
  j = end_idx + 1
263
265
  continue
@@ -1,191 +1,193 @@
1
- Metadata-Version: 2.4
2
- Name: django-orm-lens
3
- Version: 1.0.2
4
- Summary: Static analysis + MCP server for Django models. Sidebar tree, ER diagrams, and JSON output for terminals and AI coding agents.
5
- Author: frowningdev
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/FROWNINGdev/django-orm-lens
8
- Project-URL: Repository, https://github.com/FROWNINGdev/django-orm-lens
9
- Project-URL: Bug Tracker, https://github.com/FROWNINGdev/django-orm-lens/issues
10
- Project-URL: Changelog, https://github.com/FROWNINGdev/django-orm-lens/blob/main/CHANGELOG.md
11
- Project-URL: VS Code Marketplace, https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens
12
- Keywords: django,orm,models,er-diagram,mermaid,mcp,ai-agents,cursor,aider,code-analysis,static-analysis
13
- Classifier: Development Status :: 5 - Production/Stable
14
- Classifier: Environment :: Console
15
- Classifier: Framework :: Django
16
- Classifier: Framework :: Django :: 4.0
17
- Classifier: Framework :: Django :: 4.1
18
- Classifier: Framework :: Django :: 4.2
19
- Classifier: Framework :: Django :: 5.0
20
- Classifier: Framework :: Django :: 5.1
21
- Classifier: Intended Audience :: Developers
22
- Classifier: License :: OSI Approved :: MIT License
23
- Classifier: Operating System :: OS Independent
24
- Classifier: Programming Language :: Python
25
- Classifier: Programming Language :: Python :: 3
26
- Classifier: Programming Language :: Python :: 3 :: Only
27
- Classifier: Programming Language :: Python :: 3.9
28
- Classifier: Programming Language :: Python :: 3.10
29
- Classifier: Programming Language :: Python :: 3.11
30
- Classifier: Programming Language :: Python :: 3.12
31
- Classifier: Programming Language :: Python :: 3.13
32
- Classifier: Topic :: Software Development :: Documentation
33
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
34
- Classifier: Topic :: Utilities
35
- Classifier: Typing :: Typed
36
- Requires-Python: >=3.9
37
- Description-Content-Type: text/markdown
38
- Provides-Extra: mcp
39
- Requires-Dist: mcp>=1.0; extra == "mcp"
40
- Provides-Extra: dev
41
- Requires-Dist: pytest>=8; extra == "dev"
42
- Requires-Dist: ruff>=0.5; extra == "dev"
43
- Requires-Dist: mypy>=1.10; extra == "dev"
44
- Requires-Dist: build>=1.2; extra == "dev"
45
- Requires-Dist: twine>=5.1; extra == "dev"
46
-
47
- # django-orm-lens
48
-
49
- <!-- mcp-name: io.github.frowningdev/django-orm-lens -->
50
-
51
- **Static analysis + MCP server for Django models.** Terminal- and AI-agent-friendly.
52
-
53
- Ships with a zero-dependency parser, a JSON/Markdown/table CLI, and an optional
54
- MCP (Model Context Protocol) server so any AI coding agent — Cursor, Aider,
55
- Continue, and any other MCP client can navigate your Django schema without
56
- importing Django or spinning up your app.
57
-
58
- Companion to the [Django ORM Lens VS Code
59
- extension](https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens).
60
-
61
- ---
62
-
63
- ## Install
64
-
65
- ```bash
66
- # Core CLI (zero third-party deps)
67
- pip install django-orm-lens
68
-
69
- # With the MCP server (adds the `mcp` package)
70
- pip install "django-orm-lens[mcp]"
71
- ```
72
-
73
- Requires Python **3.9+**. Works on Linux, macOS, and Windows.
74
-
75
- ---
76
-
77
- ## CLI usage
78
-
79
- ```bash
80
- # Scan a Django project for models (JSON, Markdown, or table)
81
- django-orm-lens scan -f json
82
- django-orm-lens scan -f markdown
83
- django-orm-lens scan -f table
84
-
85
- # Describe one model
86
- django-orm-lens describe blog.Post
87
- django-orm-lens describe Post -f json
88
-
89
- # Compact hover card (great for pipeing into your editor)
90
- django-orm-lens hover blog.Post
91
-
92
- # Flat list — pipes into fzf, grep, etc.
93
- django-orm-lens list | fzf
94
-
95
- # Emit a Mermaid ER diagram
96
- django-orm-lens er > schema.mmd
97
- django-orm-lens er -o schema.mmd
98
- ```
99
-
100
- Every command accepts `--path <dir>` and repeatable `--exclude <glob>`. Defaults
101
- skip `migrations/`, `venv/`, `.venv/`, `env/`, and `node_modules/`.
102
-
103
- ---
104
-
105
- ## MCP server — for AI coding agents
106
-
107
- The MCP server exposes five read-only tools that any MCP-compatible agent can
108
- call while it edits your Django project:
109
-
110
- | Tool | Purpose |
111
- | --- | --- |
112
- | `list_apps` | Every Django app in the workspace with model counts |
113
- | `list_models` | Flat `app.Model` list, optional app filter |
114
- | `describe_model` | Full field / relation / Meta detail for one model |
115
- | `find_relations` | Inbound + outbound relations for one model |
116
- | `er_diagram` | Mermaid `erDiagram` string for the whole workspace |
117
-
118
- ### Start the server manually
119
-
120
- ```bash
121
- django-orm-lens-mcp # dedicated entry point
122
- # or
123
- django-orm-lens mcp # subcommand
124
- ```
125
-
126
- By default the server scans the current working directory. Override with
127
- `DJANGO_ORM_LENS_ROOT=/abs/path/to/project`.
128
-
129
- ### Register it with an agent
130
-
131
- **Cursor** add to `~/.cursor/mcp.json`:
132
-
133
- ```json
134
- {
135
- "mcpServers": {
136
- "django-orm-lens": {
137
- "command": "django-orm-lens-mcp",
138
- "env": { "DJANGO_ORM_LENS_ROOT": "/abs/path/to/your/project" }
139
- }
140
- }
141
- }
142
- ```
143
-
144
- **Aider / Continue.dev / Zed / any MCP client** — same shape, the tool is
145
- generic. Point `command` at the installed `django-orm-lens-mcp` binary and set
146
- the workspace root via env.
147
-
148
- ---
149
-
150
- ## Why?
151
-
152
- Django's ORM is Python, and Python is dynamic. AI agents that only see
153
- `models.py` as raw text miss:
154
-
155
- * which fields belong to which model;
156
- * the direction and cardinality of every relation;
157
- * what `Meta.ordering`, `unique_together`, and `constraints` actually contain;
158
- * which app owns which model when the project uses split `models/` packages.
159
-
160
- `django-orm-lens` gives them a **static, deterministic, JSON view** of the
161
- schema — no Django boot, no database, no side effects. And you get a nice CLI
162
- for humans too.
163
-
164
- ---
165
-
166
- ## Programmatic API
167
-
168
- ```python
169
- from django_orm_lens import scan_workspace
170
-
171
- index = scan_workspace(".")
172
- for app in index.apps:
173
- for model in app.models:
174
- print(f"{app.name}.{model.name} {len(model.fields)} fields")
175
-
176
- # The full parsed tree serialises to the same JSON schema the VS Code
177
- # extension emits, so tools can share it interchangeably.
178
- import json
179
- json.dumps(index.to_dict(), indent=2)
180
- ```
181
-
182
- ---
183
-
184
- ## Links
185
-
186
- * Repo: <https://github.com/FROWNINGdev/django-orm-lens>
187
- * Issues: <https://github.com/FROWNINGdev/django-orm-lens/issues>
188
- * Changelog: <https://github.com/FROWNINGdev/django-orm-lens/blob/main/CHANGELOG.md>
189
- * VS Code extension: <https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens>
190
-
191
- MIT licensed.
1
+ Metadata-Version: 2.4
2
+ Name: django-orm-lens
3
+ Version: 1.0.4
4
+ Summary: Static analysis + MCP server for Django models. Sidebar tree, ER diagrams, and JSON output for terminals and AI coding agents.
5
+ Author: frowningdev
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/FROWNINGdev/django-orm-lens
8
+ Project-URL: Repository, https://github.com/FROWNINGdev/django-orm-lens
9
+ Project-URL: Bug Tracker, https://github.com/FROWNINGdev/django-orm-lens/issues
10
+ Project-URL: Changelog, https://github.com/FROWNINGdev/django-orm-lens/blob/main/CHANGELOG.md
11
+ Project-URL: VS Code Marketplace, https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens
12
+ Keywords: django,orm,models,er-diagram,mermaid,mcp,ai-agents,cursor,aider,code-analysis,static-analysis
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Environment :: Console
15
+ Classifier: Framework :: Django
16
+ Classifier: Framework :: Django :: 4.0
17
+ Classifier: Framework :: Django :: 4.1
18
+ Classifier: Framework :: Django :: 4.2
19
+ Classifier: Framework :: Django :: 5.0
20
+ Classifier: Framework :: Django :: 5.1
21
+ Classifier: Intended Audience :: Developers
22
+ Classifier: License :: OSI Approved :: MIT License
23
+ Classifier: Operating System :: OS Independent
24
+ Classifier: Programming Language :: Python
25
+ Classifier: Programming Language :: Python :: 3
26
+ Classifier: Programming Language :: Python :: 3 :: Only
27
+ Classifier: Programming Language :: Python :: 3.9
28
+ Classifier: Programming Language :: Python :: 3.10
29
+ Classifier: Programming Language :: Python :: 3.11
30
+ Classifier: Programming Language :: Python :: 3.12
31
+ Classifier: Programming Language :: Python :: 3.13
32
+ Classifier: Topic :: Software Development :: Documentation
33
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
34
+ Classifier: Topic :: Utilities
35
+ Classifier: Typing :: Typed
36
+ Requires-Python: >=3.9
37
+ Description-Content-Type: text/markdown
38
+ Provides-Extra: mcp
39
+ Requires-Dist: mcp>=1.0; extra == "mcp"
40
+ Provides-Extra: dev
41
+ Requires-Dist: pytest>=8; extra == "dev"
42
+ Requires-Dist: ruff>=0.5; extra == "dev"
43
+ Requires-Dist: mypy>=1.10; extra == "dev"
44
+ Requires-Dist: build>=1.2; extra == "dev"
45
+ Requires-Dist: twine>=5.1; extra == "dev"
46
+
47
+ # django-orm-lens
48
+
49
+ <!-- mcp-name: io.github.FROWNINGdev/django-orm-lens -->
50
+
51
+ **Static analysis + MCP server for Django models.** Terminal- and AI-agent-friendly.
52
+
53
+ Listed in the official [MCP Registry](https://registry.modelcontextprotocol.io/servers/io.github.FROWNINGdev%2Fdjango-orm-lens) as `io.github.FROWNINGdev/django-orm-lens`.
54
+
55
+ Ships with a zero-dependency parser, a JSON/Markdown/table CLI, and an optional
56
+ MCP (Model Context Protocol) server so any AI coding agent — Cursor, Aider,
57
+ Continue, and any other MCP client — can navigate your Django schema without
58
+ importing Django or spinning up your app.
59
+
60
+ Companion to the [Django ORM Lens VS Code
61
+ extension](https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens).
62
+
63
+ ---
64
+
65
+ ## Install
66
+
67
+ ```bash
68
+ # Core CLI (zero third-party deps)
69
+ pip install django-orm-lens
70
+
71
+ # With the MCP server (adds the `mcp` package)
72
+ pip install "django-orm-lens[mcp]"
73
+ ```
74
+
75
+ Requires Python **3.9+**. Works on Linux, macOS, and Windows.
76
+
77
+ ---
78
+
79
+ ## CLI usage
80
+
81
+ ```bash
82
+ # Scan a Django project for models (JSON, Markdown, or table)
83
+ django-orm-lens scan -f json
84
+ django-orm-lens scan -f markdown
85
+ django-orm-lens scan -f table
86
+
87
+ # Describe one model
88
+ django-orm-lens describe blog.Post
89
+ django-orm-lens describe Post -f json
90
+
91
+ # Compact hover card (great for pipeing into your editor)
92
+ django-orm-lens hover blog.Post
93
+
94
+ # Flat list — pipes into fzf, grep, etc.
95
+ django-orm-lens list | fzf
96
+
97
+ # Emit a Mermaid ER diagram
98
+ django-orm-lens er > schema.mmd
99
+ django-orm-lens er -o schema.mmd
100
+ ```
101
+
102
+ Every command accepts `--path <dir>` and repeatable `--exclude <glob>`. Defaults
103
+ skip `migrations/`, `venv/`, `.venv/`, `env/`, and `node_modules/`.
104
+
105
+ ---
106
+
107
+ ## MCP server for AI coding agents
108
+
109
+ The MCP server exposes five read-only tools that any MCP-compatible agent can
110
+ call while it edits your Django project:
111
+
112
+ | Tool | Purpose |
113
+ | --- | --- |
114
+ | `list_apps` | Every Django app in the workspace with model counts |
115
+ | `list_models` | Flat `app.Model` list, optional app filter |
116
+ | `describe_model` | Full field / relation / Meta detail for one model |
117
+ | `find_relations` | Inbound + outbound relations for one model |
118
+ | `er_diagram` | Mermaid `erDiagram` string for the whole workspace |
119
+
120
+ ### Start the server manually
121
+
122
+ ```bash
123
+ django-orm-lens-mcp # dedicated entry point
124
+ # or
125
+ django-orm-lens mcp # subcommand
126
+ ```
127
+
128
+ By default the server scans the current working directory. Override with
129
+ `DJANGO_ORM_LENS_ROOT=/abs/path/to/project`.
130
+
131
+ ### Register it with an agent
132
+
133
+ **Cursor** — add to `~/.cursor/mcp.json`:
134
+
135
+ ```json
136
+ {
137
+ "mcpServers": {
138
+ "django-orm-lens": {
139
+ "command": "django-orm-lens-mcp",
140
+ "env": { "DJANGO_ORM_LENS_ROOT": "/abs/path/to/your/project" }
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ **Aider / Continue.dev / Zed / any MCP client** — same shape, the tool is
147
+ generic. Point `command` at the installed `django-orm-lens-mcp` binary and set
148
+ the workspace root via env.
149
+
150
+ ---
151
+
152
+ ## Why?
153
+
154
+ Django's ORM is Python, and Python is dynamic. AI agents that only see
155
+ `models.py` as raw text miss:
156
+
157
+ * which fields belong to which model;
158
+ * the direction and cardinality of every relation;
159
+ * what `Meta.ordering`, `unique_together`, and `constraints` actually contain;
160
+ * which app owns which model when the project uses split `models/` packages.
161
+
162
+ `django-orm-lens` gives them a **static, deterministic, JSON view** of the
163
+ schema — no Django boot, no database, no side effects. And you get a nice CLI
164
+ for humans too.
165
+
166
+ ---
167
+
168
+ ## Programmatic API
169
+
170
+ ```python
171
+ from django_orm_lens import scan_workspace
172
+
173
+ index = scan_workspace(".")
174
+ for app in index.apps:
175
+ for model in app.models:
176
+ print(f"{app.name}.{model.name} {len(model.fields)} fields")
177
+
178
+ # The full parsed tree serialises to the same JSON schema the VS Code
179
+ # extension emits, so tools can share it interchangeably.
180
+ import json
181
+ json.dumps(index.to_dict(), indent=2)
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Links
187
+
188
+ * Repo: <https://github.com/FROWNINGdev/django-orm-lens>
189
+ * Issues: <https://github.com/FROWNINGdev/django-orm-lens/issues>
190
+ * Changelog: <https://github.com/FROWNINGdev/django-orm-lens/blob/main/CHANGELOG.md>
191
+ * VS Code extension: <https://marketplace.visualstudio.com/items?itemName=frowningdev.django-orm-lens>
192
+
193
+ MIT licensed.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "django-orm-lens"
7
- version = "1.0.2"
7
+ version = "1.0.4"
8
8
  description = "Static analysis + MCP server for Django models. Sidebar tree, ER diagrams, and JSON output for terminals and AI coding agents."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+