list_oke_clusters
Retrieve all Kubernetes clusters in an Oracle Cloud compartment to view their configurations, endpoints, and current operational status.
Instructions
List all OKE (Container Engine for Kubernetes) clusters in a compartment.
Args:
compartment_id: OCID of the compartment
Returns:
List of OKE clusters with their details including Kubernetes version, endpoints, and lifecycle state
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| compartment_id | Yes |
Implementation Reference
- mcp_server_oci/mcp_server.py:1770-1771 (registration)Registration of the "list_oke_clusters" MCP tool using @mcp.tool decorator with custom wrapper for logging and error handling.@mcp.tool(name="list_oke_clusters") @mcp_tool_wrapper(
- mcp_server_oci/mcp_server.py:1775-1786 (handler)The MCP handler function that receives the MCP context and parameters, calls the core list_clusters helper with the container engine client, and returns the list of clusters.async def mcp_list_oke_clusters(ctx: Context, compartment_id: str) -> List[Dict[str, Any]]: """ List all OKE (Container Engine for Kubernetes) clusters in a compartment. Args: compartment_id: OCID of the compartment Returns: List of OKE clusters with their details including Kubernetes version, endpoints, and lifecycle state """ return list_clusters(oci_clients["container_engine"], compartment_id)
- mcp_server_oci/tools/oke.py:14-57 (helper)Core helper function that performs the actual OCI API call to list all OKE clusters in the specified compartment using the ContainerEngineClient, formats the response, and handles logging and exceptions.def list_clusters(container_engine_client: oci.container_engine.ContainerEngineClient, compartment_id: str) -> List[Dict[str, Any]]: """ List all OKE clusters in a compartment. Args: container_engine_client: OCI ContainerEngine client compartment_id: OCID of the compartment Returns: List of clusters with their details """ try: clusters_response = oci.pagination.list_call_get_all_results( container_engine_client.list_clusters, compartment_id ) clusters = [] for cluster in clusters_response.data: clusters.append({ "id": cluster.id, "name": cluster.name, "compartment_id": cluster.compartment_id, "lifecycle_state": cluster.lifecycle_state, "lifecycle_details": cluster.lifecycle_details, "vcn_id": cluster.vcn_id, "kubernetes_version": cluster.kubernetes_version, "time_created": str(cluster.time_created) if cluster.time_created else None, "time_updated": str(cluster.time_updated) if cluster.time_updated else None, "endpoint_config": { "subnet_id": cluster.endpoint_config.subnet_id if cluster.endpoint_config else None, "is_public_ip_enabled": cluster.endpoint_config.is_public_ip_enabled if cluster.endpoint_config else None, } if cluster.endpoint_config else None, "type": cluster.type if hasattr(cluster, 'type') else None, }) logger.info(f"Found {len(clusters)} OKE clusters in compartment {compartment_id}") return clusters except Exception as e: logger.exception(f"Error listing OKE clusters: {e}") raise