mcpzero-cli 0.1.2__py3-none-any.whl
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.
mcpzero_cli/__init__.py
ADDED
|
@@ -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,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,5 @@
|
|
|
1
|
+
mcpzero_cli/__init__.py,sha256=ZZDNUcWUewYbf-iYo5RIxQmmxPqdqhg0tB0IY6LyF2o,2899
|
|
2
|
+
mcpzero_cli-0.1.2.dist-info/METADATA,sha256=KcRcim5mUaxKaKk1fq8HAu7rd6cnpNb0qjirXFg7hT0,764
|
|
3
|
+
mcpzero_cli-0.1.2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
4
|
+
mcpzero_cli-0.1.2.dist-info/entry_points.txt,sha256=HFpmp72lrGfd9cw4V9AJ9TNOgY2fvq6r4xX4RiFt8W4,45
|
|
5
|
+
mcpzero_cli-0.1.2.dist-info/RECORD,,
|