get_services
Retrieve all Kubernetes services within a specified namespace using the MCP Kubernetes Server's simplified interface for managing clusters with natural language commands.
Instructions
Get all services in the specified namespace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | default |
Implementation Reference
- kubernetes.py:35-43 (handler)The handler function for the 'get_services' tool. It executes 'kubectl get services' in the specified namespace (default 'default'), parses the JSON output, and returns it or an error dictionary if the command fails.@mcp.tool() async def get_services(namespace: str = "default") -> dict: """Get all services in the specified namespace""" try: cmd = ["kubectl", "get", "services", "-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 services: {str(e)}"}