sdcmodeler 4.2.1__tar.gz → 4.3.1__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 (21) hide show
  1. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/PKG-INFO +2 -1
  2. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/README.md +1 -0
  3. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/pyproject.toml +1 -1
  4. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler/__init__.py +1 -1
  5. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler/mcp_server.py +50 -2
  6. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler.egg-info/PKG-INFO +2 -1
  7. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/tests/test_mcp_server.py +41 -1
  8. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/LICENSE +0 -0
  9. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/setup.cfg +0 -0
  10. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler/cli.py +0 -0
  11. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler/client.py +0 -0
  12. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler/pricing.py +0 -0
  13. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler.egg-info/SOURCES.txt +0 -0
  14. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler.egg-info/dependency_links.txt +0 -0
  15. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler.egg-info/entry_points.txt +0 -0
  16. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler.egg-info/requires.txt +0 -0
  17. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/src/sdcmodeler.egg-info/top_level.txt +0 -0
  18. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/tests/test_cli.py +0 -0
  19. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/tests/test_client.py +0 -0
  20. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/tests/test_pricing.py +0 -0
  21. {sdcmodeler-4.2.1 → sdcmodeler-4.3.1}/tests/test_registry_launch.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdcmodeler
3
- Version: 4.2.1
3
+ Version: 4.3.1
4
4
  Summary: The modeler's client for SDCStudio: search the catalog, estimate, assemble and publish SDC4 data models, generate applications; a CLI and an MCP server over one client
5
5
  Author: Axius SDC, Inc.
6
6
  License-Expression: Apache-2.0
@@ -110,6 +110,7 @@ A JSON-RPC 2.0 stdio server, no SDK, the way sdcvalidator and sdcgovernance are
110
110
  | `estimate_model` | what a tree would reuse, mint and cost; returns `estimate_id` | no |
111
111
  | `build_model` | assemble, publish and generate (or `publish: false` for a draft); needs the `estimate_id` the person saw; refuses past the key's limit | yes |
112
112
  | `job_status` | one job by id: status, step, cost so far, the model's links | no |
113
+ | `download_package` | a model's package ZIP with the key, including a model in a private project; builds a missing package first (free, once) unless `generate` is false | no |
113
114
  | `generate_app` | generate and download the application; needs `confirm_charge`; 1,500 credits the first time, free after | yes |
114
115
  | `wallet` | balance in credits and the key's policy | no |
115
116
 
@@ -84,6 +84,7 @@ A JSON-RPC 2.0 stdio server, no SDK, the way sdcvalidator and sdcgovernance are
84
84
  | `estimate_model` | what a tree would reuse, mint and cost; returns `estimate_id` | no |
85
85
  | `build_model` | assemble, publish and generate (or `publish: false` for a draft); needs the `estimate_id` the person saw; refuses past the key's limit | yes |
86
86
  | `job_status` | one job by id: status, step, cost so far, the model's links | no |
87
+ | `download_package` | a model's package ZIP with the key, including a model in a private project; builds a missing package first (free, once) unless `generate` is false | no |
87
88
  | `generate_app` | generate and download the application; needs `confirm_charge`; 1,500 credits the first time, free after | yes |
88
89
  | `wallet` | balance in credits and the key's policy | no |
89
90
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sdcmodeler"
7
- version = "4.2.1"
7
+ version = "4.3.1"
8
8
  description = "The modeler's client for SDCStudio: search the catalog, estimate, assemble and publish SDC4 data models, generate applications; a CLI and an MCP server over one client"
9
9
  license = "Apache-2.0"
10
10
  requires-python = ">=3.10"
@@ -17,7 +17,7 @@ servers: sdcvalidator validates, sdcgovernance governs, sdcreader reads,
17
17
  sdcmodeler models. It also names the concept SDCStudio already has: every user
18
18
  is a Modeler, and the Modeler's projects scope every call.
