model2data-studio 0.3.0__tar.gz → 0.5.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.
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/PKG-INFO +109 -11
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/README.md +108 -10
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/model2data_studio/__init__.py +1 -1
- model2data_studio-0.5.0/model2data_studio/building.py +367 -0
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/model2data_studio/cli.py +233 -25
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/model2data_studio/client.py +46 -5
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/model2data_studio/mcp_server.py +297 -31
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/pyproject.toml +1 -1
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/server.json +9 -3
- model2data_studio-0.5.0/tests/test_building.py +635 -0
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/uv.lock +4 -4
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/.gitignore +0 -0
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/LICENSE +0 -0
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/model2data_studio/archive.py +0 -0
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/model2data_studio/export.py +0 -0
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/tests/test_cli.py +0 -0
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/tests/test_export.py +0 -0
- {model2data_studio-0.3.0 → model2data_studio-0.5.0}/tests/test_mcp_server.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: model2data-studio
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Generate a model2data studio project's data from the command line, so CI can rebuild fixtures instead of committing them.
|
|
5
5
|
Project-URL: Homepage, https://www.jbanalytica.com/model2data/
|
|
6
6
|
Project-URL: Studio, https://studio.jbanalytica.com
|
|
@@ -52,7 +52,10 @@ uvx model2data-studio --help
|
|
|
52
52
|
|
|
53
53
|
It needs an API key from a **Pro** account on the studio: see
|
|
54
54
|
[pricing](https://www.jbanalytica.com/model2data/pricing/). The client is MIT
|
|
55
|
-
licensed; the studio it talks to is not open source.
|
|
55
|
+
licensed; the studio it talks to is not open source. (To use the studio from
|
|
56
|
+
Claude or another MCP client without a key, see [the MCP
|
|
57
|
+
server](#the-mcp-server-generating-from-an-agent-instead-of-a-shell): the
|
|
58
|
+
studio's own endpoint needs only a sign-in.)
|
|
56
59
|
|
|
57
60
|
## Configuration
|
|
58
61
|
|
|
@@ -70,7 +73,9 @@ the account, so put it in your CI provider's secrets rather than in a file.
|
|
|
70
73
|
Leave the key's access on **Generate and export**, which is the default and
|
|
71
74
|
covers everything below: reading a project, generating, exporting. A key with
|
|
72
75
|
**Read only** access is refused by `generate` with a 403 saying so. **Generate
|
|
73
|
-
and save** adds writing the project back, which `push`
|
|
76
|
+
and save** adds writing the project back, which `push`, `project create`, `model push`,
|
|
77
|
+
`metrics push` and `dashboard push` need (`project create` also needs a key that is not
|
|
78
|
+
limited to one project) — for a
|
|
74
79
|
pipeline that pushes a model up rather than pulling data down — and **Full access** adds
|
|
75
80
|
deleting a project and managing its share links, which the CLI never does. A
|
|
76
81
|
key that leaks out of a CI log can only do what it was given.
|
|
@@ -86,10 +91,18 @@ model2data-studio generate --project <id> --out . --format dbt --adapter duckdb
|
|
|
86
91
|
|
|
87
92
|
model2data-studio push --project <id> shop.model2data.yml # save a model as the project's
|
|
88
93
|
|
|
94
|
+
model2data-studio project create Shop --model shop.model2data.yml --metrics shop.metrics.yml
|
|
95
|
+
model2data-studio model check shop.model2data.yml # exits 1 on an error; no key needed
|
|
96
|
+
model2data-studio model push <id> shop.model2data.yml # replace the model, keep the rest
|
|
97
|
+
model2data-studio model guide # how to write one: the model spec
|
|
98
|
+
|
|
89
99
|
model2data-studio metrics list --project ID # what each metric computes
|
|
90
100
|
model2data-studio metrics check --project shop.metrics.yml # exits 1 on an error, for CI
|
|
91
101
|
model2data-studio metrics values --project ID --seed 42 --as-of 2026-10-01
|
|
92
102
|
model2data-studio metrics suggest --project shop.model2data.yml -o shop.metrics.yml
|
|
103
|
+
model2data-studio metrics check shop.metrics.yml --model shop.model2data.yml # or --project <id>
|
|
104
|
+
model2data-studio metrics push <id> shop.metrics.yml # replace the metrics file, keep the rest
|
|
105
|
+
model2data-studio metrics guide # how to write one: the metrics spec
|
|
93
106
|
|
|
94
107
|
model2data-studio dashboard pull <id> --out dashboards/ # one <name>.dashboard.yml each
|
|
95
108
|
model2data-studio dashboard push <id> dashboards/*.dashboard.yml
|
|
@@ -200,7 +213,10 @@ runs on the free plan.
|
|
|
200
213
|
| | |
|
|
201
214
|
| --- | --- |
|
|
202
215
|
| `metrics list --project TARGET` | each metric's name, label, kind, what it computes, its filter and its date column; a metric the model implies rather than the file writes is marked `*` |
|
|
203
|
-
| `metrics check --project TARGET` | every issue as `file:line: error: path: message`, the shape a CI log viewer links; exits 1 on an error, 0 on warnings alone |
|
|
216
|
+
| `metrics check --project TARGET` | every issue as `file:line:column: error: path: message`, the shape a CI log viewer links; exits 1 on an error, 0 on warnings alone |
|
|
217
|
+
| `metrics check FILE.metrics.yml --model FILE` | the same, for a metrics file against a model file (YAML, JSON or DBML), wherever the two live; `--project ID` instead reads it against a saved project's model. Needs no key with `--model` |
|
|
218
|
+
| `metrics push PROJECT_ID FILE.metrics.yml` | checks the file against the project's model, then saves it as the project's metrics file, keeping the model, dashboards and settings; says which metrics were added and removed. Nothing is saved on an error |
|
|
219
|
+
| `metrics guide` | the guide to writing a metrics file, as markdown: the metrics spec, then what the studio adds (no key needed) |
|
|
204
220
|
| `metrics values --project TARGET` | generates the data (the same run `generate` makes with the same arguments) and prints each metric's known value. `--seed`, `--rows` and `--as-of` as for `generate`; `--by-month` adds each month; `--json` prints the values shaped like the export's `metric_values.json` (its `run` and `metrics`; the spec version and rounding note are the export's own) |
|
|
205
221
|
| `metrics suggest --project TARGET` | a metrics file of the metrics the model implies, to start one from: stdout, or `-o FILE` (`--force` to replace one) |
|
|
206
222
|
|
|
@@ -254,6 +270,40 @@ A dashboard file that names something the project does not have is still saved:
|
|
|
254
270
|
that is a warning, not an error, so a dashboard can be sketched before the
|
|
255
271
|
metric it needs exists.
|
|
256
272
|
|
|
273
|
+
## Building a project: model, metrics, dashboards
|
|
274
|
+
|
|
275
|
+
A whole project can be built from files, by a pipeline or an agent, without
|
|
276
|
+
opening the studio: a model (`<stem>.model2data.yml`, model2data's open
|
|
277
|
+
[model spec](https://github.com/JB-Analytica/model2data/blob/main/model2data/spec/README.md),
|
|
278
|
+
or DBML), a metrics file (the
|
|
279
|
+
[metrics spec](https://github.com/JB-Analytica/model2data/blob/main/model2data/spec/metrics/README.md))
|
|
280
|
+
and dashboard files. Each kind has a guide (the spec, served by the studio), a
|
|
281
|
+
check that says where each error is by line and column, and a save that checks
|
|
282
|
+
first and saves nothing on an error. Since 0.4.0.
|
|
283
|
+
|
|
284
|
+
| | |
|
|
285
|
+
| --- | --- |
|
|
286
|
+
| `project create NAME --model FILE [--metrics FILE]` | checks both, then creates the project (100 rows a table, seed 42, dates anchored on today) and prints its id and studio URL. The plan's project limit applies |
|
|
287
|
+
| `model check FILE` | every error and warning as `file:line:column: error: message`; exits 1 on an error. Needs no key |
|
|
288
|
+
| `model push PROJECT_ID FILE` | checks the model, then saves it as the project's model, keeping its metrics file, dashboards, settings and canvas; says how the tables changed, and whether the project's metrics file still reads against it |
|
|
289
|
+
| `model guide` | the guide to writing a model, as markdown (no key needed) |
|
|
290
|
+
|
|
291
|
+
DBML is saved as the model document it converts to, so the project generates
|
|
292
|
+
straight away. A save reads the project first and replaces only its own part;
|
|
293
|
+
if the project is saved elsewhere in between, it reads it again once rather
|
|
294
|
+
than writing over that save.
|
|
295
|
+
|
|
296
|
+
The order of work:
|
|
297
|
+
|
|
298
|
+
1. `model guide`, write `shop.model2data.yml`, `model check` it until it is clean.
|
|
299
|
+
2. `project create Shop --model shop.model2data.yml`: note the id it prints.
|
|
300
|
+
3. `metrics guide`, write `shop.metrics.yml`, `metrics check shop.metrics.yml --project <id>`.
|
|
301
|
+
4. `metrics push <id> shop.metrics.yml`, then `metrics values --project <id>` to see
|
|
302
|
+
that the numbers come out as intended.
|
|
303
|
+
5. `dashboard guide --project <id>`, write `sales.dashboard.yml`,
|
|
304
|
+
`dashboard check sales.dashboard.yml --project <id>`.
|
|
305
|
+
6. `dashboard push <id> sales.dashboard.yml`, and open the URL it prints.
|
|
306
|
+
|
|
257
307
|
## Regenerating dbt seeds in CI
|
|
258
308
|
|
|
259
309
|
```yaml
|
|
@@ -315,11 +365,44 @@ would compare against rows anchored on today and fail at the first midnight.
|
|
|
315
365
|
|
|
316
366
|
## The MCP server: generating from an agent instead of a shell
|
|
317
367
|
|
|
318
|
-
The same account, the same
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
368
|
+
The same account, the same API — for an agent rather than the terminal. The
|
|
369
|
+
studio is where a schema is *designed*, with a diagram and a preview to design
|
|
370
|
+
it against; the agent in your editor or chat is where the data is wanted, and
|
|
371
|
+
asking it for "two hundred believable orders from my webshop model" should not
|
|
372
|
+
mean pasting DBML into a chat.
|
|
373
|
+
|
|
374
|
+
There are two ways to connect, with the same tools behind both.
|
|
375
|
+
|
|
376
|
+
### One URL: the studio's own MCP endpoint
|
|
377
|
+
|
|
378
|
+
The studio serves these tools itself at `https://studio.jbanalytica.com/mcp`.
|
|
379
|
+
Add that URL to your MCP client and sign in to the studio in your browser when
|
|
380
|
+
it asks; there is no key to copy, nothing to install and no config file. It
|
|
381
|
+
works with a free account, within the free plan's limits.
|
|
382
|
+
|
|
383
|
+
- **Claude** (web, desktop and mobile): *Settings → Connectors → Add custom
|
|
384
|
+
connector*, paste `https://studio.jbanalytica.com/mcp`, then *Connect* and
|
|
385
|
+
approve the connection in the studio.
|
|
386
|
+
- **Claude Code**:
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
claude mcp add --transport http model2data-studio https://studio.jbanalytica.com/mcp
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
then run `/mcp` in Claude Code and pick the server to sign in.
|
|
393
|
+
- **Anything else** that speaks Streamable HTTP with OAuth: the same URL.
|
|
394
|
+
|
|
395
|
+
A connected app appears in the studio under *API keys* in the account menu,
|
|
396
|
+
marked *Connected app*; *Disconnect* there takes its access away at once. It can
|
|
397
|
+
read your projects, create them and save their models, metrics files and
|
|
398
|
+
dashboards, and generate previews and metric values. It cannot delete a project,
|
|
399
|
+
share one, or manage your keys. `write_data` is not offered there: a server on
|
|
400
|
+
the studio would write the files to the studio's disk, not yours.
|
|
401
|
+
|
|
402
|
+
### Local: this package, with an API key
|
|
403
|
+
|
|
404
|
+
For CI, for a self-hosted studio, or for writing fixtures straight to disk with
|
|
405
|
+
`write_data`, run the server from this package with an API key (Pro):
|
|
323
406
|
|
|
324
407
|
```bash
|
|
325
408
|
uvx --from 'model2data-studio[mcp]' model2data-studio mcp # the SDK is an extra, see below
|
|
@@ -351,7 +434,7 @@ and for anything that reads a JSON config (Claude Desktop, Cursor, Zed):
|
|
|
351
434
|
|
|
352
435
|
`MODEL2DATA_STUDIO_URL` works here too, for a self-hosted studio.
|
|
353
436
|
|
|
354
|
-
|
|
437
|
+
Nineteen tools (eighteen at the studio's own endpoint, which has no `write_data`):
|
|
355
438
|
|
|
356
439
|
| | |
|
|
357
440
|
| --- | --- |
|
|
@@ -362,12 +445,27 @@ Twelve tools:
|
|
|
362
445
|
| `write_data` | generate and write the files, as `generate --out` does |
|
|
363
446
|
| `list_metrics` | the project's metrics, a line each: what it computes, its filter, its date column |
|
|
364
447
|
| `metric_values` | each metric's known value over a generated run, overall and by month (`seed`, `rows`, `as_of` as for `preview_data`). Pro, bar a bundled example. |
|
|
448
|
+
| `get_model_guide` | how to write a model: the open model spec, then what the studio adds (no key needed) |
|
|
449
|
+
| `check_model` | a model's errors and warnings (YAML, JSON or DBML), each with its line and column, and what it holds (no key needed) |
|
|
450
|
+
| `create_project` | checks a model and, optionally, a metrics file, then creates a project from them; answers with its id and studio URL. Needs a key not limited to one project |
|
|
451
|
+
| `save_model` | checks a model, then makes it a project's model, keeping everything else; says how the tables changed |
|
|
452
|
+
| `get_metrics_guide` | how to write a metrics file: the open metrics spec, then what the studio adds (no key needed) |
|
|
453
|
+
| `check_metrics` | a metrics file's errors and warnings, against a project's model (`project_id`) or a model's text (`model_text`, no key needed), and the metrics it defines |
|
|
454
|
+
| `save_metrics` | checks a metrics file, then makes it a project's, keeping everything else; says which metrics were added and removed |
|
|
365
455
|
| `list_dashboards` | the project's dashboards, by name |
|
|
366
456
|
| `get_dashboard` | one dashboard file's text, to edit and save back |
|
|
367
457
|
| `get_dashboard_guide` | how to write a dashboard file: the open dashboard spec, then what the studio adds (no key needed); with `project_id`, ending with that project's metrics and columns |
|
|
368
458
|
| `check_dashboard` | a dashboard file's errors and warnings, each with its line and column, without saving (no key needed without `project_id`) |
|
|
369
459
|
| `save_dashboard` | checks a dashboard file, then creates or replaces it by name; a file with errors is not saved and the errors come back. Answers with the link to the project |
|
|
370
460
|
|
|
461
|
+
The server's instructions give an agent the order of work for building a
|
|
462
|
+
project from nothing: `get_model_guide` → write the model → `check_model` →
|
|
463
|
+
`create_project` → `get_metrics_guide` → write the metrics → `check_metrics` →
|
|
464
|
+
`save_metrics` → `metric_values` to sanity-check the numbers →
|
|
465
|
+
`get_dashboard_guide` → write a dashboard → `check_dashboard` →
|
|
466
|
+
`save_dashboard` → the studio URL (and share link) to open. Every check and save
|
|
467
|
+
is the studio's; the tools move text.
|
|
468
|
+
|
|
371
469
|
`preview_data` is the one worth having. An agent that can *read* generated rows
|
|
372
470
|
can act on them — write an assertion against them, notice that `shipped_at`
|
|
373
471
|
precedes `ordered_at`, spot a column coming out as placeholder sentences. It
|
|
@@ -411,7 +509,7 @@ workflow refuses a tag that disagrees with any of them), merge, then tag the
|
|
|
411
509
|
merge commit on `main` and push the tag:
|
|
412
510
|
|
|
413
511
|
```bash
|
|
414
|
-
git tag cli-v0.
|
|
512
|
+
git tag cli-v0.4.0 && git push origin cli-v0.4.0
|
|
415
513
|
```
|
|
416
514
|
|
|
417
515
|
`.github/workflows/release-cli.yml` runs the tests, builds, publishes to PyPI
|
|
@@ -23,7 +23,10 @@ uvx model2data-studio --help
|
|
|
23
23
|
|
|
24
24
|
It needs an API key from a **Pro** account on the studio: see
|
|
25
25
|
[pricing](https://www.jbanalytica.com/model2data/pricing/). The client is MIT
|
|
26
|
-
licensed; the studio it talks to is not open source.
|
|
26
|
+
licensed; the studio it talks to is not open source. (To use the studio from
|
|
27
|
+
Claude or another MCP client without a key, see [the MCP
|
|
28
|
+
server](#the-mcp-server-generating-from-an-agent-instead-of-a-shell): the
|
|
29
|
+
studio's own endpoint needs only a sign-in.)
|
|
27
30
|
|
|
28
31
|
## Configuration
|
|
29
32
|
|
|
@@ -41,7 +44,9 @@ the account, so put it in your CI provider's secrets rather than in a file.
|
|
|
41
44
|
Leave the key's access on **Generate and export**, which is the default and
|
|
42
45
|
covers everything below: reading a project, generating, exporting. A key with
|
|
43
46
|
**Read only** access is refused by `generate` with a 403 saying so. **Generate
|
|
44
|
-
and save** adds writing the project back, which `push`
|
|
47
|
+
and save** adds writing the project back, which `push`, `project create`, `model push`,
|
|
48
|
+
`metrics push` and `dashboard push` need (`project create` also needs a key that is not
|
|
49
|
+
limited to one project) — for a
|
|
45
50
|
pipeline that pushes a model up rather than pulling data down — and **Full access** adds
|
|
46
51
|
deleting a project and managing its share links, which the CLI never does. A
|
|
47
52
|
key that leaks out of a CI log can only do what it was given.
|
|
@@ -57,10 +62,18 @@ model2data-studio generate --project <id> --out . --format dbt --adapter duckdb
|
|
|
57
62
|
|
|
58
63
|
model2data-studio push --project <id> shop.model2data.yml # save a model as the project's
|
|
59
64
|
|
|
65
|
+
model2data-studio project create Shop --model shop.model2data.yml --metrics shop.metrics.yml
|
|
66
|
+
model2data-studio model check shop.model2data.yml # exits 1 on an error; no key needed
|
|
67
|
+
model2data-studio model push <id> shop.model2data.yml # replace the model, keep the rest
|
|
68
|
+
model2data-studio model guide # how to write one: the model spec
|
|
69
|
+
|
|
60
70
|
model2data-studio metrics list --project ID # what each metric computes
|
|
61
71
|
model2data-studio metrics check --project shop.metrics.yml # exits 1 on an error, for CI
|
|
62
72
|
model2data-studio metrics values --project ID --seed 42 --as-of 2026-10-01
|
|
63
73
|
model2data-studio metrics suggest --project shop.model2data.yml -o shop.metrics.yml
|
|
74
|
+
model2data-studio metrics check shop.metrics.yml --model shop.model2data.yml # or --project <id>
|
|
75
|
+
model2data-studio metrics push <id> shop.metrics.yml # replace the metrics file, keep the rest
|
|
76
|
+
model2data-studio metrics guide # how to write one: the metrics spec
|
|
64
77
|
|
|
65
78
|
model2data-studio dashboard pull <id> --out dashboards/ # one <name>.dashboard.yml each
|
|
66
79
|
model2data-studio dashboard push <id> dashboards/*.dashboard.yml
|
|
@@ -171,7 +184,10 @@ runs on the free plan.
|
|
|
171
184
|
| | |
|
|
172
185
|
| --- | --- |
|
|
173
186
|
| `metrics list --project TARGET` | each metric's name, label, kind, what it computes, its filter and its date column; a metric the model implies rather than the file writes is marked `*` |
|
|
174
|
-
| `metrics check --project TARGET` | every issue as `file:line: error: path: message`, the shape a CI log viewer links; exits 1 on an error, 0 on warnings alone |
|
|
187
|
+
| `metrics check --project TARGET` | every issue as `file:line:column: error: path: message`, the shape a CI log viewer links; exits 1 on an error, 0 on warnings alone |
|
|
188
|
+
| `metrics check FILE.metrics.yml --model FILE` | the same, for a metrics file against a model file (YAML, JSON or DBML), wherever the two live; `--project ID` instead reads it against a saved project's model. Needs no key with `--model` |
|
|
189
|
+
| `metrics push PROJECT_ID FILE.metrics.yml` | checks the file against the project's model, then saves it as the project's metrics file, keeping the model, dashboards and settings; says which metrics were added and removed. Nothing is saved on an error |
|
|
190
|
+
| `metrics guide` | the guide to writing a metrics file, as markdown: the metrics spec, then what the studio adds (no key needed) |
|
|
175
191
|
| `metrics values --project TARGET` | generates the data (the same run `generate` makes with the same arguments) and prints each metric's known value. `--seed`, `--rows` and `--as-of` as for `generate`; `--by-month` adds each month; `--json` prints the values shaped like the export's `metric_values.json` (its `run` and `metrics`; the spec version and rounding note are the export's own) |
|
|
176
192
|
| `metrics suggest --project TARGET` | a metrics file of the metrics the model implies, to start one from: stdout, or `-o FILE` (`--force` to replace one) |
|
|
177
193
|
|
|
@@ -225,6 +241,40 @@ A dashboard file that names something the project does not have is still saved:
|
|
|
225
241
|
that is a warning, not an error, so a dashboard can be sketched before the
|
|
226
242
|
metric it needs exists.
|
|
227
243
|
|
|
244
|
+
## Building a project: model, metrics, dashboards
|
|
245
|
+
|
|
246
|
+
A whole project can be built from files, by a pipeline or an agent, without
|
|
247
|
+
opening the studio: a model (`<stem>.model2data.yml`, model2data's open
|
|
248
|
+
[model spec](https://github.com/JB-Analytica/model2data/blob/main/model2data/spec/README.md),
|
|
249
|
+
or DBML), a metrics file (the
|
|
250
|
+
[metrics spec](https://github.com/JB-Analytica/model2data/blob/main/model2data/spec/metrics/README.md))
|
|
251
|
+
and dashboard files. Each kind has a guide (the spec, served by the studio), a
|
|
252
|
+
check that says where each error is by line and column, and a save that checks
|
|
253
|
+
first and saves nothing on an error. Since 0.4.0.
|
|
254
|
+
|
|
255
|
+
| | |
|
|
256
|
+
| --- | --- |
|
|
257
|
+
| `project create NAME --model FILE [--metrics FILE]` | checks both, then creates the project (100 rows a table, seed 42, dates anchored on today) and prints its id and studio URL. The plan's project limit applies |
|
|
258
|
+
| `model check FILE` | every error and warning as `file:line:column: error: message`; exits 1 on an error. Needs no key |
|
|
259
|
+
| `model push PROJECT_ID FILE` | checks the model, then saves it as the project's model, keeping its metrics file, dashboards, settings and canvas; says how the tables changed, and whether the project's metrics file still reads against it |
|
|
260
|
+
| `model guide` | the guide to writing a model, as markdown (no key needed) |
|
|
261
|
+
|
|
262
|
+
DBML is saved as the model document it converts to, so the project generates
|
|
263
|
+
straight away. A save reads the project first and replaces only its own part;
|
|
264
|
+
if the project is saved elsewhere in between, it reads it again once rather
|
|
265
|
+
than writing over that save.
|
|
266
|
+
|
|
267
|
+
The order of work:
|
|
268
|
+
|
|
269
|
+
1. `model guide`, write `shop.model2data.yml`, `model check` it until it is clean.
|
|
270
|
+
2. `project create Shop --model shop.model2data.yml`: note the id it prints.
|
|
271
|
+
3. `metrics guide`, write `shop.metrics.yml`, `metrics check shop.metrics.yml --project <id>`.
|
|
272
|
+
4. `metrics push <id> shop.metrics.yml`, then `metrics values --project <id>` to see
|
|
273
|
+
that the numbers come out as intended.
|
|
274
|
+
5. `dashboard guide --project <id>`, write `sales.dashboard.yml`,
|
|
275
|
+
`dashboard check sales.dashboard.yml --project <id>`.
|
|
276
|
+
6. `dashboard push <id> sales.dashboard.yml`, and open the URL it prints.
|
|
277
|
+
|
|
228
278
|
## Regenerating dbt seeds in CI
|
|
229
279
|
|
|
230
280
|
```yaml
|
|
@@ -286,11 +336,44 @@ would compare against rows anchored on today and fail at the first midnight.
|
|
|
286
336
|
|
|
287
337
|
## The MCP server: generating from an agent instead of a shell
|
|
288
338
|
|
|
289
|
-
The same account, the same
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
339
|
+
The same account, the same API — for an agent rather than the terminal. The
|
|
340
|
+
studio is where a schema is *designed*, with a diagram and a preview to design
|
|
341
|
+
it against; the agent in your editor or chat is where the data is wanted, and
|
|
342
|
+
asking it for "two hundred believable orders from my webshop model" should not
|
|
343
|
+
mean pasting DBML into a chat.
|
|
344
|
+
|
|
345
|
+
There are two ways to connect, with the same tools behind both.
|
|
346
|
+
|
|
347
|
+
### One URL: the studio's own MCP endpoint
|
|
348
|
+
|
|
349
|
+
The studio serves these tools itself at `https://studio.jbanalytica.com/mcp`.
|
|
350
|
+
Add that URL to your MCP client and sign in to the studio in your browser when
|
|
351
|
+
it asks; there is no key to copy, nothing to install and no config file. It
|
|
352
|
+
works with a free account, within the free plan's limits.
|
|
353
|
+
|
|
354
|
+
- **Claude** (web, desktop and mobile): *Settings → Connectors → Add custom
|
|
355
|
+
connector*, paste `https://studio.jbanalytica.com/mcp`, then *Connect* and
|
|
356
|
+
approve the connection in the studio.
|
|
357
|
+
- **Claude Code**:
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
claude mcp add --transport http model2data-studio https://studio.jbanalytica.com/mcp
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
then run `/mcp` in Claude Code and pick the server to sign in.
|
|
364
|
+
- **Anything else** that speaks Streamable HTTP with OAuth: the same URL.
|
|
365
|
+
|
|
366
|
+
A connected app appears in the studio under *API keys* in the account menu,
|
|
367
|
+
marked *Connected app*; *Disconnect* there takes its access away at once. It can
|
|
368
|
+
read your projects, create them and save their models, metrics files and
|
|
369
|
+
dashboards, and generate previews and metric values. It cannot delete a project,
|
|
370
|
+
share one, or manage your keys. `write_data` is not offered there: a server on
|
|
371
|
+
the studio would write the files to the studio's disk, not yours.
|
|
372
|
+
|
|
373
|
+
### Local: this package, with an API key
|
|
374
|
+
|
|
375
|
+
For CI, for a self-hosted studio, or for writing fixtures straight to disk with
|
|
376
|
+
`write_data`, run the server from this package with an API key (Pro):
|
|
294
377
|
|
|
295
378
|
```bash
|
|
296
379
|
uvx --from 'model2data-studio[mcp]' model2data-studio mcp # the SDK is an extra, see below
|
|
@@ -322,7 +405,7 @@ and for anything that reads a JSON config (Claude Desktop, Cursor, Zed):
|
|
|
322
405
|
|
|
323
406
|
`MODEL2DATA_STUDIO_URL` works here too, for a self-hosted studio.
|
|
324
407
|
|
|
325
|
-
|
|
408
|
+
Nineteen tools (eighteen at the studio's own endpoint, which has no `write_data`):
|
|
326
409
|
|
|
327
410
|
| | |
|
|
328
411
|
| --- | --- |
|
|
@@ -333,12 +416,27 @@ Twelve tools:
|
|
|
333
416
|
| `write_data` | generate and write the files, as `generate --out` does |
|
|
334
417
|
| `list_metrics` | the project's metrics, a line each: what it computes, its filter, its date column |
|
|
335
418
|
| `metric_values` | each metric's known value over a generated run, overall and by month (`seed`, `rows`, `as_of` as for `preview_data`). Pro, bar a bundled example. |
|
|
419
|
+
| `get_model_guide` | how to write a model: the open model spec, then what the studio adds (no key needed) |
|
|
420
|
+
| `check_model` | a model's errors and warnings (YAML, JSON or DBML), each with its line and column, and what it holds (no key needed) |
|
|
421
|
+
| `create_project` | checks a model and, optionally, a metrics file, then creates a project from them; answers with its id and studio URL. Needs a key not limited to one project |
|
|
422
|
+
| `save_model` | checks a model, then makes it a project's model, keeping everything else; says how the tables changed |
|
|
423
|
+
| `get_metrics_guide` | how to write a metrics file: the open metrics spec, then what the studio adds (no key needed) |
|
|
424
|
+
| `check_metrics` | a metrics file's errors and warnings, against a project's model (`project_id`) or a model's text (`model_text`, no key needed), and the metrics it defines |
|
|
425
|
+
| `save_metrics` | checks a metrics file, then makes it a project's, keeping everything else; says which metrics were added and removed |
|
|
336
426
|
| `list_dashboards` | the project's dashboards, by name |
|
|
337
427
|
| `get_dashboard` | one dashboard file's text, to edit and save back |
|
|
338
428
|
| `get_dashboard_guide` | how to write a dashboard file: the open dashboard spec, then what the studio adds (no key needed); with `project_id`, ending with that project's metrics and columns |
|
|
339
429
|
| `check_dashboard` | a dashboard file's errors and warnings, each with its line and column, without saving (no key needed without `project_id`) |
|
|
340
430
|
| `save_dashboard` | checks a dashboard file, then creates or replaces it by name; a file with errors is not saved and the errors come back. Answers with the link to the project |
|
|
341
431
|
|
|
432
|
+
The server's instructions give an agent the order of work for building a
|
|
433
|
+
project from nothing: `get_model_guide` → write the model → `check_model` →
|
|
434
|
+
`create_project` → `get_metrics_guide` → write the metrics → `check_metrics` →
|
|
435
|
+
`save_metrics` → `metric_values` to sanity-check the numbers →
|
|
436
|
+
`get_dashboard_guide` → write a dashboard → `check_dashboard` →
|
|
437
|
+
`save_dashboard` → the studio URL (and share link) to open. Every check and save
|
|
438
|
+
is the studio's; the tools move text.
|
|
439
|
+
|
|
342
440
|
`preview_data` is the one worth having. An agent that can *read* generated rows
|
|
343
441
|
can act on them — write an assertion against them, notice that `shipped_at`
|
|
344
442
|
precedes `ordered_at`, spot a column coming out as placeholder sentences. It
|
|
@@ -382,7 +480,7 @@ workflow refuses a tag that disagrees with any of them), merge, then tag the
|
|
|
382
480
|
merge commit on `main` and push the tag:
|
|
383
481
|
|
|
384
482
|
```bash
|
|
385
|
-
git tag cli-v0.
|
|
483
|
+
git tag cli-v0.4.0 && git push origin cli-v0.4.0
|
|
386
484
|
```
|
|
387
485
|
|
|
388
486
|
`.github/workflows/release-cli.yml` runs the tests, builds, publishes to PyPI
|