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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions what the tool does but lacks critical details: it doesn't specify if this is a read-only operation (implied by 'Get' but not explicit), whether it requires specific permissions, potential rate limits, or how it handles errors (e.g., if the pod doesn't exist). The description adds minimal behavioral context beyond the basic function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized, with a clear purpose statement followed by parameter and return sections. It uses bullet-like formatting for readability and avoids redundant information. However, the 'Returns' section ('Pod logs') is overly simplistic and could be more informative, slightly reducing efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (6 parameters, no annotations, no output schema), the description is partially complete. It covers the purpose and parameters adequately but lacks behavioral details (e.g., safety, error handling) and output specifics. Without an output schema, the return description is vague ('Pod logs'), leaving gaps in understanding the response format or content.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description includes an 'Args' section that lists all 6 parameters with brief explanations, adding meaningful semantics beyond the input schema (which has 0% description coverage). For example, it clarifies that 'container' is optional for multi-container pods and 'tail_lines' retrieves lines from the end. This compensates well for the schema's lack of descriptions, though it could provide more detail on parameter interactions or defaults.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get logs from a pod or a specific container within the pod.' This specifies the verb ('Get logs') and resource ('pod' or 'container'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'pod_detail' or 'pod_list', which might also provide log-related information, so it falls short of a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a running pod), exclusions (e.g., not for deleted pods), or comparisons to siblings like 'pod_detail' that might offer log summaries. This lack of contextual direction leaves the agent to infer usage scenarios independently.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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