get_deployments
Retrieve all deployments in a specified Kubernetes namespace using a simplified interface with the MCP Kubernetes Server, streamlining cluster management tasks.
Instructions
Get all deployments in the specified namespace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | default |
Implementation Reference
- kubernetes.py:76-84 (handler)Handler function decorated with @mcp.tool() that executes 'kubectl get deployments' in the given namespace and returns the JSON output or an error.@mcp.tool() async def get_deployments(namespace: str = "default") -> dict: """Get all deployments in the specified namespace""" try: cmd = ["kubectl", "get", "deployments", "-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 nodes: {str(e)}"}