chewy-constellations 0.1.0__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.
Files changed (29) hide show
  1. chewy_constellations-0.1.0/PKG-INFO +371 -0
  2. chewy_constellations-0.1.0/README.md +350 -0
  3. chewy_constellations-0.1.0/constellations/__init__.py +37 -0
  4. chewy_constellations-0.1.0/constellations/cli.py +672 -0
  5. chewy_constellations-0.1.0/constellations/extractors/__init__.py +31 -0
  6. chewy_constellations-0.1.0/constellations/extractors/config.py +71 -0
  7. chewy_constellations-0.1.0/constellations/extractors/gradle.py +272 -0
  8. chewy_constellations-0.1.0/constellations/extractors/terraform.py +76 -0
  9. chewy_constellations-0.1.0/constellations/extractors/terraform_env.py +259 -0
  10. chewy_constellations-0.1.0/constellations/extractors/terraform_graph.py +470 -0
  11. chewy_constellations-0.1.0/constellations/indexing.py +192 -0
  12. chewy_constellations-0.1.0/constellations/mcp_server.py +713 -0
  13. chewy_constellations-0.1.0/constellations/merge.py +492 -0
  14. chewy_constellations-0.1.0/constellations/merging.py +141 -0
  15. chewy_constellations-0.1.0/constellations/models/__init__.py +24 -0
  16. chewy_constellations-0.1.0/constellations/models/base.py +5 -0
  17. chewy_constellations-0.1.0/constellations/models/enums.py +31 -0
  18. chewy_constellations-0.1.0/constellations/models/evidence.py +18 -0
  19. chewy_constellations-0.1.0/constellations/models/gradle.py +43 -0
  20. chewy_constellations-0.1.0/constellations/models/graph.py +68 -0
  21. chewy_constellations-0.1.0/constellations/models/terraform.py +99 -0
  22. chewy_constellations-0.1.0/constellations/neo4j_store.py +220 -0
  23. chewy_constellations-0.1.0/constellations/registry.py +302 -0
  24. chewy_constellations-0.1.0/constellations/utils/__init__.py +10 -0
  25. chewy_constellations-0.1.0/constellations/utils/graph_annotations.py +40 -0
  26. chewy_constellations-0.1.0/constellations/utils/naming.py +7 -0
  27. chewy_constellations-0.1.0/constellations/utils/repo_detector.py +27 -0
  28. chewy_constellations-0.1.0/docker-compose.yml +14 -0
  29. chewy_constellations-0.1.0/pyproject.toml +23 -0
