Skip to main content
Glama

get_vnic

Retrieve detailed information about a specific Virtual Network Interface Card (VNIC) in Oracle Cloud Infrastructure, including IP addresses, subnet details, and Network Security Group associations.

Instructions

Get detailed information about a specific VNIC. Args: vnic_id: OCID of the VNIC to retrieve Returns: Detailed VNIC information including IP addresses, subnet, and NSG associations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vnic_idYes

Implementation Reference

  • MCP tool handler for 'get_vnic': decorated with @mcp.tool and wrapper, calls the core get_vnic helper with OCI network client and vnic_id parameter.
    @mcp.tool(name="get_vnic") @mcp_tool_wrapper( start_msg="Getting VNIC details for {vnic_id}...", success_msg="Retrieved VNIC details successfully", error_prefix="Error getting VNIC details" ) async def mcp_get_vnic(ctx: Context, vnic_id: str) -> Dict[str, Any]: """ Get detailed information about a specific VNIC. Args: vnic_id: OCID of the VNIC to retrieve Returns: Detailed VNIC information including IP addresses, subnet, and NSG associations """ return get_vnic(oci_clients["network"], vnic_id)
  • Core helper function implementing the logic to retrieve VNIC details from OCI VirtualNetworkClient, formats the response including private/public IP, subnet, IPv6 if available, and handles errors.
    def get_vnic(network_client: oci.core.VirtualNetworkClient, vnic_id: str) -> Dict[str, Any]: """ Get details of a specific VNIC. Args: network_client: OCI VirtualNetwork client vnic_id: OCID of the VNIC Returns: Details of the VNIC """ try: # Get the VNIC details vnic = network_client.get_vnic(vnic_id).data # Format the VNIC details vnic_details = { "id": vnic.id, "display_name": vnic.display_name, "hostname_label": vnic.hostname_label, "is_primary": vnic.is_primary, "lifecycle_state": vnic.lifecycle_state, "mac_address": vnic.mac_address, "private_ip": vnic.private_ip, "public_ip": vnic.public_ip, "subnet_id": vnic.subnet_id, "time_created": str(vnic.time_created), "compartment_id": vnic.compartment_id, } # Add IPv6 addresses if available if hasattr(vnic, 'ipv6_addresses') and vnic.ipv6_addresses: vnic_details["ipv6_addresses"] = vnic.ipv6_addresses logger.info(f"Retrieved details for VNIC {vnic_id}") return vnic_details except Exception as e: logger.exception(f"Error getting VNIC details: {e}") raise
  • Registration of the 'get_vnic' tool using @mcp.tool decorator in the main MCP server file.
    @mcp.tool(name="get_vnic") @mcp_tool_wrapper( start_msg="Getting VNIC details for {vnic_id}...", success_msg="Retrieved VNIC details successfully", error_prefix="Error getting VNIC details" ) async def mcp_get_vnic(ctx: Context, vnic_id: str) -> Dict[str, Any]: """ Get detailed information about a specific VNIC. Args: vnic_id: OCID of the VNIC to retrieve Returns: Detailed VNIC information including IP addresses, subnet, and NSG associations """ return get_vnic(oci_clients["network"], vnic_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