list_security_groups
Retrieve AWS security group configurations to manage network access controls and review firewall rules for EC2 instances and VPC resources.
Instructions
Lists all security groups.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vpc_id | No | Optional: Filter by VPC ID. |
Implementation Reference
- src/index.ts:1438-1452 (handler)Handler function that executes the list_security_groups tool by calling DescribeSecurityGroupsCommand on EC2 client, optionally filtering by VPC ID, and returns formatted security group list.if (name === "list_security_groups") { const vpcId = (args as any)?.vpc_id; const filter = vpcId ? [{ Name: "vpc-id", Values: [vpcId] }] : undefined; const command = new DescribeSecurityGroupsCommand({ Filters: filter }); const response = await ec2Client.send(command); const sgs = response.SecurityGroups?.map(s => ({ GroupId: s.GroupId, GroupName: s.GroupName, Description: s.Description, VpcId: s.VpcId })) || []; return { content: [{ type: "text", text: JSON.stringify(sgs, null, 2) }] };
- src/index.ts:340-348 (registration)Registration of the list_security_groups tool in the ListToolsRequestHandler, including its description and input schema.{ name: "list_security_groups", description: "Lists all security groups.", inputSchema: { type: "object", properties: { vpc_id: { type: "string", description: "Optional: Filter by VPC ID." } } }
- src/index.ts:346-347 (schema)Input schema definition allowing optional vpc_id parameter.vpc_id: { type: "string", description: "Optional: Filter by VPC ID." } }