Skip to main content
Glama

list_vpc_networks

Retrieve a list of Virtual Private Cloud (VPC) networks within a specified Google Cloud Platform (GCP) project to manage and analyze your network configurations.

Instructions

    List Virtual Private Cloud (VPC) networks in a GCP project.
    
    Args:
        project_id: The ID of the GCP project to list VPC networks for
    
    Returns:
        List of VPC networks in the specified GCP project
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Implementation Reference

  • The handler function for the 'list_vpc_networks' tool. It lists all VPC networks in the specified GCP project using the Google Cloud Compute API, formats the output with details like subnet mode, creation time, and subnets, and handles errors.
        def list_vpc_networks(project_id: str) -> str:
            """
            List Virtual Private Cloud (VPC) networks in a GCP project.
            
            Args:
                project_id: The ID of the GCP project to list VPC networks for
            
            Returns:
                List of VPC networks in the specified GCP project
            """
            try:
                from google.cloud import compute_v1
                
                # Initialize the Compute Engine client for networks
                client = compute_v1.NetworksClient()
                
                # List networks
                request = compute_v1.ListNetworksRequest(project=project_id)
                networks = client.list(request=request)
                
                # Format the response
                networks_list = []
                for network in networks:
                    subnet_mode = "Auto" if network.auto_create_subnetworks else "Custom"
                    creation_time = network.creation_timestamp if network.creation_timestamp else "Unknown"
                    
                    # Get subnet information if available
                    subnets = []
                    if not network.auto_create_subnetworks and network.subnetworks:
                        for subnet_url in network.subnetworks:
                            subnet_name = subnet_url.split('/')[-1]
                            subnet_region = subnet_url.split('/')[-3]
                            subnets.append(f"    - {subnet_name} (Region: {subnet_region})")
                    
                    network_info = f"- {network.name} (Mode: {subnet_mode}, Created: {creation_time})"
                    if subnets:
                        network_info += "\n  Subnets:\n" + "\n".join(subnets)
                        
                    networks_list.append(network_info)
                
                if not networks_list:
                    return f"No VPC networks found in project {project_id}."
                
                networks_str = "\n".join(networks_list)
                
                return f"""
    VPC Networks in GCP Project {project_id}:
    {networks_str}
    """
            except Exception as e:
                return f"Error listing VPC networks: {str(e)}"
  • The registration of the 'list_vpc_networks' tool occurs within the register_tools function using the @mcp.tool() decorator.
    def register_tools(mcp):
        """Register all networking tools with the MCP server."""
        
        @mcp.tool()
  • The docstring provides the schema description for args (project_id: str) and returns (str with formatted list). The type hint project_id: str also defines input schema.
    """
    List Virtual Private Cloud (VPC) networks in a GCP project.
    
    Args:
        project_id: The ID of the GCP project to list VPC networks for
    
    Returns:
        List of VPC networks in the specified GCP project
    """
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool lists VPC networks but doesn't describe key behaviors: whether it requires specific permissions, how results are formatted (e.g., JSON, paginated), error handling, or rate limits. For a read operation with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and well-structured: a clear purpose statement followed by Args and Returns sections. It avoids redundancy and uses minimal sentences. However, the Returns section could be more specific (e.g., 'List of VPC network objects'), and the formatting includes unnecessary indentation, slightly affecting readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (1 parameter, no output schema, no annotations), the description is incomplete. It lacks behavioral details (e.g., permissions, pagination), usage context, and output specifics. While the purpose is clear, the agent would struggle to use it effectively without additional context or trial-and-error, especially compared to more descriptive siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal semantic value beyond the input schema. It documents the single parameter ('project_id') in the Args section, but the schema already defines it as a required string with title 'Project Id'. With 0% schema description coverage, the description compensates slightly by confirming the parameter's purpose, but doesn't provide format examples (e.g., 'my-project-123') or constraints. This meets the baseline for adequate but not helpful.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'List Virtual Private Cloud (VPC) networks in a GCP project.' It specifies the verb ('List') and resource ('VPC networks'), and distinguishes it from siblings like 'get_vpc_details' (which likely retrieves details of a specific VPC) by focusing on listing all networks. However, it doesn't explicitly differentiate from other list tools (e.g., 'list_subnets'), so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication, project access), compare it to siblings like 'list_subnets' or 'get_vpc_details', or specify use cases (e.g., inventory, troubleshooting). The agent must infer usage from the name and context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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