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
| Name | Required | Description | Default |
|---|---|---|---|
| instanceId | Yes | EC2 instance ID | |
| region | No | AWS region |
Implementation Reference
- src/tools/aws-tools.ts:171-175 (handler)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` }; }
- src/tools/aws-tools.ts:82-95 (schema)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'], },
- src/tools/aws-tools.ts:79-96 (registration)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'], }, },
- src/adapters/aws-adapter.ts:121-131 (helper)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 || {});