Skip to main content
Glama

get_logs

Retrieve logs from a specific Kubernetes pod by specifying its name, namespace, and log tail length. Simplify log management within clusters using MCP Kubernetes Server.

Instructions

Get the logs of a specific pod

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
namespaceNodefault
tailNo

Implementation Reference

  • The handler function that implements the 'get_logs' tool logic. It retrieves the last 'tail' number of lines from the logs of a pod named 'name' in the specified 'namespace' using the 'kubectl logs' command.
    @mcp.tool() async def get_logs(name: str, namespace: str = "default", tail: int = 1000) -> dict: """Get the logs of a specific pod""" try: cmd = ["kubectl", "logs", name, "-n", namespace, "--tail", str(tail)] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return {"logs": result.stdout} except subprocess.CalledProcessError as e: return {"error": f"Failed to get logs: {str(e)}"}

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/abhijeetka/mcp-k8s-server'

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