@@ -0,0 +1,371 @@
1
+ Metadata-Version: 2.4
2
+ Name: chewy-constellations
3
+ Version: 0.1.0
4
+ Summary: Local Terraform infrastructure graph indexer for Constellations
5
+ Author: Andrew Nguyen
6
+ Author-email: anguyen7@chewy.com
7
+ Requires-Python: >=3.10,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Dist: PyYAML (>=6.0,<7.0)
15
+ Requires-Dist: mcp (>=1.9,<2.0)
16
+ Requires-Dist: neo4j (>=5.20,<6.0)
17
+ Requires-Dist: pydantic (>=2.8,<3.0)
18
+ Requires-Dist: tfparse (>=0.6.0)
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Constellations
22
+
23
+ Just as ancient navigators used constellations to understand the night sky,
24
+ Constellations maps relationships between infrastructure and code into a
25
+ connected graph that can be explored, queried, and understood. Each resource is
26
+ a star. Each dependency is a line. Together, they form a local map of the
27
+ system.
28
+
29
+ Constellations is local-first. A developer runs one local Neo4j server, indexes
30
+ one or more repositories into graph snapshots, merges those snapshots when
31
+ cross-repository relationships matter, and queries the graph through the CLI or
32
+ MCP.
33
+
34
+ ## What It Does
35
+
36
+ Constellations scans a service or infrastructure repository and creates a graph
37
+ fragment for that repo.
38
+
39
+ Current extraction supports:
40
+
41
+ - Terraform `aws_lambda_function`, `aws_sqs_queue`, and
42
+ `aws_lambda_event_source_mapping`
43
+ - Java Gradle repositories from `settings.gradle`, `settings.gradle.kts`,
44
+ `build.gradle`, and `build.gradle.kts`
45
+ - `Repository` and `CodeModule` nodes for Java modules
46
+ - `${ENV_VAR}` placeholders in base `application.yml` and `application.yaml`
47
+ - Lambda environment variables from Terraform
48
+ - Evidence on nodes and relationships, including file path and line numbers
49
+
50
+ Current merge behavior can derive cross-repository relationships such as:
51
+
52
+ - `SQSQueue -[:TRIGGERS]-> LambdaFunction`
53
+ - `LambdaFunction -[:RUNS_CODE]-> CodeModule`
54
+ - `CodeModule -[:WRITES_TO]-> SQSQueue`
55
+
56
+ The graph also preserves unresolved references and isolated nodes so users can
57
+ see where more repo context is needed.
58
+
59
+ ## Install
60
+
61
+ ```bash
62
+ pip install chewy-constellations
63
+ ```
64
+
65
+ For local development in this folder:
66
+
67
+ ```bash
68
+ pip install -r requirements.txt
69
+ ```
70
+
71
+ Or with Poetry:
72
+
73
+ ```bash
74
+ poetry install
75
+ ```
76
+
77
+ ## Core Workflow
78
+
79
+ 1. Start Neo4j once on the developer machine.
80
+ 2. Index each service or infrastructure repo into a local graph snapshot.
81
+ 3. Merge indexed snapshots when questions need cross-repo traversal.
82
+ 4. Write the merged graph to Neo4j with `--neo4j`.
83
+ 5. Run the MCP server and ask questions from an MCP client.
84
+
85
+ ## Local Neo4j
86
+
87
+ Start the local Neo4j server:
88
+
89
+ ```bash
90
+ constellations start
91
+ ```
92
+
93
+ Neo4j Browser:
94
+
95
+ ```text
96
+ http://localhost:7474
97
+ ```
98
+
99
+ Default local connection:
100
+
101
+ ```text
102
+ NEO4J_URI=bolt://localhost:7687
103
+ NEO4J_USERNAME=neo4j
104
+ NEO4J_PASSWORD=constellations
105
+ ```
106
+
107
+ Stop the local server:
108
+
109
+ ```bash
110
+ constellations stop
111
+ ```
112
+
113
+ ## Index A Repo
114
+
115
+ Run from a Terraform root or Java Gradle repository:
116
+
117
+ ```bash
118
+ constellations index
119
+ ```
120
+
121
+ You can also index a path without changing directories:
122
+
123
+ ```bash
124
+ constellations index --path ../aggregator/wizmo-aggregator-lambda-terraform/terraform
125
+ ```
126
+
127
+ Useful options:
128
+
129
+ ```bash
130
+ constellations index \
131
+ --repo wizmo-aggregator-lambda-terraform \
132
+ --graph aggregator-infra \
133
+ --service aggregator
134
+ ```
135
+
136
+ Force a repository type when auto-detection is not desired:
137
+
138
+ ```bash
139
+ constellations index --repo-type terraform
140
+ constellations index --repo-type java
141
+ ```
142
+
143
+ `index` writes repo-local artifacts:
144
+
145
+ ```text
146
+ .constellations/resources.json
147
+ .constellations/snapshot.json
148
+ .constellations/graphs.json
149
+ ```
150
+
151
+ - `resources.json` is the raw parsed input model.
152
+ - `snapshot.json` is the Constellations graph fragment with nodes, edges,
153
+ evidence, and unresolved references.
154
+ - `graphs.json` registers the snapshot locally and also updates the user-level
155
+ registry at `~/.constellations/graphs.json`.
156
+
157
+ To index and immediately write that graph fragment to Neo4j:
158
+
159
+ ```bash
160
+ constellations index --neo4j
161
+ ```
162
+
163
+ ## Inspect And Review
164
+
165
+ Inspect defaults to `.constellations/snapshot.json` in the current directory:
166
+
167
+ ```bash
168
+ constellations inspect
169
+ ```
170
+
171
+ It can also inspect a repository directory or a snapshot file:
172
+
173
+ ```bash
174
+ constellations inspect ../aggregator/wizmo-aggregator-lambda-terraform/terraform
175
+ constellations inspect ../aggregator/wizmo-aggregator-lambda-terraform/terraform/.constellations/snapshot.json
176
+ ```
177
+
178
+ Use inspection and the generated JSON to review:
179
+
180
+ - which nodes and relationships were created
181
+ - which source files and line numbers support each graph fact
182
+ - which references remain unresolved
183
+ - which nodes are isolated after merge
184
+ - which relationships were extracted directly versus resolved during merge
185
+
186
+ List registered local and global graphs:
187
+
188
+ ```bash
189
+ constellations graphs
190
+ constellations graphs --local
191
+ constellations graphs --global
192
+ ```
193
+
194
+ Assign aliases to registered graphs:
195
+
196
+ ```bash
197
+ constellations alias wizmo-consumers consumers-code
198
+ constellations alias wizmo-consumers-lambda-terraform consumers-infra
199
+ ```
200
+
201
+ ## Merge For Multi-Repo Questions
202
+
203
+ Single-repo indexing remains the base workflow. Multi-repo composition happens
204
+ by merging existing graph snapshots into a derived graph snapshot.
205
+
206
+ From a workspace directory, `merge` can discover one-level-deep snapshots:
207
+
208
+ ```bash
209
+ constellations merge
210
+ ```
211
+
212
+ It looks for:
213
+
214
+ ```text
215
+ ./*/.constellations/snapshot.json
216
+ ```
217
+
218
+ You can also pass repository directories:
219
+
220
+ ```bash
221
+ constellations merge \
222
+ ../api/wizmo-nebula2-terraform/terraform \
223
+ ../aggregator/wizmo-aggregator-lambda-terraform/terraform \
224
+ ../aggregator/wizmo-aggregator-lambda
225
+ ```
226
+
227
+ Or pass snapshot files directly:
228
+
229
+ ```bash
230
+ constellations merge \
231
+ ../api/wizmo-nebula2-terraform/terraform/.constellations/snapshot.json \
232
+ ../aggregator/wizmo-aggregator-lambda-terraform/terraform/.constellations/snapshot.json \
233
+ ../aggregator/wizmo-aggregator-lambda/.constellations/snapshot.json
234
+ ```
235
+
236
+ Or pass registered graph names and aliases:
237
+
238
+ ```bash
239
+ constellations merge consumers-code consumers-infra --graph wizmo
240
+ ```
241
+
242
+ When `--graph` or `--name` is omitted, the merged graph name defaults to:
243
+
244
+ ```text
245
+ merged_graph
246
+ ```
247
+
248
+ When `--output` is omitted, the merged snapshot is written to:
249
+
250
+ ```text
251
+ ~/.constellations/merged_graphs/<graph>.snapshot.json
252
+ ```
253
+
254
+ Write the merged graph to Neo4j so the MCP server can query it:
255
+
256
+ ```bash
257
+ constellations merge snapshot1.json snapshot2.json --neo4j
258
+ ```
259
+
260
+ Use a custom graph name when needed:
261
+
262
+ ```bash
263
+ constellations merge snapshot1.json snapshot2.json --graph wizmo-dev --neo4j
264
+ ```
265
+
266
+ Refresh a previously registered merged graph from the same source snapshots:
267
+
268
+ ```bash
269
+ constellations merge --refresh merged_graph --neo4j
270
+ ```
271
+
272
+ Merged graphs are registered in the current directory's
273
+ `.constellations/graphs.json` and in the user-level registry:
274
+
275
+ ```text
276
+ ~/.constellations/graphs.json
277
+ ```
278
+
279
+ ## Push An Existing Snapshot
280
+
281
+ `push` writes an existing snapshot into Neo4j. Use it when the snapshot already
282
+ exists and you do not need to rebuild it.
283
+
284
+ ```bash
285
+ constellations push
286
+ ```
287
+
288
+ `push` can also accept a repository directory or snapshot file:
289
+
290
+ ```bash
291
+ constellations push ../aggregator/wizmo-aggregator-lambda-terraform/terraform
292
+ constellations push ../aggregator/wizmo-aggregator-lambda-terraform/terraform/.constellations/snapshot.json
293
+ ```
294
+
295
+ The `--neo4j` flag is for commands that create snapshots, such as `index`,
296
+ `from-json`, and `merge`. The `push` command is already a Neo4j write.
297
+
298
+ ## MCP Server
299
+
300
+ Run the MCP server against the local Neo4j graph:
301
+
302
+ ```bash
303
+ constellations mcp --graph merged_graph
304
+ ```
305
+
306
+ If Neo4j contains exactly one Constellations graph, `--graph` can be omitted.
307
+ When multiple graphs exist, pass `--graph` to avoid ambiguity.
308
+
309
+ Useful connection options:
310
+
311
+ ```bash
312
+ constellations mcp \
313
+ --neo4j-uri bolt://localhost:7687 \
314
+ --neo4j-user neo4j \
315
+ --neo4j-password constellations \
316
+ --graph merged_graph
317
+ ```
318
+
319
+ ### Use With Codex
320
+
321
+ After installing the package and writing a graph to Neo4j, register the MCP
322
+ server in Codex. Codex starts stdio MCP servers from its config, so the server
323
+ does not need to be started separately in another terminal.
324
+
325
+ Add this to `~/.codex/config.toml`, or to a trusted project's
326
+ `.codex/config.toml`:
327
+
328
+ ```toml
329
+ [mcp_servers.constellations]
330
+ command = "constellations"
331
+ args = [
332
+ "mcp",
333
+ "--neo4j-uri", "bolt://localhost:7687",
334
+ "--neo4j-user", "neo4j",
335
+ "--neo4j-password", "constellations",
336
+ "--graph", "merged_graph",
337
+ ]
338
+ ```
339
+
340
+ Restart Codex or start a new Codex session after changing MCP config. In the
341
+ Codex CLI TUI, `/mcp` shows active MCP servers.
342
+
343
+ The MCP server exposes these tools:
344
+
345
+ - `list_graphs`: list Constellations graphs currently stored in Neo4j.
346
+ - `index_repo`: index a local Java or Terraform repository and optionally
347
+ write the indexed graph to Neo4j.
348
+ - `merge_graphs`: merge snapshot files, repository directories, registered
349
+ graph names, or aliases and optionally write the merged graph to Neo4j.
350
+ - `graph_summary`: summarize labels, edge types, repositories, and unresolved
351
+ references.
352
+ - `find_resources`: find nodes by text, label, isolated status, or inferred
353
+ relationships.
354
+ - `ask_graph`: answer a natural-language question with bounded Neo4j traversal
355
+ context.
356
+ - `readonly_cypher`: run a graph-scoped read-only Cypher query.
357
+
358
+ It also exposes resources:
359
+
360
+ ```text
361
+ constellations://graphs
362
+ constellations://graph/{graph}/summary
363
+ constellations://graph/{graph}/isolated
364
+ constellations://graph/{graph}/inferred
365
+ ```
366
+
367
+ ## Architecture
368
+
369
+ For model details, relationship derivation, saved-resource rebuilds, and current
370
+ scope, see [docs/architecture.md](docs/architecture.md).
371
+
@@ -0,0 +1,350 @@
1
+ # Constellations
2
+
3
+ Just as ancient navigators used constellations to understand the night sky,
4
+ Constellations maps relationships between infrastructure and code into a
5
+ connected graph that can be explored, queried, and understood. Each resource is
6
+ a star. Each dependency is a line. Together, they form a local map of the
7
+ system.
8
+
9
+ Constellations is local-first. A developer runs one local Neo4j server, indexes
10
+ one or more repositories into graph snapshots, merges those snapshots when
11
+ cross-repository relationships matter, and queries the graph through the CLI or
12
+ MCP.
13
+
14
+ ## What It Does
15
+
16
+ Constellations scans a service or infrastructure repository and creates a graph
17
+ fragment for that repo.
18
+
19
+ Current extraction supports:
20
+
21
+ - Terraform `aws_lambda_function`, `aws_sqs_queue`, and
22
+ `aws_lambda_event_source_mapping`
23
+ - Java Gradle repositories from `settings.gradle`, `settings.gradle.kts`,
24
+ `build.gradle`, and `build.gradle.kts`
25
+ - `Repository` and `CodeModule` nodes for Java modules
26
+ - `${ENV_VAR}` placeholders in base `application.yml` and `application.yaml`
27
+ - Lambda environment variables from Terraform
28
+ - Evidence on nodes and relationships, including file path and line numbers
29
+
30
+ Current merge behavior can derive cross-repository relationships such as:
31
+
32
+ - `SQSQueue -[:TRIGGERS]-> LambdaFunction`
33
+ - `LambdaFunction -[:RUNS_CODE]-> CodeModule`
34
+ - `CodeModule -[:WRITES_TO]-> SQSQueue`
35
+
36
+ The graph also preserves unresolved references and isolated nodes so users can
37
+ see where more repo context is needed.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ pip install chewy-constellations
43
+ ```
44
+
45
+ For local development in this folder:
46
+
47
+ ```bash
48
+ pip install -r requirements.txt
49
+ ```
50
+
51
+ Or with Poetry:
52
+
53
+ ```bash
54
+ poetry install
55
+ ```
56
+
57
+ ## Core Workflow
58
+
59
+ 1. Start Neo4j once on the developer machine.
60
+ 2. Index each service or infrastructure repo into a local graph snapshot.
61
+ 3. Merge indexed snapshots when questions need cross-repo traversal.
62
+ 4. Write the merged graph to Neo4j with `--neo4j`.
63
+ 5. Run the MCP server and ask questions from an MCP client.
64
+
65
+ ## Local Neo4j
66
+
67
+ Start the local Neo4j server:
68
+
69
+ ```bash
70
+ constellations start
71
+ ```
72
+
73
+ Neo4j Browser:
74
+
75
+ ```text
76
+ http://localhost:7474
77
+ ```
78
+
79
+ Default local connection:
80
+
81
+ ```text
82
+ NEO4J_URI=bolt://localhost:7687
83
+ NEO4J_USERNAME=neo4j
84
+ NEO4J_PASSWORD=constellations
85
+ ```
86
+
87
+ Stop the local server:
88
+
89
+ ```bash
90
+ constellations stop
91
+ ```
92
+
93
+ ## Index A Repo
94
+
95
+ Run from a Terraform root or Java Gradle repository:
96
+
97
+ ```bash
98
+ constellations index
99
+ ```
100
+
101
+ You can also index a path without changing directories:
102
+
103
+ ```bash
104
+ constellations index --path ../aggregator/wizmo-aggregator-lambda-terraform/terraform
105
+ ```
106
+
107
+ Useful options:
108
+
109
+ ```bash
110
+ constellations index \
111
+ --repo wizmo-aggregator-lambda-terraform \
112
+ --graph aggregator-infra \
113
+ --service aggregator
114
+ ```
115
+
116
+ Force a repository type when auto-detection is not desired:
117
+
118
+ ```bash
119
+ constellations index --repo-type terraform
120
+ constellations index --repo-type java
121
+ ```
122
+
123
+ `index` writes repo-local artifacts:
124
+
125
+ ```text
126
+ .constellations/resources.json
127
+ .constellations/snapshot.json
128
+ .constellations/graphs.json
129
+ ```
130
+
131
+ - `resources.json` is the raw parsed input model.
132
+ - `snapshot.json` is the Constellations graph fragment with nodes, edges,
133
+ evidence, and unresolved references.
134
+ - `graphs.json` registers the snapshot locally and also updates the user-level
135
+ registry at `~/.constellations/graphs.json`.
136
+
137
+ To index and immediately write that graph fragment to Neo4j:
138
+
139
+ ```bash
140
+ constellations index --neo4j
141
+ ```
142
+
143
+ ## Inspect And Review
144
+
145
+ Inspect defaults to `.constellations/snapshot.json` in the current directory:
146
+
147
+ ```bash
148
+ constellations inspect
149
+ ```
150
+
151
+ It can also inspect a repository directory or a snapshot file:
152
+
153
+ ```bash
154
+ constellations inspect ../aggregator/wizmo-aggregator-lambda-terraform/terraform
155
+ constellations inspect ../aggregator/wizmo-aggregator-lambda-terraform/terraform/.constellations/snapshot.json
156
+ ```
157
+
158
+ Use inspection and the generated JSON to review:
159
+
160
+ - which nodes and relationships were created
161
+ - which source files and line numbers support each graph fact
162
+ - which references remain unresolved
163
+ - which nodes are isolated after merge
164
+ - which relationships were extracted directly versus resolved during merge
165
+
166
+ List registered local and global graphs:
167
+
168
+ ```bash
169
+ constellations graphs
170
+ constellations graphs --local
171
+ constellations graphs --global
172
+ ```
173
+
174
+ Assign aliases to registered graphs:
175
+
176
+ ```bash
177
+ constellations alias wizmo-consumers consumers-code
178
+ constellations alias wizmo-consumers-lambda-terraform consumers-infra
179
+ ```
180
+
181
+ ## Merge For Multi-Repo Questions
182
+
183
+ Single-repo indexing remains the base workflow. Multi-repo composition happens
184
+ by merging existing graph snapshots into a derived graph snapshot.
185
+
186
+ From a workspace directory, `merge` can discover one-level-deep snapshots:
187
+
188
+ ```bash
189
+ constellations merge
190
+ ```
191
+
192
+ It looks for:
193
+
194
+ ```text
195
+ ./*/.constellations/snapshot.json
196
+ ```
197
+
198
+ You can also pass repository directories:
199
+
200
+ ```bash
201
+ constellations merge \
202
+ ../api/wizmo-nebula2-terraform/terraform \
203
+ ../aggregator/wizmo-aggregator-lambda-terraform/terraform \
204
+ ../aggregator/wizmo-aggregator-lambda
205
+ ```
206
+
207
+ Or pass snapshot files directly:
208
+
209
+ ```bash
210
+ constellations merge \
211
+ ../api/wizmo-nebula2-terraform/terraform/.constellations/snapshot.json \
212
+ ../aggregator/wizmo-aggregator-lambda-terraform/terraform/.constellations/snapshot.json \
213
+ ../aggregator/wizmo-aggregator-lambda/.constellations/snapshot.json
214
+ ```
215
+
216
+ Or pass registered graph names and aliases:
217
+
218
+ ```bash
219
+ constellations merge consumers-code consumers-infra --graph wizmo
220
+ ```
221
+
222
+ When `--graph` or `--name` is omitted, the merged graph name defaults to:
223
+
224
+ ```text
225
+ merged_graph
226
+ ```
227
+
228
+ When `--output` is omitted, the merged snapshot is written to:
229
+
230
+ ```text
231
+ ~/.constellations/merged_graphs/<graph>.snapshot.json
232
+ ```
233
+
234
+ Write the merged graph to Neo4j so the MCP server can query it:
235
+
236
+ ```bash
237
+ constellations merge snapshot1.json snapshot2.json --neo4j
238
+ ```
239
+
240
+ Use a custom graph name when needed:
241
+
242
+ ```bash
243
+ constellations merge snapshot1.json snapshot2.json --graph wizmo-dev --neo4j
244
+ ```
245
+
246
+ Refresh a previously registered merged graph from the same source snapshots:
247
+
248
+ ```bash
249
+ constellations merge --refresh merged_graph --neo4j
250
+ ```
251
+
252
+ Merged graphs are registered in the current directory's
253
+ `.constellations/graphs.json` and in the user-level registry:
254
+
255
+ ```text
256
+ ~/.constellations/graphs.json
257
+ ```
258
+
259
+ ## Push An Existing Snapshot
260
+
261
+ `push` writes an existing snapshot into Neo4j. Use it when the snapshot already
262
+ exists and you do not need to rebuild it.
263
+
264
+ ```bash
265
+ constellations push
266
+ ```
267
+
268
+ `push` can also accept a repository directory or snapshot file:
269
+
270
+ ```bash
271
+ constellations push ../aggregator/wizmo-aggregator-lambda-terraform/terraform
272
+ constellations push ../aggregator/wizmo-aggregator-lambda-terraform/terraform/.constellations/snapshot.json
273
+ ```
274
+
275
+ The `--neo4j` flag is for commands that create snapshots, such as `index`,
276
+ `from-json`, and `merge`. The `push` command is already a Neo4j write.
277
+
278
+ ## MCP Server
279
+
280
+ Run the MCP server against the local Neo4j graph:
281
+
282
+ ```bash
283
+ constellations mcp --graph merged_graph
284
+ ```
285
+
286
+ If Neo4j contains exactly one Constellations graph, `--graph` can be omitted.
287
+ When multiple graphs exist, pass `--graph` to avoid ambiguity.
288
+
289
+ Useful connection options:
290
+
291
+ ```bash
292
+ constellations mcp \
293
+ --neo4j-uri bolt://localhost:7687 \
294
+ --neo4j-user neo4j \
295
+ --neo4j-password constellations \
296
+ --graph merged_graph
297
+ ```
298
+
299
+ ### Use With Codex
300
+
301
+ After installing the package and writing a graph to Neo4j, register the MCP
302
+ server in Codex. Codex starts stdio MCP servers from its config, so the server
303
+ does not need to be started separately in another terminal.
304
+
305
+ Add this to `~/.codex/config.toml`, or to a trusted project's
306
+ `.codex/config.toml`:
307
+
308
+ ```toml
309
+ [mcp_servers.constellations]
310
+ command = "constellations"
311
+ args = [
312
+ "mcp",
313
+ "--neo4j-uri", "bolt://localhost:7687",
314
+ "--neo4j-user", "neo4j",
315
+ "--neo4j-password", "constellations",
316
+ "--graph", "merged_graph",
317
+ ]
318
+ ```
319
+
320
+ Restart Codex or start a new Codex session after changing MCP config. In the
321
+ Codex CLI TUI, `/mcp` shows active MCP servers.
322
+
323
+ The MCP server exposes these tools:
324
+
325
+ - `list_graphs`: list Constellations graphs currently stored in Neo4j.
326
+ - `index_repo`: index a local Java or Terraform repository and optionally
327
+ write the indexed graph to Neo4j.
328
+ - `merge_graphs`: merge snapshot files, repository directories, registered
329
+ graph names, or aliases and optionally write the merged graph to Neo4j.
330
+ - `graph_summary`: summarize labels, edge types, repositories, and unresolved
331
+ references.
332
+ - `find_resources`: find nodes by text, label, isolated status, or inferred
333
+ relationships.
334
+ - `ask_graph`: answer a natural-language question with bounded Neo4j traversal
335
+ context.
336
+ - `readonly_cypher`: run a graph-scoped read-only Cypher query.
337
+
338
+ It also exposes resources:
339
+
340
+ ```text
341
+ constellations://graphs
342
+ constellations://graph/{graph}/summary
343
+ constellations://graph/{graph}/isolated
344
+ constellations://graph/{graph}/inferred
345
+ ```
346
+
347
+ ## Architecture
348
+
349
+ For model details, relationship derivation, saved-resource rebuilds, and current
350
+ scope, see [docs/architecture.md](docs/architecture.md).