get_jobs
Retrieve all Kubernetes jobs within a specified namespace using commands on the MCP Kubernetes Server, simplifying cluster management tasks directly through LLM-driven interfaces.
Instructions
Get all jobs in the specified namespace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | default |
Implementation Reference
- kubernetes.py:86-94 (handler)The handler function for the 'get_jobs' tool. It is decorated with @mcp.tool() which registers it as an MCP tool. The function executes 'kubectl get jobs -o json' to retrieve jobs from the specified Kubernetes namespace and returns the parsed JSON or an error dictionary.@mcp.tool() async def get_jobs(namespace: str = "default") -> dict: """Get all jobs in the specified namespace""" try: cmd = ["kubectl", "get", "jobs", "-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 jobs: {str(e)}"}