Skip to main content
Glama

start_instance

Initiate the launch of a Compute Engine instance on Google Cloud Platform by specifying the project ID, zone, and instance name, and receive a status message upon completion.

Instructions

Start a 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 start Returns: Status message indicating whether the instance was started successfully

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instance_nameYes
project_idYes
zoneYes

Implementation Reference

  • The core handler implementation for the 'start_instance' tool. It uses the Google Cloud Compute Engine API to start a specified VM instance, polls the operation status until completion, and returns success or error message. The @mcp.tool() decorator registers it with the MCP server using the function name as the tool name and type hints/docstring for schema.
    def start_instance(project_id: str, zone: str, instance_name: str) -> str: """ Start a 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 start Returns: Status message indicating whether the instance was started successfully """ try: from google.cloud import compute_v1 # Initialize the Compute Engine client client = compute_v1.InstancesClient() # Start the instance operation = client.start(project=project_id, zone=zone, instance=instance_name) # 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 starting instance {instance_name}: {operation.error.errors[0].message}" return f"Instance {instance_name} in zone {zone} started successfully." except Exception as e: return f"Error starting instance: {str(e)}"
  • Top-level registration call in the main MCP server file that invokes the compute module's register_tools function, thereby registering the start_instance tool (among others) with the FastMCP server instance.
    compute_tools.register_tools(mcp)
  • Module-level registration function that defines and registers all compute tools, including start_instance via nested @mcp.tool() decorators.
    def register_tools(mcp):
  • Input schema defined by function parameters (project_id: str, zone: str, instance_name: str) and output str, along with detailed docstring describing args and return value, used by MCP for tool schema generation.
    def start_instance(project_id: str, zone: str, instance_name: str) -> str: """ Start a 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 start Returns: Status message indicating whether the instance was started successfully """

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