sdcmodeler 4.0.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.
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 Semantic Data Charter Foundation
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: sdcmodeler
3
+ Version: 4.0.0
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
+ Author: Axius SDC, Inc.
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Repository, https://github.com/Axius-SDC/sdcmodeler
8
+ Project-URL: Documentation, https://axius-sdc.com/docs/
9
+ Project-URL: Issues, https://github.com/Axius-SDC/sdcmodeler/issues
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: httpx>=0.27
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=8; extra == "dev"
24
+ Requires-Dist: pytest-cov; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # sdcmodeler
28
+
29
+ <!-- mcp-name: io.github.Axius-SDC/sdcmodeler -->
30
+
31
+ **The modeler's client for SDCStudio.** Search the public catalog, estimate, assemble and publish an SDC4 data model, generate its package and an application. A Python client with httpx as its only dependency, a CLI, and `sdcmodeler mcp`, an MCP server for any agent.
32
+
33
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
34
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
35
+
36
+ ## Why
37
+
38
+ An agent that builds a feature decides a data model at that moment. With sdcmodeler the data is modeled in SDC by default: the agent searches the catalog first, reuses published components wherever one fits, mints only what is new, publishes the model, and takes the package. The result is interoperable because it is composed from shared, published components, and verifiable because every record validates against a published schema.
39
+
40
+ The name follows the role pattern of the other Semantic Data Charter servers: sdcvalidator validates, sdcgovernance governs, sdcreader reads, sdcmodeler models. It also names what SDCStudio calls every user: a Modeler.
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install sdcmodeler
46
+ ```
47
+
48
+ The catalog and estimates need no account. Building needs an SDCStudio API key, created in Settings, API Keys, with the scopes and spending limit the holder should have:
49
+
50
+ ```bash
51
+ export SDCSTUDIO_API_KEY=sdcs_...
52
+ ```
53
+
54
+ ## The three layers
55
+
56
+ ### The client
57
+
58
+ ```python
59
+ from sdcmodeler import SDCStudioClient
60
+
61
+ c = SDCStudioClient() # key from $SDCSTUDIO_API_KEY, URL from $SDCSTUDIO_URL
62
+ hits = c.search_components("blood pressure", type="xdquantity")
63
+ tree = {
64
+ "label": "Vitals",
65
+ "components": [
66
+ {"ct_id": hits["results"][0]["ct_id"]}, # reuse: free
67
+ {"label": "Pulse", "data_type": "XdCount"}, # mint: 100 credits
68
+ ],
69
+ "clusters": [],
70
+ }
71
+ print(c.estimate(tree, "Vitals")) # reuse, mint, total_credits, estimate_id; no call that spends
72
+ result = c.assemble("Vitals", tree) # 500 credits plus the mints
73
+ ```
74
+
75
+ Every leaf existing: the server assembles, publishes and generates the package in one call (`result["mode"] == "reuse"`). Some leaves new: the pipeline runs and `result["data_source_ct_id"]` is polled with `c.job_status(...)`.
76
+
77
+ A 402 is `InsufficientCredits` with the numbers in credits. A 403 from the key's policy (no `spend` scope, or past its limit) is `KeyPolicyRefused`. The client never funds a wallet; a person does that at the wallet page.
78
+
79
+ ### The CLI
80
+
81
+ ```bash
82
+ sdcmodeler search "blood pressure" --type xdquantity
83
+ sdcmodeler models "patient"
84
+ sdcmodeler model <ct_id>
85
+ sdcmodeler artifact <ct_id> xsd --dir ./schemas
86
+ sdcmodeler estimate tree.json --title "Vitals"
87
+ sdcmodeler build tree.json --title "Vitals"
88
+ sdcmodeler app <ct_id> --profile lightweight --dir ./apps
89
+ sdcmodeler wallet
90
+ ```
91
+
92
+ ### The MCP server
93
+
94
+ ```bash
95
+ sdcmodeler mcp
96
+ ```
97
+
98
+ A JSON-RPC 2.0 stdio server, no SDK, the way sdcvalidator and sdcgovernance are built. A client configuration needs only:
99
+
100
+ ```json
101
+ {"command": "uvx", "args": ["sdcmodeler", "mcp"], "env": {"SDCSTUDIO_API_KEY": "sdcs_..."}}
102
+ ```
103
+
104
+ | Tool | Does | Spends |
105
+ |---|---|---|
106
+ | `search_components` | the public catalog by label, type and project | no |
107
+ | `list_models`, `get_model` | published models and their artifact routes | no |
108
+ | `estimate_model` | what a tree would reuse, mint and cost; returns `estimate_id` | no |
109
+ | `build_model` | assemble and publish; needs the `estimate_id` the person saw; refuses past the key's limit | yes |
110
+ | `job_status` | the pipeline for a mixed build | no |
111
+ | `generate_app` | generate and download the application; needs `confirm_charge`; 1,500 credits the first time, free after | yes |
112
+ | `wallet` | balance in credits and the key's policy | no |
113
+
114
+ **The policy lives in the server.** No spend without an estimate shown: `build_model` takes the `estimate_id` that `estimate_model` returned for the same title and tree in this process. Stop at the key's limit: a build whose estimate exceeds what the key may still spend is refused before the server is asked. Never pay: a 402 is reported with the wallet page's address and the tool stops. No tool takes a URL, a key or a payment method as an argument; the key is the environment the server starts with.
115
+
116
+ ## The package or the application
117
+
118
+ `get_model` names the artifacts: the XSD 1.1 schema, the instance template, JSON, JSON-LD, SHACL, HTML, GraphQL. The package is a contract with no runtime attached; a feature inside an existing application implements on it, in any language, validating every record locally with [sdcvalidator](https://pypi.org/project/sdcvalidator/). The generated application (lightweight or enterprise profile) is a Django implementation on the same package, right when the feature is a new service. [CordovaOS](https://github.com/Axius-SDC/CordovaOS) is ten of them sharing data with zero integration code.
119
+
120
+ ## What is not here
121
+
122
+ Validation (sdcvalidator's server), governance (sdcgovernance's), receipt verification (sdcreceipt's) and bringing existing data across (sdc-agents) are their own registered servers. sdcmodeler composes with them; it does not re-implement them.
123
+
124
+ ## Release
125
+
126
+ Two steps: merge to `main`, then push the tag `v<version>` matching `pyproject.toml`. `release.yml` runs the tests, builds, publishes to PyPI by trusted publisher and to the MCP registry.
127
+
128
+ ## License
129
+
130
+ Apache License 2.0. Copyright Axius SDC, Inc.
@@ -0,0 +1,104 @@
1
+ # sdcmodeler
2
+
3
+ <!-- mcp-name: io.github.Axius-SDC/sdcmodeler -->
4
+
5
+ **The modeler's client for SDCStudio.** Search the public catalog, estimate, assemble and publish an SDC4 data model, generate its package and an application. A Python client with httpx as its only dependency, a CLI, and `sdcmodeler mcp`, an MCP server for any agent.
6
+
7
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
8
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
9
+
10
+ ## Why
11
+
12
+ An agent that builds a feature decides a data model at that moment. With sdcmodeler the data is modeled in SDC by default: the agent searches the catalog first, reuses published components wherever one fits, mints only what is new, publishes the model, and takes the package. The result is interoperable because it is composed from shared, published components, and verifiable because every record validates against a published schema.
13
+
14
+ The name follows the role pattern of the other Semantic Data Charter servers: sdcvalidator validates, sdcgovernance governs, sdcreader reads, sdcmodeler models. It also names what SDCStudio calls every user: a Modeler.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pip install sdcmodeler
20
+ ```
21
+
22
+ The catalog and estimates need no account. Building needs an SDCStudio API key, created in Settings, API Keys, with the scopes and spending limit the holder should have:
23
+
24
+ ```bash
25
+ export SDCSTUDIO_API_KEY=sdcs_...
26
+ ```
27
+
28
+ ## The three layers
29
+
30
+ ### The client
31
+
32
+ ```python
33
+ from sdcmodeler import SDCStudioClient
34
+
35
+ c = SDCStudioClient() # key from $SDCSTUDIO_API_KEY, URL from $SDCSTUDIO_URL
36
+ hits = c.search_components("blood pressure", type="xdquantity")
37
+ tree = {
38
+ "label": "Vitals",
39
+ "components": [
40
+ {"ct_id": hits["results"][0]["ct_id"]}, # reuse: free
41
+ {"label": "Pulse", "data_type": "XdCount"}, # mint: 100 credits
42
+ ],
43
+ "clusters": [],
44
+ }
45
+ print(c.estimate(tree, "Vitals")) # reuse, mint, total_credits, estimate_id; no call that spends
46
+ result = c.assemble("Vitals", tree) # 500 credits plus the mints
47
+ ```
48
+
49
+ Every leaf existing: the server assembles, publishes and generates the package in one call (`result["mode"] == "reuse"`). Some leaves new: the pipeline runs and `result["data_source_ct_id"]` is polled with `c.job_status(...)`.
50
+
51
+ A 402 is `InsufficientCredits` with the numbers in credits. A 403 from the key's policy (no `spend` scope, or past its limit) is `KeyPolicyRefused`. The client never funds a wallet; a person does that at the wallet page.
52
+
53
+ ### The CLI
54
+
55
+ ```bash
56
+ sdcmodeler search "blood pressure" --type xdquantity
57
+ sdcmodeler models "patient"
58
+ sdcmodeler model <ct_id>
59
+ sdcmodeler artifact <ct_id> xsd --dir ./schemas
60
+ sdcmodeler estimate tree.json --title "Vitals"
61
+ sdcmodeler build tree.json --title "Vitals"
62
+ sdcmodeler app <ct_id> --profile lightweight --dir ./apps
63
+ sdcmodeler wallet
64
+ ```
65
+
66
+ ### The MCP server
67
+
68
+ ```bash
69
+ sdcmodeler mcp
70
+ ```
71
+
72
+ A JSON-RPC 2.0 stdio server, no SDK, the way sdcvalidator and sdcgovernance are built. A client configuration needs only:
73
+
74
+ ```json
75
+ {"command": "uvx", "args": ["sdcmodeler", "mcp"], "env": {"SDCSTUDIO_API_KEY": "sdcs_..."}}
76
+ ```
77
+
78
+ | Tool | Does | Spends |
79
+ |---|---|---|
80
+ | `search_components` | the public catalog by label, type and project | no |
81
+ | `list_models`, `get_model` | published models and their artifact routes | no |
82
+ | `estimate_model` | what a tree would reuse, mint and cost; returns `estimate_id` | no |
83
+ | `build_model` | assemble and publish; needs the `estimate_id` the person saw; refuses past the key's limit | yes |
84
+ | `job_status` | the pipeline for a mixed build | no |
85
+ | `generate_app` | generate and download the application; needs `confirm_charge`; 1,500 credits the first time, free after | yes |
86
+ | `wallet` | balance in credits and the key's policy | no |
87
+
88
+ **The policy lives in the server.** No spend without an estimate shown: `build_model` takes the `estimate_id` that `estimate_model` returned for the same title and tree in this process. Stop at the key's limit: a build whose estimate exceeds what the key may still spend is refused before the server is asked. Never pay: a 402 is reported with the wallet page's address and the tool stops. No tool takes a URL, a key or a payment method as an argument; the key is the environment the server starts with.
89
+
90
+ ## The package or the application
91
+
92
+ `get_model` names the artifacts: the XSD 1.1 schema, the instance template, JSON, JSON-LD, SHACL, HTML, GraphQL. The package is a contract with no runtime attached; a feature inside an existing application implements on it, in any language, validating every record locally with [sdcvalidator](https://pypi.org/project/sdcvalidator/). The generated application (lightweight or enterprise profile) is a Django implementation on the same package, right when the feature is a new service. [CordovaOS](https://github.com/Axius-SDC/CordovaOS) is ten of them sharing data with zero integration code.
93
+
94
+ ## What is not here
95
+
96
+ Validation (sdcvalidator's server), governance (sdcgovernance's), receipt verification (sdcreceipt's) and bringing existing data across (sdc-agents) are their own registered servers. sdcmodeler composes with them; it does not re-implement them.
97
+
98
+ ## Release
99
+
100
+ Two steps: merge to `main`, then push the tag `v<version>` matching `pyproject.toml`. `release.yml` runs the tests, builds, publishes to PyPI by trusted publisher and to the MCP registry.
101
+
102
+ ## License
103
+
104
+ Apache License 2.0. Copyright Axius SDC, Inc.
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sdcmodeler"
7
+ version = "4.0.0"
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
+ license = "Apache-2.0"
10
+ requires-python = ">=3.10"
11
+ readme = "README.md"
12
+ authors = [
13
+ {name = "Axius SDC, Inc."},
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Software Development :: Libraries",
24
+ ]
25
+ dependencies = ["httpx>=0.27"]
26
+
27
+ [project.optional-dependencies]
28
+ dev = ["pytest>=8", "pytest-cov"]
29
+
30
+ [project.scripts]
31
+ sdcmodeler = "sdcmodeler.cli:main"
32
+
33
+ [project.urls]
34
+ Repository = "https://github.com/Axius-SDC/sdcmodeler"
35
+ Documentation = "https://axius-sdc.com/docs/"
36
+ Issues = "https://github.com/Axius-SDC/sdcmodeler/issues"
37
+
38
+ [tool.setuptools.packages.find]
39
+ where = ["src"]
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
43
+ pythonpath = ["."]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,39 @@
1
+ """
2
+ sdcmodeler: the modeler's client for SDCStudio.
3
+
4
+ Three layers in one package (SDCStudio's agent-path PRD, decision D1):
5
+
6
+ - ``sdcmodeler.client``: a framework-free client for the SDCStudio API, httpx
7
+ and nothing else. Search the catalog, estimate, assemble and publish a data
8
+ model, generate the package and an application, read the wallet and the
9
+ key's policy.
10
+ - ``sdcmodeler.cli``: the same client at a terminal.
11
+ - ``sdcmodeler.mcp_server``: ``sdcmodeler mcp``, a JSON-RPC 2.0 stdio server
12
+ over the client for any MCP-capable agent, carrying the product policy: no
13
+ spend without an estimate shown, stop at the key's limit, never pay.
14
+
15
+ The name follows the role-name pattern of the other Semantic Data Charter
16
+ servers: sdcvalidator validates, sdcgovernance governs, sdcreader reads,
17
+ sdcmodeler models. It also names the concept SDCStudio already has: every user
18
+ is a Modeler, and the Modeler's projects scope every call.
19
+ """
20
+ __version__ = "4.0.0"
21
+
22
+ from sdcmodeler.client import ( # noqa: E402
23
+ AssemblyRefused,
24
+ InsufficientCredits,
25
+ KeyPolicyRefused,
26
+ SDCStudioClient,
27
+ SDCStudioError,
28
+ )
29
+ from sdcmodeler.pricing import estimate_tree # noqa: E402
30
+
31
+ __all__ = [
32
+ "__version__",
33
+ "SDCStudioClient",
34
+ "SDCStudioError",
35
+ "InsufficientCredits",
36
+ "KeyPolicyRefused",
37
+ "AssemblyRefused",
38
+ "estimate_tree",
39
+ ]
@@ -0,0 +1,102 @@
1
+ """``sdcmodeler``: the client at a terminal. ``sdcmodeler mcp`` starts the MCP server."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import json
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ from sdcmodeler import __version__
10
+ from sdcmodeler.client import SDCStudioClient, SDCStudioError
11
+
12
+
13
+ def _print(data) -> None:
14
+ sys.stdout.write(json.dumps(data, indent=2, default=str) + "\n")
15
+
16
+
17
+ def _load_tree(path: str) -> dict:
18
+ return json.loads(Path(path).read_text(encoding="utf-8"))
19
+
20
+
21
+ def build_parser() -> argparse.ArgumentParser:
22
+ p = argparse.ArgumentParser(
23
+ prog="sdcmodeler",
24
+ description="The modeler's client for SDCStudio: search, estimate, build, generate; `sdcmodeler mcp` runs the MCP server.",
25
+ epilog="The key is read from $SDCSTUDIO_API_KEY, the deployment from $SDCSTUDIO_URL.",
26
+ )
27
+ p.add_argument("--version", action="version", version=f"sdcmodeler {__version__}")
28
+ p.add_argument("--url", default=None, help="SDCStudio base URL.")
29
+ sub = p.add_subparsers(dest="command")
30
+
31
+ s = sub.add_parser("search", help="search the public catalog of published components")
32
+ s.add_argument("query"); s.add_argument("--type"); s.add_argument("--project"); s.add_argument("--page-size", type=int, default=25)
33
+ s.set_defaults(func=lambda c, a: c.search_components(a.query, type=a.type, project=a.project, page_size=a.page_size))
34
+
35
+ s = sub.add_parser("models", help="published models in the public catalog")
36
+ s.add_argument("query", nargs="?", default="")
37
+ s.set_defaults(func=lambda c, a: c.list_models(a.query))
38
+
39
+ s = sub.add_parser("model", help="one published model, with its artifact routes")
40
+ s.add_argument("ct_id")
41
+ s.set_defaults(func=lambda c, a: c.get_model(a.ct_id))
42
+
43
+ s = sub.add_parser("artifact", help="download one artifact of a published model (xsd, xml, json, jsonld, html, ttl, shacl, gql, zip)")
44
+ s.add_argument("ct_id"); s.add_argument("kind"); s.add_argument("--dir", default=".")
45
+ s.set_defaults(func=lambda c, a: {"path": str(c.download_artifact(a.ct_id, a.kind, a.dir))})
46
+
47
+ s = sub.add_parser("estimate", help="what an assembly tree would reuse, mint and cost (no call that spends)")
48
+ s.add_argument("tree", help="JSON file: {label, components: [...], clusters: [...]}"); s.add_argument("--title", default="")
49
+ s.set_defaults(func=lambda c, a: c.estimate(_load_tree(a.tree), a.title))
50
+
51
+ s = sub.add_parser("build", help="assemble (and, with every leaf existing, publish and generate) a model; spends credits")
52
+ s.add_argument("tree"); s.add_argument("--title", required=True); s.add_argument("--description", default="")
53
+ s.set_defaults(func=lambda c, a: c.assemble(a.title, _load_tree(a.tree), description=a.description))
54
+
55
+ s = sub.add_parser("job", help="status of a mixed build or an upload")
56
+ s.add_argument("data_source_ct_id")
57
+ s.set_defaults(func=lambda c, a: c.job_status(a.data_source_ct_id))
58
+
59
+ s = sub.add_parser("package", help="generate a published model's package and download it")
60
+ s.add_argument("ct_id"); s.add_argument("--dir", default=".")
61
+ s.set_defaults(func=lambda c, a: {"generated": c.generate_package(a.ct_id), "path": str(c.download_package(a.ct_id, a.dir))})
62
+
63
+ s = sub.add_parser("app", help="generate and download a published model's application (1,500 credits the first time)")
64
+ s.add_argument("ct_id"); s.add_argument("--profile", choices=["lightweight", "enterprise"], default="lightweight"); s.add_argument("--dir", default=".")
65
+ def _app(c, a):
66
+ generated = c.generate_app(a.ct_id, a.profile)
67
+ path, charged = c.download_app(a.ct_id, a.dir, a.profile)
68
+ return {"generated": generated, "path": str(path), "charged": charged}
69
+ s.set_defaults(func=_app)
70
+
71
+ s = sub.add_parser("wallet", help="the wallet balance in credits and this key's policy")
72
+ s.set_defaults(func=lambda c, a: {"wallet": c.wallet(), "key": c.key_policy()})
73
+
74
+ sub.add_parser("mcp", help="run the MCP stdio server (options after `mcp` belong to the server)")
75
+ return p
76
+
77
+
78
+ def main(argv: list[str] | None = None) -> int:
79
+ argv = list(sys.argv[1:]) if argv is None else list(argv)
80
+ if argv[:1] == ["mcp"]:
81
+ # The registry launches `sdcmodeler mcp [server options]`; the server owns those options.
82
+ from sdcmodeler.mcp_server import main as mcp_main
83
+ mcp_main(argv[1:])
84
+ return 0
85
+ parser = build_parser()
86
+ args = parser.parse_args(argv)
87
+ if not args.command:
88
+ parser.print_help()
89
+ return 0
90
+ client = SDCStudioClient(base_url=args.url)
91
+ try:
92
+ _print(args.func(client, args))
93
+ return 0
94
+ except SDCStudioError as exc:
95
+ sys.stderr.write(f"{exc}\n")
96
+ return 1
97
+ finally:
98
+ client.close()
99
+
100
+
101
+ if __name__ == "__main__":
102
+ sys.exit(main())