Skip to main content
Glama

get_node_pods

Retrieve all pods running on a specific Kubernetes node by providing the context and node name. Outputs a JSON string with the pod details for efficient cluster management.

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 for the 'get_node_pods' tool, decorated with @mcp.tool() for registration. It fetches all pods running on the specified node across all namespaces using the Kubernetes CoreV1Api and returns a JSON object with pod details including name, namespace, status, containers, count.
    @mcp.tool() @use_current_context 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-445 (registration)
    The @mcp.tool() decorator registers the get_node_pods function as an MCP tool.
    @mcp.tool()
  • The function signature and docstring define the input schema (context_name: str, node_name: str) and output (JSON string with pods).
    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

Other Tools

Related Tools

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