get_logs
Retrieve pod logs from Kubernetes clusters to monitor application performance, debug issues, and analyze container behavior.
Instructions
Get the logs of a specific pod
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| namespace | No | default | |
| tail | No |
Implementation Reference
- kubernetes.py:158-167 (handler)The handler function for the 'get_logs' tool. It uses kubectl to fetch the last 'tail' lines of logs from the specified pod in the given namespace. Returns the logs or an error message.@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)}"}