get_nodes
Retrieve all Kubernetes cluster nodes to monitor resource availability and manage workload distribution across the infrastructure.
Instructions
Get all nodes in the cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- kubernetes.py:66-74 (handler)Handler function decorated with @mcp.tool() that implements the get_nodes tool by running 'kubectl get nodes -o json' to retrieve all nodes in the cluster.@mcp.tool() async def get_nodes() -> dict: """Get all nodes in the cluster""" try: cmd = ["kubectl", "get", "nodes", "-o", "json"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return json.loads(result.stdout) except subprocess.CalledProcessError as e: return {"error": f"Failed to get nodes: {str(e)}"}
- kubernetes.py:180-188 (handler)Secondary handler function decorated with @mcp.tool() for get_nodes tool, incorrectly attempting to filter nodes by namespace (nodes are cluster-scoped).@mcp.tool() async def get_nodes(namespace: str = "default") -> dict: """Get the nodes of a specific namespace""" try: cmd = ["kubectl", "get", "nodes", "-n", namespace, "-o", "json"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return json.loads(result.stdout) except subprocess.CalledProcessError as e: return {"error": f"Failed to get nodes: {str(e)}"}