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

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