77import tempfile
88import urllib .request
99
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+
1017def get_platform_binary ():
1118 """Determine the correct binary for the current platform."""
1219 system = platform .system ().lower ()
@@ -29,11 +36,11 @@ def get_platform_binary():
2936 else :
3037 raise RuntimeError (f"Unsupported operating system: { system } " )
3138
32- def download_binary (version = "latest" , destination = None ):
39+ def download_binary (binary_version = "latest" , destination = None ):
3340 """Download the correct binary for the current platform."""
3441 binary_name = get_platform_binary ()
3542 if destination is None :
36- destination = Path .home () / ".kubernetes-mcp-server" / "bin"
43+ destination = Path .home () / ".kubernetes-mcp-server" / "bin" / binary_version
3744
3845 destination = Path (destination )
3946 destination .mkdir (parents = True , exist_ok = True )
@@ -43,10 +50,10 @@ def download_binary(version="latest", destination=None):
4350 return binary_path
4451
4552 base_url = "https://github.com/manusa/kubernetes-mcp-server/releases"
46- if version == "latest" :
53+ if binary_version == "latest" :
4754 release_url = f"{ base_url } /latest/download/{ binary_name } "
4855 else :
49- release_url = f"{ base_url } /download/{ version } /{ binary_name } "
56+ release_url = f"{ base_url } /download/v { binary_version } /{ binary_name } "
5057
5158 # Download the binary
5259 print (f"Downloading { binary_name } from { release_url } " )
@@ -71,7 +78,7 @@ def execute(args=None):
7178 args = []
7279
7380 try :
74- binary_path = download_binary ()
81+ binary_path = download_binary (binary_version = __version__ )
7582 cmd = [str (binary_path )] + args
7683
7784 # Execute the binary with the provided arguments
0 commit comments