19
19
  """
20
- __version__ = "4.2.1"
20
+ __version__ = "4.3.1"
21
21
 
22
22
  from sdcmodeler.client import ( # noqa: E402
23
23
  AssemblyRefused,
@@ -157,6 +157,25 @@ TOOLS: list[dict[str, Any]] = [
157
157
  ),
158
158
  "inputSchema": {"type": "object", "properties": {"job_ct_id": {"type": "string"}}, "required": ["job_ct_id"]},
159
159
  },
160
+ {
161
+ "name": "download_package",
162
+ "description": (
163
+ "Download a model's package (the ZIP: schema, XML template and JSON instance of the "
164
+ "Governed Data Record, JSON-LD, HTML, RDF, SHACL, GQL) into the server's output directory, "
165
+ "with this key: it works for a model in a private project, such as the one build_model "
166
+ "just made, where get_model and the public catalog do not. When the model is published "
167
+ "and its package not yet built, it builds it first (free, once; it needs the right to "
168
+ "publish the model); generate false only downloads. Free."
169
+ ),
170
+ "inputSchema": {
171
+ "type": "object",
172
+ "properties": {
173
+ "ct_id": {"type": "string"},
174
+ "generate": {"type": "boolean", "default": True},
175
+ },
176
+ "required": ["ct_id"],
177
+ },
178
+ },
160
179
  {
161
180
  "name": "generate_app",
162
181
  "description": (
@@ -246,6 +265,14 @@ def _policy_or_none() -> dict | None:
246
265
  return None
247
266
 
248
267
 
268
+ def _problem_text(problem: Any) -> str:
269
+ """A problem from the server's estimate is ``{path, ct_id?, reason}``; one from the local walk is a string (4.3.1)."""
270
+ if isinstance(problem, dict):
271
+ ct_id = f" ({problem['ct_id']})" if problem.get("ct_id") else ""
272
+ return f"{problem.get('path', '')}{ct_id}: {problem.get('reason', '')}".strip(": ")
273
+ return str(problem)
274
+
275
+
249
276
  def _handle_build_model(args: dict) -> Any:
250
277
  estimate_id = _string(args, "estimate_id", required=True)
251
278
  title = _string(args, "title", required=True)
@@ -258,7 +285,7 @@ def _handle_build_model(args: dict) -> Any:
258
285
  "in this session; run estimate_model, show the person the cost, then build."
259
286
  )
260
287
  if current["problems"]:
261
- raise ValueError("The tree has problems: " + "; ".join(current["problems"]))
288
+ raise ValueError("The tree has problems: " + "; ".join(_problem_text(p) for p in current["problems"]))
262
289
  remaining = None
263
290
  if current.get("source") == "server" and (current.get("key") or {}).get("remaining_credits") is not None:
264
291
  remaining = current["key"]["remaining_credits"]
@@ -290,6 +317,25 @@ def _handle_job_status(args: dict) -> Any:
290
317
  return get_client().job_status(_string(args, "job_ct_id", required=True))
291
318
 
292
319
 
320
+ def _handle_download_package(args: dict) -> Any:
321
+ ct_id = _string(args, "ct_id", required=True)
322
+ generate = args.get("generate", True)
323
+ if not isinstance(generate, bool):
324
+ raise ValueError("`generate` must be a boolean.")
325
+ c = get_client()
326
+ built_now = False
327
+ try:
328
+ path = c.download_package(ct_id, _output_dir)
329
+ except SDCStudioError as exc:
330
+ # 404 until the package exists (and for a draft); a published model's package is built once, free.
331
+ if exc.status != 404 or not generate:
332
+ raise
333
+ c.generate_package(ct_id)
334
+ built_now = True
335
+ path = c.download_package(ct_id, _output_dir)
336
+ return {"path": str(path), "built_now": built_now}
337
+
338
+
293
339
  def _handle_generate_app(args: dict) -> Any:
294
340
  ct_id = _string(args, "ct_id", required=True)
295
341
  profile = _string(args, "profile", default="lightweight") or "lightweight"
@@ -316,6 +362,7 @@ TOOL_HANDLERS = {
316
362
  "estimate_model": _handle_estimate_model,
317
363
  "build_model": _handle_build_model,
318
364
  "job_status": _handle_job_status,
365
+ "download_package": _handle_download_package,
319
366
  "generate_app": _handle_generate_app,
320
367
  "wallet": _handle_wallet,
321
368
  }
@@ -364,7 +411,8 @@ def _handle_request(request: Any) -> dict | None:
364
411
  "The modeler's client for SDCStudio. Search the public catalog first and reuse published "
365
412
  "components; estimate before you build and show the person the cost; build only with the "
366
413
  "estimate_id you showed; prefer the model package over the generated application when the "
367
- "feature lives inside an existing application. A 402 means the person funds the wallet at "
414
+ "feature lives inside an existing application; fetch a model's package, including one you just built "
415
+ "in a private project, with download_package. A 402 means the person funds the wallet at "
368
416
  f"{get_client().base_url}/app/settings?tab=wallet; never try to pay. "
