get_statefulsets
Retrieve all StatefulSets in a specified Kubernetes namespace to monitor and manage persistent application deployments.
Instructions
Get all statefulsets in the specified namespace
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_statefulsets"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | default |
Implementation Reference
- kubernetes.py:108-115 (handler)The main handler function for the 'get_statefulsets' tool. It runs 'kubectl get statefulsets' in the specified namespace, parses the JSON output, and returns it or an error dictionary.
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)}"} - kubernetes.py:107-107 (registration)The @mcp.tool() decorator registers the get_statefulsets function as an MCP tool with FastMCP.
@mcp.tool()