Skip to main content
Glama

list_load_balancers

Retrieve classic load balancers in an Oracle Cloud compartment to view IP addresses, shape, and state information for infrastructure management.

Instructions

List all classic load balancers in a compartment.

Args:
    compartment_id: OCID of the compartment to list load balancers from

Returns:
    List of load balancers with their IP addresses, shape, and state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compartment_idYes

Implementation Reference

  • Core handler function that executes the logic to list OCI load balancers in a compartment using the OCI SDK.
    def list_load_balancers(load_balancer_client: oci.load_balancer.LoadBalancerClient, 
                            compartment_id: str) -> List[Dict[str, Any]]:
        """
        List all load balancers in a compartment.
        
        Args:
            load_balancer_client: OCI LoadBalancer client
            compartment_id: OCID of the compartment
            
        Returns:
            List of load balancers with their details
        """
        try:
            load_balancers_response = oci.pagination.list_call_get_all_results(
                load_balancer_client.list_load_balancers,
                compartment_id
            )
            
            load_balancers = []
            for lb in load_balancers_response.data:
                load_balancers.append({
                    "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,
                })
            
            logger.info(f"Found {len(load_balancers)} load balancers in compartment {compartment_id}")
            return load_balancers
            
        except Exception as e:
            logger.exception(f"Error listing load balancers: {e}")
            raise
  • MCP tool registration decorator and wrapper function that registers 'list_load_balancers' tool and delegates to the core handler.
    @mcp.tool(name="list_load_balancers")
    @mcp_tool_wrapper(
        start_msg="Listing load balancers in compartment {compartment_id}...",
        error_prefix="Error listing load balancers"
    )
    async def mcp_list_load_balancers(ctx: Context, compartment_id: str) -> List[Dict[str, Any]]:
        """
        List all classic load balancers in a compartment.
    
        Args:
            compartment_id: OCID of the compartment to list load balancers from
    
        Returns:
            List of load balancers with their IP addresses, shape, and state
        """
        return list_load_balancers(oci_clients["load_balancer"], compartment_id)
  • Import statement that brings the load balancer handler functions into the MCP server scope for registration.
    from mcp_server_oci.tools.load_balancer import (
        list_load_balancers,
        get_load_balancer,
        list_network_load_balancers,
        get_network_load_balancer,
    )
  • Initialization of the OCI LoadBalancerClient used by the tool, stored in oci_clients dict.
    load_balancer_client = oci.load_balancer.LoadBalancerClient(config)
    network_load_balancer_client = oci.network_load_balancer.NetworkLoadBalancerClient(config)
    kms_vault_client = oci.key_management.KmsVaultClient(config)
    usage_api_client = oci.usage_api.UsageapiClient(config)
    budget_client = oci.budget.BudgetClient(config)
    monitoring_client = oci.monitoring.MonitoringClient(config)
    logging_search_client = oci.loggingsearch.LogSearchClient(config)
    logging_client = oci.logging.LoggingManagementClient(config)
    container_engine_client = oci.container_engine.ContainerEngineClient(config)
    
    oci_clients = {
        "compute": compute_client,
        "identity": identity_client,
        "network": network_client,
        "object_storage": object_storage_client,
        "block_storage": block_storage_client,
        "file_storage": file_storage_client,
        "database": database_client,
        "load_balancer": load_balancer_client,
        "network_load_balancer": network_load_balancer_client,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states this is a list operation but doesn't disclose behavioral traits like pagination, rate limits, authentication requirements, error conditions, or whether it's read-only (though implied by 'List'). For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by separate 'Args' and 'Returns' sections. Every sentence adds value: the first defines scope, the second explains the parameter, and the third outlines the return data. No wasted words, and it's front-loaded with the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is moderately complete. It covers the purpose, parameter meaning, and return content, but lacks behavioral details (e.g., pagination, errors) and doesn't reference sibling tools. For a simple list operation, this is adequate but has clear gaps in usage and transparency.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description includes an 'Args' section that explains the single parameter ('compartment_id: OCID of the compartment to list load balancers from'), adding meaningful context beyond the schema (which has 0% description coverage and only shows title 'Compartment Id'). This compensates well for the low schema coverage, though it doesn't detail format constraints like OCID structure.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('classic load balancers in a compartment'), specifying the scope ('all classic load balancers') which distinguishes it from sibling tools like 'get_load_balancer' (singular) and 'list_network_load_balancers' (different type). The purpose is specific and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_load_balancer' (for a specific load balancer) or 'list_network_load_balancers' (for a different load balancer type), nor does it specify prerequisites or exclusions. Usage context is implied but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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