369
417
  + ("A key is configured, so building and downloading are available within its policy."
370
418
  if has_key else "No key is configured: the catalog and estimates work; building needs SDCSTUDIO_API_KEY.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdcmodeler
3
- Version: 4.2.1
3
+ Version: 4.3.1
4
4
  Summary: The modeler's client for SDCStudio: search the catalog, estimate, assemble and publish SDC4 data models, generate applications; a CLI and an MCP server over one client
5
5
  Author: Axius SDC, Inc.
6
6
  License-Expression: Apache-2.0
@@ -110,6 +110,7 @@ A JSON-RPC 2.0 stdio server, no SDK, the way sdcvalidator and sdcgovernance are
110
110
  | `estimate_model` | what a tree would reuse, mint and cost; returns `estimate_id` | no |
111
111
  | `build_model` | assemble, publish and generate (or `publish: false` for a draft); needs the `estimate_id` the person saw; refuses past the key's limit | yes |
112
112
  | `job_status` | one job by id: status, step, cost so far, the model's links | no |
113
+ | `download_package` | a model's package ZIP with the key, including a model in a private project; builds a missing package first (free, once) unless `generate` is false | no |
113
114
  | `generate_app` | generate and download the application; needs `confirm_charge`; 1,500 credits the first time, free after | yes |
114
115
  | `wallet` | balance in credits and the key's policy | no |
115
116
 
@@ -42,7 +42,7 @@ def test_initialize_and_tools_list():
42
42
  assert r["result"]["protocolVersion"] == "2025-06-18"
43
43
  assert "wallet" in r["result"]["instructions"]
44
44
  tools = rpc("tools/list")["result"]["tools"]
45
- assert [t["name"] for t in tools] == ["search_components", "list_models", "get_model", "estimate_model", "build_model", "job_status", "generate_app", "wallet"]
45
+ assert [t["name"] for t in tools] == ["search_components", "list_models", "get_model", "estimate_model", "build_model", "job_status", "download_package", "generate_app", "wallet"]
46
46
 
47
47
 
48
48
  def test_build_needs_the_estimate_the_person_saw(bound):
@@ -114,3 +114,43 @@ def test_build_model_passes_the_flags_and_names_what_to_poll(bound):
114
114
  sent = json.loads([c for c in bound.calls if c.url.path.endswith("/assemble/")][-1].content)
115
115
  assert sent["generate"] is False and "publish" not in sent
116
116
  assert built["requested"] == {"publish": True, "generate": False} and "j9" in built["next"]
117
+
118
+
119
+ def test_download_package_fetches_a_private_models_package_with_the_key(bound, tmp_path):
120
+ bound.on("GET", "/api/v1/dmgen/dms/m1/download_package/", body={"download_url": "https://storage.example/dm-m1.zip", "filename": "dm-m1.zip"})
121
+ bound.on("GET", "https://storage.example/dm-m1.zip", body=b"PK")
122
+ out, _ = call("download_package", {"ct_id": "m1"})
123
+ assert out == {"path": str(tmp_path / "dm-m1.zip"), "built_now": False} and (tmp_path / "dm-m1.zip").exists()
124
+ assert "authorization" not in bound.calls[-1].headers, "the storage pointer is followed without the key"
125
+
126
+
127
+ def test_download_package_builds_a_missing_package_first_unless_told_not_to(bound, tmp_path):
128
+ bound.on("GET", "/api/v1/dmgen/dms/m2/download_package/", status=404, body={"error": "No package"})
129
+ _, err = call("download_package", {"ct_id": "m2", "generate": False})
130
+ assert err and "404" in err
131
+
132
+ def built(_request):
133
+ bound.on("GET", "/api/v1/dmgen/dms/m2/download_package/", body=b"PK", headers={"content-disposition": 'attachment; filename="dm-m2.zip"'})
134
+ return {"success": True}
135
+
136
+ bound.on("POST", "/api/v1/dmgen/dms/m2/generate/", body=built)
137
+ out, _ = call("download_package", {"ct_id": "m2"})
138
+ assert out["built_now"] is True and (tmp_path / "dm-m2.zip").exists()
139
+
140
+
141
+ def test_a_problem_the_server_names_is_reported_and_nothing_is_built(bound):
142
+ """4.3.1: the server's estimate names problems as {path, ct_id, reason}; build_model joined them as strings
143
+ and failed with a TypeError, reported as a defect in this server instead of the problem."""
144
+ def server_estimate(request):
145
+ from sdcmodeler.pricing import estimate_tree
146
+ body = json.loads(request.content)
147
+ local = estimate_tree(body["data"], body["title"])
148
+ return {**local, "problems": [{"path": "data.components[0]", "ct_id": "abc123abc123abc123abc123",
149
+ "reason": "Component not found or not published"}],
150
+ "wallet": {"balance_credits": 10000, "can_pay": True}, "key": {"remaining_credits": 700, "within_limit": True}}
151
+ bound.on("POST", "/api/v1/dmgen/assemble/estimate/", body=server_estimate)
152
+ est, _ = call("estimate_model", {"title": "Vitals", "tree": TREE})
153
+ _, err = call("build_model", {"estimate_id": est["estimate_id"], "title": "Vitals", "tree": TREE})
154
+ assert "Component not found or not published" in err and "abc123abc123abc123abc123" in err
155
+ assert "defect" not in err
156
+ assert not any(c.url.path.endswith("/assemble/") for c in bound.calls)
File without changes
File without changes
File without changes