Skip to main content
Glama
code-alchemist01

MCP Cloud Services Server

aws_stop_ec2_instance

Stop an AWS EC2 instance to manage costs or perform maintenance by specifying the instance ID and optional region.

Instructions

Stop an EC2 instance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instanceIdYesEC2 instance ID
regionNoAWS region

Implementation Reference

  • Handler logic for the 'aws_stop_ec2_instance' tool. Extracts the instanceId from input parameters, calls AWSAdapter.stopEC2Instance, and returns a success message.
    case 'aws_stop_ec2_instance': { const instanceId = params.instanceId as string; await adapter.stopEC2Instance(instanceId); return { success: true, message: `Instance ${instanceId} stopped successfully` }; }
  • Input schema for the tool, requiring 'instanceId' and optionally accepting 'region'.
    inputSchema: { type: 'object', properties: { instanceId: { type: 'string', description: 'EC2 instance ID', }, region: { type: 'string', description: 'AWS region', }, }, required: ['instanceId'], },
  • Tool registration definition including name, description, and schema, exported as part of awsTools array which is used in the main server.
    { name: 'aws_stop_ec2_instance', description: 'Stop an EC2 instance', inputSchema: { type: 'object', properties: { instanceId: { type: 'string', description: 'EC2 instance ID', }, region: { type: 'string', description: 'AWS region', }, }, required: ['instanceId'], }, },
  • Supporting method in AWSAdapter that performs the actual AWS API call to stop the EC2 instance using StopInstancesCommand.
    async stopEC2Instance(instanceId: string): Promise<void> { await this.initializeClients(); if (!this.ec2Client) throw new Error('EC2 client not initialized'); try { const command = new StopInstancesCommand({ InstanceIds: [instanceId] }); await this.ec2Client.send(command); } catch (error) { throw new Error(`Failed to stop instance: ${error instanceof Error ? error.message : String(error)}`); } }
  • src/server.ts:64-65 (registration)
    Routing logic in the main tool call handler that directs calls to 'aws_stop_ec2_instance' (via awsTools check) to the AWS-specific handleAWSTool function.
    if (awsTools.some((t) => t.name === name)) { result = await handleAWSTool(name, args || {});

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/code-alchemist01/Cloud-mcp_server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server