Python MCP server for Kubernetes with kubectl and helm
## Kubernetes Python MCP Server: K8s Management with Python The **Kubernetes Python MCP Server** provides native Python integration for Kubernetes into Google Antigravity, enabling developers to manage clusters, deployments, and resources with type-safe Python interfaces. ### Why Kubernetes Python MCP? - **Native Python** - Clean Python API for Kubernetes operations - **Full API coverage** - Access to all Kubernetes API resources - **Type safety** - Complete type hints for all operations - **Multi-cluster** - Manage multiple clusters from one interface - **Watch support** - Real-time resource monitoring with watches ### Key Features #### 1. Deployment Management ```python # Create deployment deployment = await mcp.call("k8s-python", "create_deployment", { "namespace": "default", "name": "web-app", "image": "nginx:latest", "replicas": 3, "ports": [{"container_port": 80}], "resources": { "requests": {"cpu": "100m", "memory": "128Mi"}, "limits": {"cpu": "500m", "memory": "512Mi"} } }) # Scale deployment await mcp.call("k8s-python", "scale_deployment", { "namespace": "default", "name": "web-app", "replicas": 5 }) ``` #### 2. Pod Operations ```python # List pods pods = await mcp.call("k8s-python", "list_pods", { "namespace": "default", "label_selector": "app=web-app" }) for pod in pods: print(f"{pod[\"name\"]}: {pod[\"status\"][\"phase\"]}") # Get pod logs logs = await mcp.call("k8s-python", "get_pod_logs", { "namespace": "default", "name": pods[0]["name"], "tail_lines": 100 }) ``` #### 3. Service Management ```python # Create service service = await mcp.call("k8s-python", "create_service", { "namespace": "default", "name": "web-app-svc", "selector": {"app": "web-app"}, "ports": [{"port": 80, "target_port": 80}], "type": "LoadBalancer" }) # Get service external IP svc = await mcp.call("k8s-python", "get_service", { "namespace": "default", "name": "web-app-svc" }) print(f"External IP: {svc[\"status\"][\"load_balancer\"][\"ingress\"][0][\"ip\"]}") ``` #### 4. ConfigMap and Secrets ```python # Create ConfigMap await mcp.call("k8s-python", "create_configmap", { "namespace": "default", "name": "app-config", "data": { "DATABASE_URL": "postgres://db:5432/app", "LOG_LEVEL": "info" } }) # Create Secret await mcp.call("k8s-python", "create_secret", { "namespace": "default", "name": "app-secrets", "data": { "API_KEY": "base64-encoded-key" } }) ``` ### Configuration ```json { "mcpServers": { "k8s-python": { "command": "python", "args": ["-m", "mcp_kubernetes"], "env": { "KUBECONFIG": "~/.kube/config", "K8S_CONTEXT": "production" } } } } ``` ### Use Cases **Deployment Automation**: Manage application deployments programmatically. **Resource Monitoring**: Watch and react to resource changes in real-time. **Configuration Management**: Manage ConfigMaps and Secrets centrally. **Multi-Cluster Operations**: Manage resources across multiple clusters. The Kubernetes Python MCP Server provides Pythonic cluster management.
{
"mcpServers": {
"kubernetes-python": {
"mcpServers": {
"kubernetes-py": {
"args": [
"mcp-kubernetes-server"
],
"command": "uvx"
}
}
}
}
}