7
7
import tempfile
8
8
import urllib .request
9
9
10
+ if sys .version_info >= (3 , 8 ):
11
+ from importlib .metadata import version
12
+ else :
13
+ from importlib_metadata import version
14
+
15
+ __version__ = version ("kubernetes-mcp-server" )
16
+
10
17
def get_platform_binary ():
11
18
"""Determine the correct binary for the current platform."""
12
19
system = platform .system ().lower ()
@@ -29,11 +36,11 @@ def get_platform_binary():
29
36
else :
30
37
raise RuntimeError (f"Unsupported operating system: { system } " )
31
38
32
- def download_binary (version = "latest" , destination = None ):
39
+ def download_binary (binary_version = "latest" , destination = None ):
33
40
"""Download the correct binary for the current platform."""
34
41
binary_name = get_platform_binary ()
35
42
if destination is None :
36
- destination = Path .home () / ".kubernetes-mcp-server" / "bin"
43
+ destination = Path .home () / ".kubernetes-mcp-server" / "bin" / binary_version
37
44
38
45
destination = Path (destination )
39
46
destination .mkdir (parents = True , exist_ok = True )
@@ -43,10 +50,10 @@ def download_binary(version="latest", destination=None):
43
50
return binary_path
44
51
45
52
base_url = "https://github.com/manusa/kubernetes-mcp-server/releases"
46
- if version == "latest" :
53
+ if binary_version == "latest" :
47
54
release_url = f"{ base_url } /latest/download/{ binary_name } "
48
55
else :
49
- release_url = f"{ base_url } /download/{ version } /{ binary_name } "
56
+ release_url = f"{ base_url } /download/v { binary_version } /{ binary_name } "
50
57
51
58
# Download the binary
52
59
print (f"Downloading { binary_name } from { release_url } " )
@@ -71,7 +78,7 @@ def execute(args=None):
71
78
args = []
72
79
73
80
try :
74
- binary_path = download_binary ()
81
+ binary_path = download_binary (binary_version = __version__ )
75
82
cmd = [str (binary_path )] + args
76
83
77
84
# Execute the binary with the provided arguments
0 commit comments