Skip to main content
Glama

get_nodes

Retrieve all nodes in a Kubernetes cluster with a simple command, enabling efficient cluster management through the MCP Kubernetes Server.

Instructions

Get all nodes in the cluster

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Primary handler implementation for the 'get_nodes' tool. Retrieves all nodes in the Kubernetes cluster without namespace restriction using kubectl get nodes -o json.
    @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 implementation for the 'get_nodes' tool with optional namespace parameter. Note: Nodes are cluster-scoped, so namespace flag may not filter as expected.
    @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)}"}
  • kubernetes.py:66-74 (registration)
    Registration of the get_nodes tool via @mcp.tool() decorator.
    @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 (registration)
    Registration of the overloaded get_nodes tool via @mcp.tool() decorator.
    @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