Skip to main content
Glama
BenedatLLC

Kubernetes Tools MCP Server

by BenedatLLC

get_logs_for_job

Returns logs from a Kubernetes Job's most recently created pod, locating it by job-name label to skip manual pod listing and sorting.

Instructions

Retrieves logs from the most-recently-created pod of a Job.

Job pods are short-lived, so this convenience finds the newest pod belonging to
the Job (via its `job-name` label) and returns its logs, saving the caller from
listing pods and sorting by creation time.

Parameters
----------
job_name : str
    Name of the Job.
namespace : str, optional
    Namespace of the Job (default is "default").
container_name : str, optional
    Container within the pod. If None, defaults to the first container.
tail : int, optional
    Number of lines from the end of the log (default: last 1000).
since_seconds : int, optional
    If set, only return logs newer than this many seconds.
previous : bool, default False
    If True, return logs from the previous terminated container instance.
    See `get_logs_for_pod_and_container` for the cases - CrashLoopBackOff, a
    restart racing the call, a reclaimed log file - where that legitimately
    returns the same text as `previous=False`, or a 200 whose body is an
    error message.

Returns
-------
str, optional
    Log content, or None if the Job has no pods.

Raises
------
K8sConfigError
    If unable to initialize the K8S API.
K8sApiError
    If the API call fails.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tailNo
job_nameYes
previousNo
namespaceNodefault
since_secondsNo
container_nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.1.0

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so: it discloses the pod-selection mechanism (newest pod via the `job-name` label), the None return when a Job has no pods, the CrashLoopBackOff/restart/log-reclaim cases where `previous=True` can return identical text or a 200 with an error body, and the two error types raised.

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?

Front-loaded with the one-sentence purpose and the rationale for the convenience wrapper before the reference sections. The Parameters section is long but earns its place given 0% schema coverage; the `previous` note is a single dense sentence that could be tightened but is not wasted.

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

Completeness5/5

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

For a six-parameter read tool with no annotations, the description covers selection logic, defaults, edge cases, error behavior, and even return values (None vs str). Nothing an agent needs in order to call it correctly or interpret the result is missing.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate and it does for all six parameters: default namespace 'default', first-container fallback for container_name, tail default of the last 1000 lines (a runtime default the schema's null does not convey), since_seconds semantics, and the meaning of `previous`.

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

Purpose5/5

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

States a specific verb and resource ('Retrieves logs') plus the precise scope ('most-recently-created pod of a Job'). That scope immediately distinguishes it from the generic get_logs_for_pod_and_container and from get_logs_for_cronjob, so an agent can route without opening a schema.

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

Usage Guidelines4/5

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

Explains the situation that motivates it ('Job pods are short-lived') and the alternative approach it saves the caller from ('listing pods and sorting by creation time'). It also points to the sibling get_logs_for_pod_and_container for the `previous` edge cases, though it never states an explicit 'do not use this when...' exclusion.

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