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

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.7/5.0
Behavior2/5

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

Since no annotations are provided, the description carries full burden for behavioral disclosure. It only restates the action and returns vague 'detailed information' without addressing permissions, side effects, error behavior, or the read-only nature. This is a significant gap for a tool with no annotation support.

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 well-structured with a clear purpose sentence, Args, and Returns sections. It is concise, front-loaded, and every sentence contributes essential information without redundancy.

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?

The tool has no output schema or annotations, so the description must adequately explain return values. 'Detailed information' is vague and does not specify what fields or data are included. Given the presence of a list_compute_instances sibling, more detail about the return structure would help the agent decide when to use this tool.

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?

The schema has 0% description coverage, but the description's Args section explains each parameter meaningfully, including an example for zone ('us-central1-a'). It compensates well for the schema gap, though it could provide more format or constraint details.

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 action ('Get'), the resource ('Compute Engine instance'), and the scope ('specific', distinguishing from listing). This also differentiates from sibling tools like list_compute_instances and get_sql_instance_details.

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 use for retrieving details of a single instance but does not explicitly mention when to use this vs list_compute_instances or other alternatives. No exclusions or conditional guidance are provided, making the usage implied rather than explicit.

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