get_pods
Retrieve all pods within a specified Kubernetes namespace using the MCP Kubernetes Server. Simplifies cluster management by providing pod details through natural language commands.
Instructions
Get all pods in the specified namespace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | default |
Implementation Reference
- kubernetes.py:15-24 (handler)The handler function for the 'get_pods' tool. It uses kubectl to retrieve pods in the given namespace as JSON and returns the parsed data or an error dictionary.@mcp.tool() async def get_pods(namespace: str = "default") -> dict: """Get all pods in the specified namespace""" try: cmd = ["kubectl", "get", "pods", "-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 pods: {str(e)}"}