list_subnets
Retrieve AWS subnet details including availability zones and available IP addresses to manage network resources and plan capacity.
Instructions
Lists subnets with availability zones and available IP counts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vpc_id | No | Optional: Filter by VPC ID. |
Implementation Reference
- src/index.ts:1357-1375 (handler)Handler function for the 'list_subnets' tool. Uses EC2 DescribeSubnetsCommand to list subnets, optionally filtered by vpc_id, and formats the response with key details like SubnetId, AvailabilityZone, and available IPs.if (name === "list_subnets") { const vpcId = (args as any)?.vpc_id; const input: any = {}; if (vpcId) input.Filters = [{ Name: "vpc-id", Values: [vpcId] }]; const command = new DescribeSubnetsCommand(input); const response = await ec2Client.send(command); const subnets = response.Subnets?.map(s => ({ SubnetId: s.SubnetId, VpcId: s.VpcId, AvailabilityZone: s.AvailabilityZone, CidrBlock: s.CidrBlock, AvailableIpAddressCount: s.AvailableIpAddressCount, Name: s.Tags?.find(t => t.Key === "Name")?.Value })) || []; return { content: [{ type: "text", text: JSON.stringify(subnets, null, 2) }] }; }
- src/index.ts:302-311 (registration)Registration of the 'list_subnets' tool in the ListToolsRequestSchema handler, defining its name, description, and input schema.{ name: "list_subnets", description: "Lists subnets with availability zones and available IP counts.", inputSchema: { type: "object", properties: { vpc_id: { type: "string", description: "Optional: Filter by VPC ID." } } } },
- src/index.ts:305-310 (schema)Input schema for the 'list_subnets' tool, defining optional vpc_id parameter.inputSchema: { type: "object", properties: { vpc_id: { type: "string", description: "Optional: Filter by VPC ID." } } }