Skip to main content
Glama

get_vpc_details

Retrieve detailed information about a specific VPC network in Google Cloud Platform by providing the project ID and network name. Ideal for managing and monitoring network configurations.

Instructions

    Get detailed information about a specific VPC network.
    
    Args:
        project_id: The ID of the GCP project
        network_name: The name of the VPC network
    
    Returns:
        Detailed information about the specified VPC network
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
network_nameYes
project_idYes

Implementation Reference

  • The handler function for the 'get_vpc_details' MCP tool. It retrieves detailed information about a specific VPC network, including subnets and peerings, using the Google Cloud Compute API.
        @mcp.tool()
        def get_vpc_details(project_id: str, network_name: str) -> str:
            """
            Get detailed information about a specific VPC network.
            
            Args:
                project_id: The ID of the GCP project
                network_name: The name of the VPC network
            
            Returns:
                Detailed information about the specified VPC network
            """
            try:
                from google.cloud import compute_v1
                
                # Initialize the Compute Engine client for networks
                network_client = compute_v1.NetworksClient()
                subnet_client = compute_v1.SubnetworksClient()
                
                # Get network details
                network = network_client.get(project=project_id, network=network_name)
                
                # Format the response
                details = []
                details.append(f"Name: {network.name}")
                details.append(f"ID: {network.id}")
                details.append(f"Description: {network.description or 'None'}")
                details.append(f"Self Link: {network.self_link}")
                details.append(f"Creation Time: {network.creation_timestamp}")
                details.append(f"Subnet Mode: {'Auto' if network.auto_create_subnetworks else 'Custom'}")
                details.append(f"Routing Mode: {network.routing_config.routing_mode if network.routing_config else 'Unknown'}")
                details.append(f"MTU: {network.mtu}")
                
                # If it's a custom subnet mode network, get all subnets
                if not network.auto_create_subnetworks:
                    # List all subnets in this network
                    request = compute_v1.ListSubnetworksRequest(project=project_id)
                    subnets = []
                    
                    for item in subnet_client.list(request=request):
                        # Check if the subnet belongs to this network
                        if network.name in item.network:
                            cidr = item.ip_cidr_range
                            region = item.region.split('/')[-1]
                            purpose = f", Purpose: {item.purpose}" if item.purpose else ""
                            private_ip = ", Private Google Access: Enabled" if item.private_ip_google_access else ""
                            subnets.append(f"  - {item.name} (Region: {region}, CIDR: {cidr}{purpose}{private_ip})")
                    
                    if subnets:
                        details.append(f"Subnets ({len(subnets)}):\n" + "\n".join(subnets))
                
                # List peering connections if any
                if network.peerings:
                    peerings = []
                    for peering in network.peerings:
                        state = peering.state
                        network_name = peering.network.split('/')[-1]
                        peerings.append(f"  - {network_name} (State: {state})")
                    
                    if peerings:
                        details.append(f"Peerings ({len(peerings)}):\n" + "\n".join(peerings))
                
                details_str = "\n".join(details)
                
                return f"""
    VPC Network Details:
    {details_str}
    """
            except Exception as e:
                return f"Error getting VPC network details: {str(e)}"

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/henihaddad/gcp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server