get_services
Retrieve all Kubernetes services in a specified namespace to monitor and manage network access for applications.
Instructions
Get all services 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_services"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | default |
Implementation Reference
- kubernetes.py:35-43 (handler)Handler function for the 'get_services' tool. Uses kubectl to fetch services in the given namespace as JSON, decorated with @mcp.tool() for registration.
@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)}"}