mcpcert-cli 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.
@@ -0,0 +1,27 @@
1
+ # Dependencies
2
+ node_modules/
3
+ packages/node/node_modules/
4
+
5
+ # Build output
6
+ dist/
7
+ *.tsbuildinfo
8
+
9
+ # Python
10
+ __pycache__/
11
+ *.py[cod]
12
+ .venv/
13
+ venv/
14
+ *.egg-info/
15
+ build/
16
+ .pytest_cache/
17
+ .ruff_cache/
18
+ .mypy_cache/
19
+
20
+ # Secrets (the CLI never commits these; never commit local test creds)
21
+ .mcpcert/
22
+
23
+ # OS / editor
24
+ .DS_Store
25
+ *.log
26
+ .idea/
27
+ .vscode/
@@ -0,0 +1,201 @@
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 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 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 those 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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 mcpcert.org
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ mcpcert CLI
2
+ Copyright 2026 mcpcert.org
3
+
4
+ This product includes software developed at mcpcert.org (https://mcpcert.org).
5
+
6
+ "mcpcert" and the mcpcert.org name and logos are trademarks of mcpcert.org.
7
+ This license does not grant rights to use those marks; see Section 6 of the
8
+ Apache License 2.0.
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcpcert-cli
3
+ Version: 0.1.0
4
+ Summary: Official mcpcert.org CLI: provision a hosted dev MCP client identity (CIMD) and run an end-to-end OAuth 2.0 + PKCE conformance check, no account required.
5
+ Project-URL: Homepage, https://mcpcert.org
6
+ Project-URL: Issues, https://mcpcert.org/contact
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ License-File: NOTICE
10
+ Keywords: cimd,cli,mcp,mcpcert,model-context-protocol,oauth,oauth2,pkce
11
+ Requires-Python: >=3.10
12
+ Requires-Dist: tomli>=2.0.1; python_version < '3.11'
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8.0; extra == 'dev'
15
+ Description-Content-Type: text/markdown
16
+
17
+ # mcpcert (Python)
18
+
19
+ [mcpcert.org](https://mcpcert.org) is a free **registry and conformance service** for **MCP (Model
20
+ Context Protocol) clients**: it hosts your client's metadata document (CIMD) at a stable URL (your
21
+ permanent `client_id`) and runs a conformance sandbox for an end-to-end OAuth 2.0 + PKCE conformance
22
+ check. Development identities are free and need no account; promote one to production within 60 days.
23
+
24
+ This is the **Python** build of the official `mcpcert` CLI (a TypeScript/Node build is also published
25
+ to npm). It installs an executable named `mcpcert` and is a thin HTTP client over the public
26
+ mcpcert.org API.
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ uv tool install mcpcert-cli # or:
32
+ pipx install mcpcert-cli
33
+ ```
34
+
35
+ The PyPI package is `mcpcert-cli`; it installs a command named `mcpcert`. Requires Python >= 3.10.
36
+
37
+ ## Quick start
38
+
39
+ ```bash
40
+ mcpcert init --accept-tos # provision a hosted dev identity (no account)
41
+ mcpcert info # show it (offline)
42
+ mcpcert conformance run # end-to-end OAuth 2.0 + PKCE conformance check
43
+ mcpcert update --redirect-uri http://127.0.0.1:8080/callback
44
+ ```
45
+
46
+ ## Commands
47
+
48
+ | Command | Purpose |
49
+ | --- | --- |
50
+ | `mcpcert init` | Provision an anonymous development identity (CIMD). |
51
+ | `mcpcert update` | Patch mutable dev metadata before expiry (never renews). |
52
+ | `mcpcert info [--check]` | Print the local identity; `--check` reconciles with live server state. |
53
+ | `mcpcert conformance run` | Drive the OAuth/conformance flow end to end. |
54
+ | `mcpcert conformance list` | List conformance runs. |
55
+ | `mcpcert conformance show <runId>` | Show one conformance run. |
56
+
57
+ Run `mcpcert <command> --help` for flags. Add `--json` to any command for machine-readable output.
58
+
59
+ Promotion to a permanent **production** CIMD is done in the web dashboard
60
+ (<https://mcpcert.org/dashboard/promote>) — it requires an account and is **not** a CLI command.
61
+ There is no `promote` or `refresh` command. Full docs: <https://mcpcert.org>.
62
+
63
+ ## License
64
+
65
+ Apache-2.0. See `LICENSE` and `NOTICE` in this package.
@@ -0,0 +1,49 @@
1
+ # mcpcert (Python)
2
+
3
+ [mcpcert.org](https://mcpcert.org) is a free **registry and conformance service** for **MCP (Model
4
+ Context Protocol) clients**: it hosts your client's metadata document (CIMD) at a stable URL (your
5
+ permanent `client_id`) and runs a conformance sandbox for an end-to-end OAuth 2.0 + PKCE conformance
6
+ check. Development identities are free and need no account; promote one to production within 60 days.
7
+
8
+ This is the **Python** build of the official `mcpcert` CLI (a TypeScript/Node build is also published
9
+ to npm). It installs an executable named `mcpcert` and is a thin HTTP client over the public
10
+ mcpcert.org API.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ uv tool install mcpcert-cli # or:
16
+ pipx install mcpcert-cli
17
+ ```
18
+
19
+ The PyPI package is `mcpcert-cli`; it installs a command named `mcpcert`. Requires Python >= 3.10.
20
+
21
+ ## Quick start
22
+
23
+ ```bash
24
+ mcpcert init --accept-tos # provision a hosted dev identity (no account)
25
+ mcpcert info # show it (offline)
26
+ mcpcert conformance run # end-to-end OAuth 2.0 + PKCE conformance check
27
+ mcpcert update --redirect-uri http://127.0.0.1:8080/callback
28
+ ```
29
+
30
+ ## Commands
31
+
32
+ | Command | Purpose |
33
+ | --- | --- |
34
+ | `mcpcert init` | Provision an anonymous development identity (CIMD). |
35
+ | `mcpcert update` | Patch mutable dev metadata before expiry (never renews). |
36
+ | `mcpcert info [--check]` | Print the local identity; `--check` reconciles with live server state. |
37
+ | `mcpcert conformance run` | Drive the OAuth/conformance flow end to end. |
38
+ | `mcpcert conformance list` | List conformance runs. |
39
+ | `mcpcert conformance show <runId>` | Show one conformance run. |
40
+
41
+ Run `mcpcert <command> --help` for flags. Add `--json` to any command for machine-readable output.
42
+
43
+ Promotion to a permanent **production** CIMD is done in the web dashboard
44
+ (<https://mcpcert.org/dashboard/promote>) — it requires an account and is **not** a CLI command.
45
+ There is no `promote` or `refresh` command. Full docs: <https://mcpcert.org>.
46
+
47
+ ## License
48
+
49
+ Apache-2.0. See `LICENSE` and `NOTICE` in this package.
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "mcpcert-cli"
7
+ version = "0.1.0"
8
+ description = "Official mcpcert.org CLI: provision a hosted dev MCP client identity (CIMD) and run an end-to-end OAuth 2.0 + PKCE conformance check, no account required."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE", "NOTICE"]
12
+ requires-python = ">=3.10"
13
+ keywords = ["mcp", "model-context-protocol", "oauth", "oauth2", "pkce", "cimd", "mcpcert", "cli"]
14
+ dependencies = [
15
+ "tomli>=2.0.1; python_version < '3.11'",
16
+ ]
17
+
18
+ [project.urls]
19
+ Homepage = "https://mcpcert.org"
20
+ Issues = "https://mcpcert.org/contact"
21
+
22
+ [project.scripts]
23
+ mcpcert = "mcpcert.cli:main"
24
+
25
+ [project.optional-dependencies]
26
+ dev = ["pytest>=8.0"]
27
+
28
+ [tool.hatch.build.targets.wheel]
29
+ packages = ["src/mcpcert"]
30
+
31
+ [tool.hatch.build.targets.sdist]
32
+ include = ["src/mcpcert", "README.md", "LICENSE", "NOTICE"]
@@ -0,0 +1,3 @@
1
+ """mcpcert — official CLI for mcpcert.org dev client identities."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,112 @@
1
+ """HTTP client over the mcpcert.org API. Mirrors packages/node/src/lib/api.ts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import urllib.error
7
+ import urllib.request
8
+ from typing import Any
9
+ from urllib.parse import quote
10
+
11
+ from .contract import CLI_CONTRACT_VERSION, CONTRACT_HEADER
12
+ from .errors import CliError
13
+
14
+
15
+ class ApiClient:
16
+ def __init__(self, base_url: str) -> None:
17
+ self.base_url = base_url
18
+ self._preflighted = False
19
+ self.api_version = "unknown"
20
+
21
+ def version(self) -> dict[str, Any]:
22
+ return self._request("GET", "/api/version")
23
+
24
+ def preflight(self) -> None:
25
+ if self._preflighted:
26
+ return
27
+ meta = self.version()
28
+ self.api_version = str(meta.get("api_version", "unknown"))
29
+ supported = meta.get("supported_cli_contract_versions") or []
30
+ if CLI_CONTRACT_VERSION not in supported:
31
+ raise CliError(
32
+ "api_version_unsupported",
33
+ f"This mcpcert CLI (contract {CLI_CONTRACT_VERSION}) is not supported by {self.base_url}. "
34
+ f"Supported: {', '.join(supported) or 'none'}. Upgrade the CLI.",
35
+ details={"cli_contract_version": CLI_CONTRACT_VERSION, "supported": supported},
36
+ )
37
+ self._preflighted = True
38
+
39
+ def provision(self, body: dict[str, Any]) -> dict[str, Any]:
40
+ self.preflight()
41
+ return self._request("POST", "/api/dev-registrations", body=body)
42
+
43
+ def describe(self, appname: str, token: str) -> dict[str, Any]:
44
+ self.preflight()
45
+ return self._request("GET", f"/api/dev-registrations/{quote(appname, safe='')}", token=token)
46
+
47
+ def update(self, appname: str, token: str, patch: dict[str, Any]) -> dict[str, Any]:
48
+ self.preflight()
49
+ return self._request("PATCH", f"/api/dev-registrations/{quote(appname, safe='')}", token=token, body=patch)
50
+
51
+ def conformance_list(self, appname: str, token: str) -> dict[str, Any]:
52
+ self.preflight()
53
+ return self._request("GET", f"/api/dev-registrations/{quote(appname, safe='')}/conformance", token=token)
54
+
55
+ def conformance_show(self, appname: str, run_id: str, token: str) -> dict[str, Any]:
56
+ self.preflight()
57
+ return self._request(
58
+ "GET",
59
+ f"/api/dev-registrations/{quote(appname, safe='')}/conformance/{quote(run_id, safe='')}",
60
+ token=token,
61
+ )
62
+
63
+ def _request(
64
+ self,
65
+ method: str,
66
+ path: str,
67
+ *,
68
+ token: str | None = None,
69
+ body: dict[str, Any] | None = None,
70
+ ) -> dict[str, Any]:
71
+ url = f"{self.base_url}{path}"
72
+ headers = {"accept": "application/json", CONTRACT_HEADER: CLI_CONTRACT_VERSION}
73
+ if token:
74
+ headers["authorization"] = f"Bearer {token}"
75
+ data = None
76
+ if body is not None:
77
+ data = json.dumps(body).encode("utf-8")
78
+ headers["content-type"] = "application/json"
79
+ request = urllib.request.Request(url, data=data, method=method, headers=headers)
80
+ try:
81
+ with urllib.request.urlopen(request) as response:
82
+ text = response.read().decode("utf-8")
83
+ return _safe_json(text)
84
+ except urllib.error.HTTPError as error:
85
+ raw = error.read().decode("utf-8", errors="replace")
86
+ payload = _safe_json(raw)
87
+ if error.code == 426:
88
+ raise CliError(
89
+ "api_version_unsupported",
90
+ "Server requires a newer mcpcert CLI. Upgrade the CLI.",
91
+ details=payload,
92
+ ) from None
93
+ code = payload.get("error") if isinstance(payload.get("error"), str) else "network_error"
94
+ message = (
95
+ payload.get("error_description")
96
+ if isinstance(payload.get("error_description"), str)
97
+ else f"Request to {path} failed with HTTP {error.code}."
98
+ )
99
+ details = payload.get("details") if isinstance(payload.get("details"), dict) else {}
100
+ raise CliError(code, message, details=details) from None
101
+ except urllib.error.URLError as error:
102
+ raise CliError("network_error", f"Could not reach {url}: {error.reason}") from None
103
+
104
+
105
+ def _safe_json(text: str) -> dict[str, Any]:
106
+ if not text:
107
+ return {}
108
+ try:
109
+ parsed = json.loads(text)
110
+ return parsed if isinstance(parsed, dict) else {"value": parsed}
111
+ except ValueError:
112
+ return {}
@@ -0,0 +1,61 @@
1
+ """Minimal argument parser mirroring packages/node/src/lib/args.ts for identical flag semantics."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+
7
+ BOOLEAN_FLAGS = {"json", "no-color", "help", "version", "check", "no-open", "accept-tos"}
8
+
9
+
10
+ @dataclass
11
+ class ParsedArgs:
12
+ positionals: list[str] = field(default_factory=list)
13
+ options: dict[str, list[str]] = field(default_factory=dict)
14
+ booleans: set[str] = field(default_factory=set)
15
+
16
+
17
+ def parse_args(argv: list[str]) -> ParsedArgs:
18
+ parsed = ParsedArgs()
19
+ i = 0
20
+ while i < len(argv):
21
+ token = argv[i]
22
+ if not token.startswith("--"):
23
+ parsed.positionals.append(token)
24
+ i += 1
25
+ continue
26
+ body = token[2:]
27
+ if "=" in body:
28
+ name, _, value = body.partition("=")
29
+ name = name.strip()
30
+ if name in BOOLEAN_FLAGS:
31
+ parsed.booleans.add(name)
32
+ else:
33
+ parsed.options.setdefault(name, []).append(value)
34
+ i += 1
35
+ continue
36
+ name = body.strip()
37
+ if name in BOOLEAN_FLAGS:
38
+ parsed.booleans.add(name)
39
+ i += 1
40
+ continue
41
+ nxt = argv[i + 1] if i + 1 < len(argv) else None
42
+ if nxt is None or nxt.startswith("--"):
43
+ parsed.options.setdefault(name, []).append("")
44
+ i += 1
45
+ else:
46
+ parsed.options.setdefault(name, []).append(nxt)
47
+ i += 2
48
+ return parsed
49
+
50
+
51
+ def one(args: ParsedArgs, name: str) -> str | None:
52
+ values = args.options.get(name)
53
+ return values[-1] if values else None
54
+
55
+
56
+ def many(args: ParsedArgs, name: str) -> list[str] | None:
57
+ return args.options.get(name)
58
+
59
+
60
+ def boolean(args: ParsedArgs, name: str) -> bool:
61
+ return name in args.booleans
@@ -0,0 +1,89 @@
1
+ """mcpcert CLI entry point. Mirrors packages/node/src/cli.ts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import sys
7
+
8
+ from . import __version__
9
+ from .args import ParsedArgs, boolean, parse_args
10
+ from .commands import conformance_cmd, info_cmd, init_cmd, update_cmd
11
+ from .context import resolve_api_base_url
12
+ from .contract import CLI_CONTRACT_VERSION
13
+ from .errors import CliError
14
+ from .output import Output
15
+
16
+ HELP = """mcpcert - provision and test a hosted dev MCP client identity (CIMD).
17
+
18
+ Usage:
19
+ mcpcert init [--appname <name>] [--client-name <name>] [--application-type <type>]
20
+ [--redirect-uri <uri>]... [--accept-tos]
21
+ mcpcert update [--client-name <name>] [--redirect-uri <uri>]... [--scope <s>] ...
22
+ mcpcert info [--check]
23
+ mcpcert conformance run [--sandbox production|local] [--no-open] [--timeout <s>]
24
+ mcpcert conformance list
25
+ mcpcert conformance show <runId>
26
+
27
+ Global flags:
28
+ --api <url> API base URL (env MCPCERT_API, default https://mcpcert.org)
29
+ --config <path> Explicit config path (.json or .toml)
30
+ --credentials <path> Explicit credentials file path
31
+ --json Emit the JSON envelope
32
+ --no-color Disable color (also NO_COLOR)
33
+ --help Show help
34
+ --version Show version
35
+
36
+ Promotion to production is done in the web dashboard (https://mcpcert.org/dashboard/promote),
37
+ not via the CLI. Dev identities expire after 60 days and are not renewable."""
38
+
39
+ COMMANDS = {
40
+ "init": init_cmd.run,
41
+ "update": update_cmd.run,
42
+ "info": info_cmd.run,
43
+ "conformance": conformance_cmd.run,
44
+ }
45
+
46
+
47
+ def main(argv: list[str] | None = None) -> int:
48
+ # Emit LF (not platform CRLF) and UTF-8 so output is byte-identical to the
49
+ # Node CLI on every platform (specs/cli-behavior.md §12).
50
+ for stream in (sys.stdout, sys.stderr):
51
+ reconfigure = getattr(stream, "reconfigure", None)
52
+ if reconfigure is not None:
53
+ try:
54
+ reconfigure(encoding="utf-8", newline="\n")
55
+ except (ValueError, OSError):
56
+ pass
57
+
58
+ args = parse_args(list(sys.argv[1:] if argv is None else argv))
59
+
60
+ if boolean(args, "version"):
61
+ sys.stdout.write(f"{__version__} (contract {CLI_CONTRACT_VERSION})\n")
62
+ return 0
63
+
64
+ command = args.positionals[0] if args.positionals else None
65
+ if not command or boolean(args, "help"):
66
+ sys.stdout.write(HELP + "\n")
67
+ return 0
68
+
69
+ as_json = boolean(args, "json")
70
+ color = not boolean(args, "no-color") and not os.environ.get("NO_COLOR")
71
+ output = Output(as_json, color)
72
+
73
+ handler = COMMANDS.get(command)
74
+ if handler is None:
75
+ err = CliError("config_invalid", f'Unknown command "{command}". Run `mcpcert --help`.')
76
+ return output.failure(command, resolve_api_base_url(args, None), err)
77
+
78
+ command_args = ParsedArgs(positionals=args.positionals[1:], options=args.options, booleans=args.booleans)
79
+ try:
80
+ return handler(command_args, output)
81
+ except CliError as error:
82
+ return output.failure(command, resolve_api_base_url(args, None), error)
83
+ except Exception as error: # noqa: BLE001 - top-level guard
84
+ wrapped = CliError("unexpected_error", str(error), exit_code=4)
85
+ return output.failure(command, resolve_api_base_url(args, None), wrapped)
86
+
87
+
88
+ if __name__ == "__main__":
89
+ sys.exit(main())
File without changes