Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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)}"}
  • 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)}"}

Latest Blog Posts

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/abhijeetka/mcp-k8s-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server