Skip to main content
Glama

get-logs

Retrieve log output from a Kubernetes pod to monitor application behavior, debug issues, and track pod activity. Specify the pod name and optionally set namespace, line count, or enable real-time log streaming.

Instructions

Get logs from a Kubernetes pod

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
followNoFollow the logs (stream new logs as they come in)
linesNoNumber of lines to retrieve from the end of the logs (default: 100)
namespaceNoThe namespace of the pod (optional, defaults to current context namespace)
podYesThe name of the pod to get logs from

Implementation Reference

  • The core handler logic for the 'get-logs' tool. Constructs and executes a 'kubectl logs' command using the provided pod name, optional namespace, number of tail lines, follow flag, and container name, returning the log output.
    case "get-logs": { const { pod, namespace, lines = 100, follow = false, container } = args; const nsArg = namespace ? `-n ${namespace}` : ""; const followArg = follow ? "-f" : ""; const containerArg = container ? `-c ${container}` : ""; const cmd = `kubectl logs ${pod} ${nsArg} --tail=${lines} ${followArg} ${containerArg}`.trim(); const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || "No logs found" }] }; }
  • The tool schema definition for 'get-logs', including input schema for validation, descriptions, and required parameters. Used for tool listing and input validation.
    name: "get-logs", description: "Get logs from a Kubernetes pod", inputSchema: { type: "object", properties: { pod: { type: "string", description: "The name of the pod to get logs from" }, namespace: { type: "string", description: "The namespace of the pod (optional, defaults to current context namespace)" }, lines: { type: "number", description: "Number of lines to retrieve from the end of the logs (default: 100)" }, follow: { type: "boolean", description: "Follow the logs (stream new logs as they come in)" }, container: { type: "string", description: "The container name to get logs from (if pod has multiple containers)" } }, required: ["pod"] } },

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/thekaranpargaie/kube-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server