Skip to main content
Glama

get_oke_cluster_kubeconfig

Retrieve kubeconfig content for accessing an Oracle Container Engine (OKE) cluster, enabling kubectl connectivity and Kubernetes cluster management.

Instructions

Get the kubeconfig file content for accessing an OKE cluster. Args: cluster_id: OCID of the cluster Returns: Kubeconfig content in YAML format that can be saved to ~/.kube/config or used with kubectl --kubeconfig flag

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cluster_idYes

Implementation Reference

  • Core handler function that executes the logic to fetch kubeconfig from OCI Container Engine using the create_kubeconfig API.
    def get_cluster_kubeconfig(container_engine_client: oci.container_engine.ContainerEngineClient, cluster_id: str) -> Dict[str, Any]: """ Get the kubeconfig for a specific OKE cluster. Args: container_engine_client: OCI ContainerEngine client cluster_id: OCID of the cluster Returns: Kubeconfig content and metadata """ try: # Create kubeconfig request create_kubeconfig_details = oci.container_engine.models.CreateClusterKubeconfigContentDetails() # Get the kubeconfig kubeconfig_response = container_engine_client.create_kubeconfig( cluster_id, create_kubeconfig_details ) # Read the kubeconfig content kubeconfig_content = kubeconfig_response.data.content.decode('utf-8') if hasattr(kubeconfig_response.data, 'content') else kubeconfig_response.data.text result = { "cluster_id": cluster_id, "kubeconfig": kubeconfig_content, "format": "yaml", "usage": "Save this content to ~/.kube/config or use with kubectl --kubeconfig flag", } logger.info(f"Retrieved kubeconfig for cluster {cluster_id}") return result except Exception as e: logger.exception(f"Error getting cluster kubeconfig: {e}") raise
  • MCP tool registration with name 'get_oke_cluster_kubeconfig' and wrapper handler that invokes the core implementation from oke.py.
    @mcp.tool(name="get_oke_cluster_kubeconfig") @mcp_tool_wrapper( start_msg="Getting kubeconfig for cluster {cluster_id}...", error_prefix="Error getting cluster kubeconfig" ) async def mcp_get_oke_cluster_kubeconfig(ctx: Context, cluster_id: str) -> Dict[str, Any]: """ Get the kubeconfig file content for accessing an OKE cluster. Args: cluster_id: OCID of the cluster Returns: Kubeconfig content in YAML format that can be saved to ~/.kube/config or used with kubectl --kubeconfig flag """ return get_cluster_kubeconfig(oci_clients["container_engine"], cluster_id)
  • Import statement that brings the get_cluster_kubeconfig helper function into scope for use in the MCP server.
    from mcp_server_oci.tools.oke import ( list_clusters, get_cluster, list_node_pools, get_node_pool, get_cluster_kubeconfig, list_work_requests, get_work_request, )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jopsis/mcp-server-oci'

If you have feedback or need assistance with the MCP directory API, please join our Discord server