get_statefulsets
Retrieve all StatefulSets in a specified Kubernetes namespace using a simplified interface for managing clusters via natural language commands.
Instructions
Get all statefulsets in the specified namespace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | default |
Implementation Reference
- kubernetes.py:107-116 (handler)The handler function for the 'get_statefulsets' tool. It executes a kubectl command to fetch all StatefulSets in the given namespace (default: 'default') and returns them as a JSON dictionary. Includes error handling for subprocess failures.@mcp.tool() async def get_statefulsets(namespace: str = "default") -> dict: """Get all statefulsets in the specified namespace""" try: cmd = ["kubectl", "get", "statefulsets", "-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 statefulsets: {str(e)}"}