Skip to main content
Glama

get_subnet

Retrieve detailed information about a specific Oracle Cloud Infrastructure subnet, including CIDR blocks, security lists, and routing configurations.

Instructions

Get detailed information about a specific subnet.

Args:
    subnet_id: OCID of the subnet to retrieve

Returns:
    Detailed subnet information including CIDR, security lists, and routing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subnet_idYes

Implementation Reference

  • Core handler function implementing the get_subnet tool logic: fetches subnet details from OCI API, formats response dictionary with key properties including CIDR block, security lists, and optional IPv6.
    def get_subnet(network_client: oci.core.VirtualNetworkClient, subnet_id: str) -> Dict[str, Any]:
        """
        Get details of a specific subnet.
        
        Args:
            network_client: OCI VirtualNetwork client
            subnet_id: OCID of the subnet
            
        Returns:
            Details of the subnet
        """
        try:
            # Get the subnet details
            subnet = network_client.get_subnet(subnet_id).data
            
            # Format the subnet details
            subnet_details = {
                "id": subnet.id,
                "name": subnet.display_name,
                "lifecycle_state": subnet.lifecycle_state,
                "cidr_block": subnet.cidr_block,
                "availability_domain": subnet.availability_domain,
                "compartment_id": subnet.compartment_id,
                "vcn_id": subnet.vcn_id,
                "route_table_id": subnet.route_table_id,
                "dhcp_options_id": subnet.dhcp_options_id,
                "security_list_ids": subnet.security_list_ids,
                "time_created": str(subnet.time_created),
                "prohibit_public_ip_on_vnic": subnet.prohibit_public_ip_on_vnic,
            }
            
            # Add IPv6 CIDR block if available
            if hasattr(subnet, 'ipv6_cidr_block') and subnet.ipv6_cidr_block:
                subnet_details["ipv6_cidr_block"] = subnet.ipv6_cidr_block
            
            logger.info(f"Retrieved details for subnet {subnet_id}")
            return subnet_details
            
        except Exception as e:
            logger.exception(f"Error getting subnet details: {e}")
            raise
  • MCP tool registration for 'get_subnet': defines the async MCP handler mcp_get_subnet, applies common wrapper for logging/error handling, imports and calls the core handler from network.py.
    @mcp.tool(name="get_subnet")
    @mcp_tool_wrapper(
        start_msg="Getting subnet details for {subnet_id}...",
        success_msg="Retrieved subnet details successfully",
        error_prefix="Error getting subnet details"
    )
    async def mcp_get_subnet(ctx: Context, subnet_id: str) -> Dict[str, Any]:
        """
        Get detailed information about a specific subnet.
    
        Args:
            subnet_id: OCID of the subnet to retrieve
    
        Returns:
            Detailed subnet information including CIDR, security lists, and routing
        """
        return get_subnet(oci_clients["network"], subnet_id)
  • Import statement bringing in the get_subnet handler function from network.py for use in tool registrations.
    from mcp_server_oci.tools.network import (
        list_vcns,
        get_vcn,
        list_subnets,
        get_subnet,
        list_vnics,
        get_vnic,
    )
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It indicates this is a read operation ('Get detailed information'), which implies non-destructive behavior, but doesn't cover important aspects like authentication requirements, rate limits, error conditions, or whether the data is real-time. The description lacks depth for a tool that likely interacts with cloud infrastructure.

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 appropriately sized and well-structured, with a clear purpose statement followed by brief sections for 'Args' and 'Returns'. Every sentence earns its place by providing essential information without redundancy, making it easy to scan and understand quickly.

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 moderate complexity (single parameter, no output schema, no annotations), the description is adequate but has gaps. It explains the parameter and return content, but lacks behavioral context like error handling or performance characteristics. For a cloud resource retrieval tool, more details on permissions or data freshness would improve completeness.

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 adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'subnet_id' is an 'OCID of the subnet to retrieve', clarifying the parameter's purpose and format (Oracle Cloud Identifier). This compensates well for the schema's lack of documentation, though it doesn't detail validation rules or examples.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('Get detailed information') and resource ('about a specific subnet'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_subnets' or 'get_vcn', which would require mentioning it retrieves a single subnet by ID rather than listing multiple.

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 'list_subnets' for browsing or 'get_vcn' for related network information, nor does it specify prerequisites such as needing the subnet's OCID. Usage is implied but not explicitly stated.

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