Skip to main content
Glama

list_snapshots

Retrieve a list of disk snapshots within a specified Google Cloud Platform (GCP) project to manage and review backup data efficiently.

Instructions

List disk snapshots in a GCP project. Args: project_id: The ID of the GCP project to list snapshots for Returns: List of disk snapshots in the specified GCP project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Implementation Reference

  • The handler function for the 'list_snapshots' tool, decorated with @mcp.tool() for registration. It lists disk snapshots in a GCP project using the Google Cloud Compute API, formats them into a string response.
    @mcp.tool() def list_snapshots(project_id: str) -> str: """ List disk snapshots in a GCP project. Args: project_id: The ID of the GCP project to list snapshots for Returns: List of disk snapshots in the specified GCP project """ try: from google.cloud import compute_v1 # Initialize the Snapshots client client = compute_v1.SnapshotsClient() # List snapshots request = compute_v1.ListSnapshotsRequest(project=project_id) snapshots = client.list(request=request) # Format the response snapshots_list = [] for snapshot in snapshots: size_gb = snapshot.disk_size_gb status = snapshot.status source_disk = snapshot.source_disk.split('/')[-1] if snapshot.source_disk else "Unknown" creation_time = snapshot.creation_timestamp if snapshot.creation_timestamp else "Unknown" snapshots_list.append(f"- {snapshot.name} (Source: {source_disk}, Size: {size_gb} GB, Status: {status}, Created: {creation_time})") if not snapshots_list: return f"No snapshots found for project {project_id}." snapshots_str = "\n".join(snapshots_list) return f""" Disk Snapshots in GCP Project {project_id}: {snapshots_str} """ except Exception as e: return f"Error listing snapshots: {str(e)}"
  • The @mcp.tool() decorator registers the list_snapshots function as an MCP tool.
    @mcp.tool()

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