Skip to main content
Glama

get_instance_details

Retrieve detailed information about a specific Google Compute Engine instance by providing the project ID, zone, and instance name, enabling precise resource monitoring and management.

Instructions

    Get detailed information about a specific Compute Engine instance.
    
    Args:
        project_id: The ID of the GCP project
        zone: The zone where the instance is located (e.g., "us-central1-a")
        instance_name: The name of the instance to get details for
    
    Returns:
        Detailed information about the specified Compute Engine instance
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instance_nameYes
project_idYes
zoneYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the core logic for retrieving and formatting detailed information about a GCP Compute Engine instance using the google-cloud-compute library.
        @mcp.tool()
        def get_instance_details(project_id: str, zone: str, instance_name: str) -> str:
            """
            Get detailed information about a specific Compute Engine instance.
            
            Args:
                project_id: The ID of the GCP project
                zone: The zone where the instance is located (e.g., "us-central1-a")
                instance_name: The name of the instance to get details for
            
            Returns:
                Detailed information about the specified Compute Engine instance
            """
            try:
                from google.cloud import compute_v1
                
                # Initialize the Compute Engine client
                client = compute_v1.InstancesClient()
                
                # Get the instance details
                instance = client.get(project=project_id, zone=zone, instance=instance_name)
                
                # Format machine type
                machine_type = instance.machine_type.split('/')[-1] if instance.machine_type else "Unknown"
                
                # Format creation timestamp
                creation_timestamp = instance.creation_timestamp if instance.creation_timestamp else "Unknown"
                
                # Format boot disk
                boot_disk = "None"
                if instance.disks:
                    for disk in instance.disks:
                        if disk.boot:
                            boot_disk = disk.source.split('/')[-1] if disk.source else "Unknown"
                            break
                
                # Get IP addresses
                network_interfaces = []
                if instance.network_interfaces:
                    for i, iface in enumerate(instance.network_interfaces):
                        network = iface.network.split('/')[-1] if iface.network else "Unknown"
                        subnetwork = iface.subnetwork.split('/')[-1] if iface.subnetwork else "Unknown"
                        internal_ip = iface.network_i_p or "None"
                        
                        # Check for external IP
                        external_ip = "None"
                        if iface.access_configs:
                            external_ip = iface.access_configs[0].nat_i_p or "None"
                        
                        network_interfaces.append(f"  Interface {i}:\n    Network: {network}\n    Subnetwork: {subnetwork}\n    Internal IP: {internal_ip}\n    External IP: {external_ip}")
                
                networks_str = "\n".join(network_interfaces) if network_interfaces else "  None"
                
                # Get attached disks
                disks = []
                if instance.disks:
                    for i, disk in enumerate(instance.disks):
                        disk_name = disk.source.split('/')[-1] if disk.source else "Unknown"
                        disk_type = "Boot" if disk.boot else "Data"
                        auto_delete = "Yes" if disk.auto_delete else "No"
                        mode = disk.mode if disk.mode else "Unknown"
                        
                        disks.append(f"  Disk {i}:\n    Name: {disk_name}\n    Type: {disk_type}\n    Mode: {mode}\n    Auto-delete: {auto_delete}")
                
                disks_str = "\n".join(disks) if disks else "  None"
                
                # Get labels
                labels = []
                if instance.labels:
                    for key, value in instance.labels.items():
                        labels.append(f"  {key}: {value}")
                
                labels_str = "\n".join(labels) if labels else "  None"
                
                # Get metadata
                metadata_items = []
                if instance.metadata and instance.metadata.items:
                    for item in instance.metadata.items:
                        metadata_items.append(f"  {item.key}: {item.value}")
                
                metadata_str = "\n".join(metadata_items) if metadata_items else "  None"
                
                return f"""
    Compute Engine Instance Details for {instance_name}:
    
    Project: {project_id}
    Zone: {zone}
    Machine Type: {machine_type}
    Status: {instance.status}
    Creation Time: {creation_timestamp}
    CPU Platform: {instance.cpu_platform}
    Boot Disk: {boot_disk}
    
    Network Interfaces:
    {networks_str}
    
    Disks:
    {disks_str}
    
    Labels:
    {labels_str}
    
    Metadata:
    {metadata_str}
    
    Service Accounts: {"Yes" if instance.service_accounts else "None"}
    """
            except Exception as e:
                return f"Error getting instance details: {str(e)}"
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. It states the tool retrieves information, implying a read-only operation, but does not disclose behavioral traits such as authentication requirements, rate limits, error handling, or what 'detailed information' includes. The description is minimal and lacks context beyond the basic operation.

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 front-loaded, with the purpose stated first, followed by parameter explanations and return information. Every sentence adds value, though the return statement is vague. It avoids redundancy and is structured for clarity.

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?

Given the tool's complexity (3 parameters, no annotations, no output schema), the description is adequate but has gaps. It covers the purpose and parameters well but lacks details on behavior, authentication, and output format. For a read operation, this is minimally viable, but more context would improve completeness.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining each parameter: 'project_id' as 'The ID of the GCP project', 'zone' with an example ('e.g., "us-central1-a"'), and 'instance_name' as 'The name of the instance to get details for'. This clarifies semantics beyond the schema's titles, though it could provide more detail on format constraints.

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

Purpose5/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: 'Get detailed information about a specific Compute Engine instance.' It specifies the verb ('Get'), resource ('Compute Engine instance'), and scope ('detailed information'), distinguishing it from sibling tools like 'list_compute_instances' (which lists multiple instances) and 'get_gcp_project_details' (which focuses on projects).

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 does not mention sibling tools like 'list_compute_instances' for listing instances or 'get_sql_instance_details' for SQL instances, nor does it specify prerequisites or exclusions. Usage is implied by the purpose but not explicitly stated.

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