mirror of
https://github.com/openshift/openshift-mcp-server.git
synced 2025-10-17 14:27:48 +03:00
feat(python): python packages (39)
feat(python): python packages --- Update python/kubernetes_mcp_server/__init__.py
This commit is contained in:
1
python/README.md
Symbolic link
1
python/README.md
Symbolic link
@@ -0,0 +1 @@
|
||||
../README.md
|
||||
7
python/kubernetes_mcp_server/__init__.py
Normal file
7
python/kubernetes_mcp_server/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""
|
||||
Kubernetes MCP Server (Model Context Protocol) with special support for OpenShift.
|
||||
"""
|
||||
from .kubernetes_mcp_server import main
|
||||
|
||||
__all__ = ['main']
|
||||
|
||||
4
python/kubernetes_mcp_server/__main__.py
Normal file
4
python/kubernetes_mcp_server/__main__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from .kubernetes_mcp_server import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
91
python/kubernetes_mcp_server/kubernetes_mcp_server.py
Normal file
91
python/kubernetes_mcp_server/kubernetes_mcp_server.py
Normal file
@@ -0,0 +1,91 @@
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import tempfile
|
||||
import urllib.request
|
||||
|
||||
def get_platform_binary():
|
||||
"""Determine the correct binary for the current platform."""
|
||||
system = platform.system().lower()
|
||||
arch = platform.machine().lower()
|
||||
|
||||
# Normalize architecture names
|
||||
if arch in ["x86_64", "amd64"]:
|
||||
arch = "amd64"
|
||||
elif arch in ["arm64", "aarch64"]:
|
||||
arch = "arm64"
|
||||
else:
|
||||
raise RuntimeError(f"Unsupported architecture: {arch}")
|
||||
|
||||
if system == "darwin":
|
||||
return f"kubernetes-mcp-server-darwin-{arch}"
|
||||
elif system == "linux":
|
||||
return f"kubernetes-mcp-server-linux-{arch}"
|
||||
elif system == "windows":
|
||||
return f"kubernetes-mcp-server-windows-{arch}.exe"
|
||||
else:
|
||||
raise RuntimeError(f"Unsupported operating system: {system}")
|
||||
|
||||
def download_binary(version="latest", destination=None):
|
||||
"""Download the correct binary for the current platform."""
|
||||
binary_name = get_platform_binary()
|
||||
if destination is None:
|
||||
destination = Path.home() / ".kubernetes-mcp-server" / "bin"
|
||||
|
||||
destination = Path(destination)
|
||||
destination.mkdir(parents=True, exist_ok=True)
|
||||
binary_path = destination / binary_name
|
||||
|
||||
if binary_path.exists():
|
||||
return binary_path
|
||||
|
||||
base_url = "https://github.com/manusa/kubernetes-mcp-server/releases"
|
||||
if version == "latest":
|
||||
release_url = f"{base_url}/latest/download/{binary_name}"
|
||||
else:
|
||||
release_url = f"{base_url}/download/{version}/{binary_name}"
|
||||
|
||||
# Download the binary
|
||||
print(f"Downloading {binary_name} from {release_url}")
|
||||
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
||||
try:
|
||||
with urllib.request.urlopen(release_url) as response:
|
||||
shutil.copyfileobj(response, temp_file)
|
||||
temp_file.close()
|
||||
|
||||
# Move to destination and make executable
|
||||
shutil.move(temp_file.name, binary_path)
|
||||
binary_path.chmod(binary_path.stat().st_mode | 0o755) # Make executable
|
||||
|
||||
return binary_path
|
||||
except Exception as e:
|
||||
os.unlink(temp_file.name)
|
||||
raise RuntimeError(f"Failed to download binary: {e}")
|
||||
|
||||
def execute(args=None):
|
||||
"""Download and execute the kubernetes-mcp-server binary."""
|
||||
if args is None:
|
||||
args = []
|
||||
|
||||
try:
|
||||
binary_path = download_binary()
|
||||
cmd = [str(binary_path)] + args
|
||||
|
||||
# Execute the binary with the provided arguments
|
||||
process = subprocess.run(cmd)
|
||||
return process.returncode
|
||||
except Exception as e:
|
||||
print(f"Error executing kubernetes-mcp-server: {e}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(execute(sys.argv[1:]))
|
||||
|
||||
|
||||
def main():
|
||||
"""Main function to execute the kubernetes-mcp-server binary."""
|
||||
args = sys.argv[1:] if len(sys.argv) > 1 else []
|
||||
return execute(args)
|
||||
25
python/pyproject.toml
Normal file
25
python/pyproject.toml
Normal file
@@ -0,0 +1,25 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=42", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "kubernetes-mcp-server"
|
||||
version = "0.0.21-7-g869ebc2"
|
||||
description = "Kubernetes MCP Server (Model Context Protocol) with special support for OpenShift"
|
||||
readme = {file="README.md", content-type="text/markdown"}
|
||||
requires-python = ">=3.6"
|
||||
license = "Apache-2.0"
|
||||
authors = [
|
||||
{ name = "Marc Nuri", email = "marc@marcnuri.com" }
|
||||
]
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/manusa/kubernetes-mcp-server"
|
||||
Repository = "https://github.com/manusa/kubernetes-mcp-server"
|
||||
|
||||
[project.scripts]
|
||||
kubernetes-mcp-server = "kubernetes_mcp_server:main"
|
||||
8
python/uv.lock
generated
Normal file
8
python/uv.lock
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
version = 1
|
||||
revision = 1
|
||||
requires-python = ">=3.6"
|
||||
|
||||
[[package]]
|
||||
name = "kubernetes-mcp-server"
|
||||
version = "0.0.0.dev3"
|
||||
source = { editable = "." }
|
||||
Reference in New Issue
Block a user