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
    """

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.3/5.0
Behavior2/5

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

With no annotations, the description carries full behavioral burden. It states the return is a list of VPC networks but does not disclose permissions, side effects, pagination, or any other behavioral traits. The word 'List' implies a read operation, but this is not explicit.

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

Conciseness5/5

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

The description is concise and well-structured with a purpose sentence followed by Args and Returns sections. It contains no fluff and is easy to scan.

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

Completeness3/5

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

For a simple one-parameter tool, the description provides the essential input and output information. However, since there is no output schema, it does not describe the structure of the returned VPC networks or pagination behavior, leaving it minimally viable but not comprehensive.

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 schema has one parameter (project_id) with no description, and the description explains it as 'the ID of the GCP project to list VPC networks for,' which adds a bit of meaning. However, it lacks format examples or additional context, so it only partially compensates for the 0% schema coverage.

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 lists VPC networks in a GCP project with a specific verb and resource. It does not explicitly distinguish from siblings like get_vpc_details or list_subnets, but the scope and action are clear.

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

Usage Guidelines3/5

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

The description implies usage when you need to list VPC networks, but it does not provide explicit when-to-use guidance or alternatives among the sibling tools. There is no mention of scenarios where this tool is preferred over get_vpc_details or list_subnets.

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