Skip to main content
Glama
BenedatLLC

Kubernetes Tools MCP Server

by BenedatLLC

get_logs_for_cronjob

Retrieves logs from a Kubernetes CronJob's last run by locating the job and pod created for that run, removing the need to manually find short-lived pods.

Instructions

Retrieves logs from the most-recent run of a CronJob.

Finds the newest Job owned by the CronJob, then returns the logs of that Job's
most-recently-created pod. Removes the need to manually locate the right
short-lived pod for a CronJob's last tick.

Parameters
----------
cronjob_name : str
    Name of the CronJob.
namespace : str, optional
    Namespace of the CronJob (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 CronJob has no jobs/pods yet.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tailNo
previousNo
namespaceNodefault
cronjob_nameYes
since_secondsNo
container_nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.1.0

TDQS

A4.5/5.0
Behavior4/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 well: it discloses the job/pod resolution algorithm, the None return when no jobs/pods exist, and the error types raised (K8sConfigError, K8sApiError). It does not mention required RBAC permissions or rate limits, leaving a minor gap.

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?

Well front-loaded with the core behavior in the opening sentence, then structured parameter/returns/raises sections. Slightly verbose but every section carries information; no padding.

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 6-parameter read tool with no annotations and 0% schema coverage, the description supplies the resolution logic, all parameter semantics, return behavior, and failure modes. Nothing an agent needs to invoke it correctly 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 fully compensate, and it does: every one of the six parameters is documented with type, default, and behavioral meaning (e.g., tail default of last 1000 lines, previous semantics and its CrashLoopBackOff caveats).

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 from a CronJob's most-recent run) and explains the resolution path (newest owned Job, then its most-recent pod). This clearly distinguishes it from siblings like get_logs_for_job and get_logs_for_pod_and_container.

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 value proposition ('removes the need to manually locate the right short-lived pod') and cross-references get_logs_for_pod_and_container for the `previous` edge cases. However, it does not explicitly say when to prefer this over get_logs_for_job or get_logs_for_pod_and_container.

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