get_cronjobs
Retrieve scheduled cronjobs from a Kubernetes namespace to monitor automated tasks and job scheduling in your cluster.
Instructions
Get all cronjobs in the specified namespace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | default |
Implementation Reference
- kubernetes.py:97-105 (handler)The handler function for the 'get_cronjobs' MCP tool, decorated with @mcp.tool() for automatic registration. It retrieves cronjobs from a Kubernetes namespace using kubectl and returns the JSON output or an error dictionary.@mcp.tool() async def get_cronjobs(namespace: str = "default") -> dict: """Get all cronjobs in the specified namespace""" try: cmd = ["kubectl", "get", "cronjobs", "-n", namespace, "-o", "json"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return json.loads(result.stdout) except subprocess.CalledProcessError as e: return {"error": f"Failed to get cronjobs: {str(e)}"}