mcpzero-cli 0.1.2__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,4 @@
1
+ /dist/
2
+ **/.wrangler/
3
+ *.log
4
+ .DS_Store
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcpzero-cli
3
+ Version: 0.1.2
4
+ Summary: MCPZERO tunnel CLI — installs the prebuilt mcpzero binary for your platform.
5
+ Project-URL: Homepage, https://mcpzero.io
6
+ Project-URL: Source, https://github.com/mcpzero/cli
7
+ Author: MCPZERO
8
+ License: MIT
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+
12
+ # mcpzero-cli
13
+
14
+ The [MCPZERO](https://mcpzero.io) tunnel CLI, distributed via PyPI. Installing
15
+ this package gives you the `mcpzero` command, which downloads the prebuilt
16
+ binary for your platform on first run.
17
+
18
+ ```bash
19
+ pipx install mcpzero-cli
20
+ mcpzero --version
21
+ ```
22
+
23
+ Equivalent installs: `brew install mcpzero/tap/mcpzero` or
24
+ `curl -fsSL https://mcpzero.io/install.sh | sh`.
25
+
26
+ The library SDKs are published separately as `mcpzero-sdk`.
@@ -0,0 +1,15 @@
1
+ # mcpzero-cli
2
+
3
+ The [MCPZERO](https://mcpzero.io) tunnel CLI, distributed via PyPI. Installing
4
+ this package gives you the `mcpzero` command, which downloads the prebuilt
5
+ binary for your platform on first run.
6
+
7
+ ```bash
8
+ pipx install mcpzero-cli
9
+ mcpzero --version
10
+ ```
11
+
12
+ Equivalent installs: `brew install mcpzero/tap/mcpzero` or
13
+ `curl -fsSL https://mcpzero.io/install.sh | sh`.
14
+
15
+ The library SDKs are published separately as `mcpzero-sdk`.
@@ -0,0 +1,97 @@
1
+ """MCPZERO CLI launcher.
2
+
3
+ This package does not bundle the binary. On first run it downloads the prebuilt
4
+ ``mcpzero`` binary matching this package version and the host platform from the
5
+ cli repo's GitHub Releases, caches it, then execs it.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import os
11
+ import platform
12
+ import stat
13
+ import sys
14
+ import tarfile
15
+ import tempfile
16
+ import urllib.request
17
+ import zipfile
18
+ from importlib import metadata
19
+ from pathlib import Path
20
+
21
+ # GitHub Release assets: <base>/v<version>/mcpzero_<version>_<os>_<arch>.<ext>
22
+ BASE_URL = os.environ.get(
23
+ "MCPZERO_BASE_URL", "https://github.com/mcpzero/cli/releases/download"
24
+ ).rstrip("/")
25
+
26
+ _OS_MAP = {"darwin": "darwin", "linux": "linux", "windows": "windows"}
27
+ _ARCH_MAP = {
28
+ "x86_64": "amd64",
29
+ "amd64": "amd64",
30
+ "arm64": "arm64",
31
+ "aarch64": "arm64",
32
+ }
33
+
34
+
35
+ def _version() -> str:
36
+ try:
37
+ return metadata.version("mcpzero-cli")
38
+ except metadata.PackageNotFoundError:
39
+ return "0.0.0"
40
+
41
+
42
+ def _platform() -> tuple[str, str]:
43
+ os_name = _OS_MAP.get(platform.system().lower())
44
+ arch = _ARCH_MAP.get(platform.machine().lower())
45
+ if not os_name or not arch:
46
+ sys.exit(f"mcpzero-cli: unsupported platform {platform.system()}/{platform.machine()}")
47
+ return os_name, arch
48
+
49
+
50
+ def _cache_dir() -> Path:
51
+ base = os.environ.get("XDG_CACHE_HOME") or os.path.join(Path.home(), ".cache")
52
+ d = Path(base) / "mcpzero" / "bin"
53
+ d.mkdir(parents=True, exist_ok=True)
54
+ return d
55
+
56
+
57
+ def _ensure_binary() -> Path:
58
+ os_name, arch = _platform()
59
+ version = _version()
60
+ bin_name = "mcpzero.exe" if os_name == "windows" else "mcpzero"
61
+ dest = _cache_dir() / f"{version}-{os_name}-{arch}-{bin_name}"
62
+ if dest.exists():
63
+ return dest
64
+
65
+ ext = "zip" if os_name == "windows" else "tar.gz"
66
+ asset = f"mcpzero_{version}_{os_name}_{arch}.{ext}"
67
+ url = f"{BASE_URL}/v{version}/{asset}"
68
+
69
+ with tempfile.TemporaryDirectory() as tmp:
70
+ archive = Path(tmp) / asset
71
+ try:
72
+ urllib.request.urlretrieve(url, archive) # noqa: S310
73
+ if ext == "zip":
74
+ with zipfile.ZipFile(archive) as zf:
75
+ zf.extractall(tmp)
76
+ else:
77
+ with tarfile.open(archive) as tf:
78
+ tf.extractall(tmp)
79
+ except Exception as err: # noqa: BLE001
80
+ sys.exit(
81
+ f"mcpzero-cli: failed to download {asset}: {err}\n"
82
+ "See https://mcpzero.io/docs/cli/install/ for manual installation."
83
+ )
84
+ extracted = Path(tmp) / bin_name
85
+ os.replace(extracted, dest)
86
+ dest.chmod(dest.stat().st_mode | stat.S_IEXEC | stat.S_IRUSR)
87
+ return dest
88
+
89
+
90
+ def main() -> None:
91
+ binary = _ensure_binary()
92
+ args = [str(binary), *sys.argv[1:]]
93
+ if os.name == "nt":
94
+ import subprocess
95
+
96
+ sys.exit(subprocess.call(args))
97
+ os.execv(str(binary), args)
@@ -0,0 +1,22 @@
1
+ [project]
2
+ name = "mcpzero-cli"
3
+ version = "0.1.2"
4
+ description = "MCPZERO tunnel CLI — installs the prebuilt mcpzero binary for your platform."
5
+ readme = "README.md"
6
+ license = { text = "MIT" }
7
+ requires-python = ">=3.8"
8
+ authors = [{ name = "MCPZERO" }]
9
+
10
+ [project.urls]
11
+ Homepage = "https://mcpzero.io"
12
+ Source = "https://github.com/mcpzero/cli"
13
+
14
+ [project.scripts]
15
+ mcpzero = "mcpzero_cli:main"
16
+
17
+ [build-system]
18
+ requires = ["hatchling"]
19
+ build-backend = "hatchling.build"
20
+
21
+ [tool.hatch.build.targets.wheel]
22
+ packages = ["mcpzero_cli"]