Skip to main content
Glama

get_vcn

Retrieve detailed information about a specific Oracle Cloud Infrastructure Virtual Cloud Network (VCN), including CIDR blocks, DNS configuration, and default resources by providing its OCID.

Instructions

Get detailed information about a specific VCN.

Args:
    vcn_id: OCID of the VCN to retrieve

Returns:
    Detailed VCN information including CIDR blocks, DNS configuration, and default resources

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vcn_idYes

Implementation Reference

  • Core handler function that executes the tool logic: retrieves VCN details from OCI API and formats the response.
    def get_vcn(network_client: oci.core.VirtualNetworkClient, vcn_id: str) -> Dict[str, Any]:
        """
        Get details of a specific VCN.
        
        Args:
            network_client: OCI VirtualNetwork client
            vcn_id: OCID of the VCN
            
        Returns:
            Details of the VCN
        """
        try:
            # Get the VCN details
            vcn = network_client.get_vcn(vcn_id).data
            
            # Format the VCN details
            vcn_details = {
                "id": vcn.id,
                "name": vcn.display_name,
                "lifecycle_state": vcn.lifecycle_state,
                "cidr_block": vcn.cidr_block,
                "time_created": str(vcn.time_created),
                "compartment_id": vcn.compartment_id,
                "dns_label": vcn.dns_label,
                "default_dhcp_options_id": vcn.default_dhcp_options_id,
                "default_route_table_id": vcn.default_route_table_id,
                "default_security_list_id": vcn.default_security_list_id,
            }
            
            # Add IPv6 CIDR blocks if available
            if hasattr(vcn, 'ipv6_cidr_blocks') and vcn.ipv6_cidr_blocks:
                vcn_details["ipv6_cidr_blocks"] = vcn.ipv6_cidr_blocks
            
            logger.info(f"Retrieved details for VCN {vcn_id}")
            return vcn_details
            
        except Exception as e:
            logger.exception(f"Error getting VCN details: {e}")
            raise
  • MCP tool registration for 'get_vcn' tool, including wrapper with error handling that delegates to the core handler.
    @mcp.tool(name="get_vcn")
    @mcp_tool_wrapper(
        start_msg="Getting VCN details for {vcn_id}...",
        success_msg="Retrieved VCN details successfully",
        error_prefix="Error getting VCN details"
    )
    async def mcp_get_vcn(ctx: Context, vcn_id: str) -> Dict[str, Any]:
        """
        Get detailed information about a specific VCN.
    
        Args:
            vcn_id: OCID of the VCN to retrieve
    
        Returns:
            Detailed VCN information including CIDR blocks, DNS configuration, and default resources
        """
        return get_vcn(oci_clients["network"], vcn_id)

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