Skip to main content
Glama

get_node_pods

Retrieve all pods running on a specific Kubernetes node to monitor workloads, troubleshoot issues, and manage cluster resources effectively.

Instructions

Get all pods running on a specific node.

Args: context_name: The Kubernetes context name node_name: The name of the node to get pods for

Returns: JSON string containing the pods running on the node

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
node_nameYes

Implementation Reference

  • The handler function that retrieves all pods running on the specified node using the Kubernetes CoreV1Api. It lists pods across all namespaces with field_selector spec.nodeName matching the node_name, formats pod info, and returns JSON.
    def get_node_pods(context_name: str, node_name: str): """ Get all pods running on a specific node. Args: context_name: The Kubernetes context name node_name: The name of the node to get pods for Returns: JSON string containing the pods running on the node """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] # Get all pods in all namespaces pods = core_v1.list_pod_for_all_namespaces(field_selector=f"spec.nodeName={node_name}") pod_list = [ { "name": pod.metadata.name, "namespace": pod.metadata.namespace, "status": pod.status.phase, "containers": [c.name for c in pod.spec.containers] } for pod in pods.items ] result = { "node": node_name, "pods": pod_list, "pod_count": len(pod_list) } return json.dumps(result)
  • tools/node.py:445-446 (registration)
    The @mcp.tool() decorator registers the get_node_pods function as an MCP tool. The @use_current_context decorator provides the current Kubernetes context.
    @mcp.tool() @use_current_context

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/bourbonkk/k8s-pilot'

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