from typing import List, Dict, Any
import os
from ..utils.k8s_client import KubernetesClient
# Initialize client with kubeconfig directory from environment or default
kubeconfig_dir = os.environ.get('KUBECONFIG_DIR', os.path.expanduser('~/.kube'))
k8s_client = KubernetesClient(kubeconfig_dir)
async def list_k8s_contexts() -> List[str]:
"""
List all available Kubernetes contexts from the kubeconfig files.
Returns:
List[str]: A list of available Kubernetes context names
Raises:
RuntimeError: If there's an error accessing the kubeconfig files
"""
try:
return k8s_client.refresh_contexts()
except Exception as e:
raise RuntimeError(f"Failed to list Kubernetes contexts: {str(e)}")
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/feibai406/k8s-multicluster-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server