Skip to main content
Glama

list_network_load_balancers

Retrieve network load balancers in a specified Oracle Cloud compartment to monitor their IP addresses and operational status.

Instructions

List all network load balancers in a compartment.

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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compartment_idYes

Implementation Reference

  • Registration of the MCP tool 'list_network_load_balancers' using the @mcp.tool decorator with custom wrapper for logging and error handling.
    @mcp.tool(name="list_network_load_balancers")
    @mcp_tool_wrapper(
        start_msg="Listing network load balancers in compartment {compartment_id}...",
        error_prefix="Error listing network load balancers"
    )
  • The MCP tool handler: an async function that takes compartment_id, retrieves the pre-initialized OCI NetworkLoadBalancerClient, and delegates to the helper function for execution.
    async def mcp_list_network_load_balancers(ctx: Context, compartment_id: str) -> List[Dict[str, Any]]:
        """
        List all network load balancers in a compartment.
    
        Args:
            compartment_id: OCID of the compartment to list network load balancers from
    
        Returns:
            List of network load balancers with their IP addresses and state
        """
        return list_network_load_balancers(oci_clients["network_load_balancer"], compartment_id)
  • Core helper function that performs pagination using OCI SDK, iterates over results, extracts and formats key attributes (id, display_name, lifecycle_state, ip_addresses, etc.) into user-friendly dicts, with logging and error propagation.
    def list_network_load_balancers(network_load_balancer_client: oci.network_load_balancer.NetworkLoadBalancerClient, 
                                    compartment_id: str) -> List[Dict[str, Any]]:
        """
        List all network load balancers in a compartment.
        
        Args:
            network_load_balancer_client: OCI NetworkLoadBalancer client
            compartment_id: OCID of the compartment
            
        Returns:
            List of network load balancers with their details
        """
        try:
            nlbs_response = oci.pagination.list_call_get_all_results(
                network_load_balancer_client.list_network_load_balancers,
                compartment_id
            )
            
            nlbs = []
            for nlb in nlbs_response.data:
                nlbs.append({
                    "id": nlb.id,
                    "display_name": nlb.display_name,
                    "compartment_id": nlb.compartment_id,
                    "lifecycle_state": nlb.lifecycle_state,
                    "time_created": str(nlb.time_created),
                    "is_private": nlb.is_private,
                    "ip_addresses": [
                        {
                            "ip_address": ip.ip_address,
                            "is_public": ip.is_public,
                            "ip_version": ip.ip_version,
                        }
                        for ip in nlb.ip_addresses
                    ] if nlb.ip_addresses else [],
                    "subnet_id": nlb.subnet_id,
                    "network_security_group_ids": nlb.network_security_group_ids,
                    "is_preserve_source_destination": nlb.is_preserve_source_destination,
                })
            
            logger.info(f"Found {len(nlbs)} network load balancers in compartment {compartment_id}")
            return nlbs
            
        except Exception as e:
            logger.exception(f"Error listing network load balancers: {e}")
            raise
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the return format ('List of network load balancers with their IP addresses and state'), which is helpful, but lacks critical details like pagination behavior, rate limits, authentication requirements, error conditions, or whether the operation is idempotent. For a list operation with zero annotation coverage, this leaves significant gaps.

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 dedicated 'Args' and 'Returns' sections. Every sentence earns its place by providing essential information without redundancy or fluff.

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?

For a simple list operation with one parameter and no output schema, the description covers the basic purpose, parameter meaning, and return format. However, without annotations, it misses behavioral aspects like pagination or error handling. It's adequate but has clear gaps in operational context.

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 explicitly documents the single parameter ('compartment_id: OCID of the compartment to list network load balancers from'), adding crucial semantic context beyond the schema's bare title ('Compartment Id'). With 0% schema description coverage and only one parameter, this effectively compensates for the schema's lack of documentation.

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 specific action ('List all network load balancers') and resource ('in a compartment'), distinguishing it from sibling tools like 'get_network_load_balancer' (singular) and 'list_load_balancers' (different resource type). It precisely defines the scope and target resource.

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?

No guidance is provided on when to use this tool versus alternatives like 'get_network_load_balancer' (for a specific instance) or 'list_load_balancers' (for a different type of load balancer). The description only states what it does, not when it's appropriate relative to other tools.

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