Skip to main content
Glama

create_snapshot

Generate a snapshot of a Compute Engine disk in Google Cloud Platform. Provide project ID, zone, disk name, and snapshot name to save disk data for backup or replication.

Instructions

    Create a snapshot of a Compute Engine disk.
    
    Args:
        project_id: The ID of the GCP project
        zone: The zone where the disk is located (e.g., "us-central1-a")
        disk_name: The name of the disk to snapshot
        snapshot_name: The name for the new snapshot
        description: Optional description for the snapshot
    
    Returns:
        Status message indicating whether the snapshot was created successfully
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNo
disk_nameYes
project_idYes
snapshot_nameYes
zoneYes

Implementation Reference

  • The core handler function for the 'create_snapshot' MCP tool. It uses the Google Cloud Compute API to create a snapshot from a specified disk, waits for completion, and returns success or error message.
    @mcp.tool()
    def create_snapshot(project_id: str, zone: str, disk_name: str, snapshot_name: str, description: str = "") -> str:
        """
        Create a snapshot of a Compute Engine disk.
        
        Args:
            project_id: The ID of the GCP project
            zone: The zone where the disk is located (e.g., "us-central1-a")
            disk_name: The name of the disk to snapshot
            snapshot_name: The name for the new snapshot
            description: Optional description for the snapshot
        
        Returns:
            Status message indicating whether the snapshot was created successfully
        """
        try:
            from google.cloud import compute_v1
            
            # Initialize the Disks client
            disks_client = compute_v1.DisksClient()
            
            # Create the snapshot request
            snapshot = compute_v1.Snapshot()
            snapshot.name = snapshot_name
            if description:
                snapshot.description = description
            
            # Create the snapshot
            operation = disks_client.create_snapshot(
                project=project_id,
                zone=zone,
                disk=disk_name,
                snapshot_resource=snapshot
            )
            
            # Wait for the operation to complete
            operation_client = compute_v1.ZoneOperationsClient()
            
            # This is a synchronous call that will wait until the operation is complete
            while operation.status != compute_v1.Operation.Status.DONE:
                operation = operation_client.get(project=project_id, zone=zone, operation=operation.name.split('/')[-1])
                import time
                time.sleep(1)
            
            if operation.error:
                return f"Error creating snapshot {snapshot_name}: {operation.error.errors[0].message}"
            
            return f"Snapshot {snapshot_name} of disk {disk_name} in zone {zone} created successfully."
        except Exception as e:
            return f"Error creating snapshot: {str(e)}"
  • Registers the compute tools module, which includes the create_snapshot tool, by calling its register_tools function with the MCP server instance.
    compute_tools.register_tools(mcp)
  • The function that defines and registers all compute tools, including create_snapshot via decorators.
    def register_tools(mcp):

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.2/5.0
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 of disclosing side effects and requirements. It only states the action and return value, with no mention of permissions needed, whether the operation is asynchronous, whether the disk must exist, or any impact on the disk. This is insufficient for a mutation tool.

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 and concise, with a clear purpose sentence, an Args list, and a Returns section. Every part serves a purpose, no redundant text exists, and it is front-loaded with the primary action. It is appropriately sized for the tool's complexity.

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

Completeness2/5

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

Given the tool has 5 parameters, no annotations, and no output schema, the description is incomplete. It omits usage guidance, prerequisites, error conditions, and behavioral details like synchronous vs asynchronous execution. The minimal Args/Returns structure does not suffice for an API operation of this complexity.

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 no descriptions (coverage 0%), but the description includes an Args section that defines each parameter, adding meaning like the zone example ('us-central1-a') and noting description is optional. However, the explanations are minimal and lack constraints, dependencies, or format details, so it only partially compensates for the schema gap.

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 specific action: 'Create a snapshot of a Compute Engine disk.' This identifies the verb, resource, and scope, distinguishing it from sibling tools like list_snapshots or create_backup. The purpose is immediately clear from the first sentence.

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 prerequisites (e.g., disk existence), exclusions, or situations where other tools (like create_backup) would be more appropriate. Usage context is only implied by 'Create a snapshot,' but no explicit direction is given.

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