Skip to main content
Glama

pod_logs

Retrieve logs from Kubernetes pods or specific containers to monitor application behavior and troubleshoot issues in your cluster.

Instructions

Get logs from a pod or a specific container within the pod.

Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The pod name container: Optional container name (if pod has multiple containers) tail_lines: Number of lines to retrieve from the end of the logs previous: Whether to get logs from a previous instance of the container

Returns: Pod logs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
namespaceYes
nameYes
containerNo
tail_linesNo
previousNo

Implementation Reference

  • Handler function for the 'pod_logs' tool, including registration via @mcp.tool() decorator. Fetches logs from a Kubernetes pod using the CoreV1Api client.
    @mcp.tool()
    @use_current_context
    def pod_logs(context_name: str, namespace: str, name: str, container: str = None,
                 tail_lines: int = 100, previous: bool = False):
        """
        Get logs from a pod or a specific container within the pod.
    
        Args:
            context_name: The Kubernetes context name
            namespace: The Kubernetes namespace
            name: The pod name
            container: Optional container name (if pod has multiple containers)
            tail_lines: Number of lines to retrieve from the end of the logs
            previous: Whether to get logs from a previous instance of the container
    
        Returns:
            Pod logs
        """
        core_v1: CoreV1Api = get_api_clients(context_name)["core"]
    
        logs = core_v1.read_namespaced_pod_log(
            name=name,
            namespace=namespace,
            container=container,
            tail_lines=tail_lines,
            previous=previous
        )
    
        result = {
            "name": name,
            "namespace": namespace,
            "container": container,
            "logs": logs
        }
        return result

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