get_load_balancer
Retrieve detailed information about a specific Oracle Cloud Infrastructure classic load balancer, including backend sets, listeners, and certificates, by providing its OCID.
Instructions
Get detailed information about a specific classic load balancer.
Args:
load_balancer_id: OCID of the load balancer to retrieve
Returns:
Detailed load balancer information including backend sets, listeners, and certificates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| load_balancer_id | Yes |
Implementation Reference
- mcp_server_oci/mcp_server.py:1226-1243 (handler)The MCP tool handler function 'mcp_get_load_balancer' that executes the tool logic by calling the helper function with the OCI LoadBalancerClient and load_balancer_id.@mcp.tool(name="get_load_balancer") @mcp_tool_wrapper( start_msg="Getting load balancer details for {load_balancer_id}...", success_msg="Retrieved load balancer details successfully", error_prefix="Error getting load balancer details" ) async def mcp_get_load_balancer(ctx: Context, load_balancer_id: str) -> Dict[str, Any]: """ Get detailed information about a specific classic load balancer. Args: load_balancer_id: OCID of the load balancer to retrieve Returns: Detailed load balancer information including backend sets, listeners, and certificates """ return get_load_balancer(oci_clients["load_balancer"], load_balancer_id)
- Helper function that retrieves and formats detailed information about a specific OCI Load Balancer using the OCI SDK, including backend sets, listeners, and other configurations.def get_load_balancer(load_balancer_client: oci.load_balancer.LoadBalancerClient, load_balancer_id: str) -> Dict[str, Any]: """ Get details of a specific load balancer. Args: load_balancer_client: OCI LoadBalancer client load_balancer_id: OCID of the load balancer Returns: Details of the load balancer """ try: lb = load_balancer_client.get_load_balancer(load_balancer_id).data # Format backend sets backend_sets = {} if lb.backend_sets: for name, backend_set in lb.backend_sets.items(): backend_sets[name] = { "name": name, "policy": backend_set.policy, "backends": [ { "ip_address": backend.ip_address, "port": backend.port, "weight": backend.weight, "drain": backend.drain, "backup": backend.backup, "offline": backend.offline, } for backend in backend_set.backends ] if backend_set.backends else [], "health_checker": { "protocol": backend_set.health_checker.protocol, "url_path": backend_set.health_checker.url_path, "port": backend_set.health_checker.port, "return_code": backend_set.health_checker.return_code, "retries": backend_set.health_checker.retries, "timeout_in_millis": backend_set.health_checker.timeout_in_millis, "interval_in_millis": backend_set.health_checker.interval_in_millis, "response_body_regex": backend_set.health_checker.response_body_regex, } if backend_set.health_checker else None, } # Format listeners listeners = {} if lb.listeners: for name, listener in lb.listeners.items(): listeners[name] = { "name": name, "default_backend_set_name": listener.default_backend_set_name, "port": listener.port, "protocol": listener.protocol, "hostname_names": listener.hostname_names, "path_route_set_name": listener.path_route_set_name, "ssl_configuration": { "certificate_name": listener.ssl_configuration.certificate_name if listener.ssl_configuration else None, "verify_peer_certificate": listener.ssl_configuration.verify_peer_certificate if listener.ssl_configuration else None, "verify_depth": listener.ssl_configuration.verify_depth if listener.ssl_configuration else None, } if listener.ssl_configuration else None, "connection_configuration": { "idle_timeout": listener.connection_configuration.idle_timeout if listener.connection_configuration else None, "backend_tcp_proxy_protocol_version": listener.connection_configuration.backend_tcp_proxy_protocol_version if listener.connection_configuration else None, } if listener.connection_configuration else None, } lb_details = { "id": lb.id, "display_name": lb.display_name, "compartment_id": lb.compartment_id, "lifecycle_state": lb.lifecycle_state, "time_created": str(lb.time_created), "shape_name": lb.shape_name, "is_private": lb.is_private, "ip_addresses": [ { "ip_address": ip.ip_address, "is_public": ip.is_public, } for ip in lb.ip_addresses ] if lb.ip_addresses else [], "subnet_ids": lb.subnet_ids, "network_security_group_ids": lb.network_security_group_ids, "backend_sets": backend_sets, "listeners": listeners, "certificates": dict(lb.certificates) if lb.certificates else {}, "path_route_sets": dict(lb.path_route_sets) if lb.path_route_sets else {}, "hostnames": dict(lb.hostnames) if lb.hostnames else {}, } logger.info(f"Retrieved details for load balancer {load_balancer_id}") return lb_details except Exception as e: logger.exception(f"Error getting load balancer details: {e}") raise
- mcp_server_oci/mcp_server.py:1226-1226 (registration)The @mcp.tool decorator that registers the 'get_load_balancer' tool with MCP.@mcp.tool(name="get_load_balancer")