get_network_security_group
Retrieve detailed configuration and security rules for a specific Network Security Group in Oracle Cloud Infrastructure to manage network access controls.
Instructions
Get detailed information about a specific Network Security Group.
Args:
nsg_id: OCID of the NSG to retrieve
Returns:
Detailed NSG information with all security rules
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nsg_id | Yes |
Implementation Reference
- mcp_server_oci/tools/security.py:198-226 (handler)Handler function that fetches and formats details of a specific Network Security Group (NSG) using the OCI VirtualNetworkClient. Returns a dictionary with id, display_name, compartment_id, vcn_id, lifecycle_state, and time_created.def get_network_security_group(network_client: oci.core.VirtualNetworkClient, nsg_id: str) -> Dict[str, Any]: """ Get details of a specific network security group. Args: network_client: OCI VirtualNetwork client nsg_id: OCID of the network security group Returns: Details of the network security group """ try: nsg = network_client.get_network_security_group(nsg_id).data nsg_details = { "id": nsg.id, "display_name": nsg.display_name, "compartment_id": nsg.compartment_id, "vcn_id": nsg.vcn_id, "lifecycle_state": nsg.lifecycle_state, "time_created": str(nsg.time_created), } logger.info(f"Retrieved details for network security group {nsg_id}") return nsg_details except Exception as e: logger.exception(f"Error getting network security group details: {e}") raise
- mcp_server_oci/mcp_server.py:775-792 (registration)MCP tool registration for 'get_network_security_group'. Wraps the handler with logging, error handling via mcp_tool_wrapper, and calls the handler with the network client from oci_clients.@mcp.tool(name="get_network_security_group") @mcp_tool_wrapper( start_msg="Getting network security group details for {nsg_id}...", success_msg="Retrieved network security group details successfully", error_prefix="Error getting network security group details" ) async def mcp_get_network_security_group(ctx: Context, nsg_id: str) -> Dict[str, Any]: """ Get detailed information about a specific Network Security Group. Args: nsg_id: OCID of the NSG to retrieve Returns: Detailed NSG information with all security rules """ return get_network_security_group(oci_clients["network"], nsg_id)