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, )

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