list_security_groups
Retrieve and filter security groups in Apache CloudStack by name or associated virtual machine ID. Manage cloud resources efficiently with this integration tool.
Instructions
List security groups
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| securitygroupname | No | Security group name to filter | |
| virtualmachineid | No | VM ID to show associated security groups |
Implementation Reference
- src/handlers/security-handlers.ts:44-70 (handler)The main handler function for the 'list_security_groups' tool. It calls the CloudStack client to list security groups, processes the response, and formats it as a text content block for the MCP response.
async handleListSecurityGroups(args: any) { const result = await this.cloudStackClient.listSecurityGroups(args); const securityGroups = result.listsecuritygroupsresponse?.securitygroup || []; const securityGroupList = securityGroups.map((sg: any) => ({ id: sg.id, name: sg.name, description: sg.description, account: sg.account, domain: sg.domain, ingressrule: sg.ingressrule || [], egressrule: sg.egressrule || [] })); return { content: [ { type: 'text', text: `Found ${securityGroupList.length} security groups:\n\n${securityGroupList .map((sg: any) => `• ${sg.name} (${sg.id})\n Description: ${sg.description}\n Account: ${sg.account}\n Domain: ${sg.domain}\n Ingress Rules: ${sg.ingressrule.length}\n Egress Rules: ${sg.egressrule.length}\n` ) .join('\n')}` } ] }; } - The tool definition including name, description, and input schema for 'list_security_groups'.
{ name: 'list_security_groups', description: 'List security groups', inputSchema: { type: 'object', properties: { securitygroupname: { type: 'string', description: 'Security group name to filter', }, virtualmachineid: { type: 'string', description: 'VM ID to show associated security groups', }, }, additionalProperties: false, }, }, - src/server.ts:204-205 (registration)Registration and dispatch of the 'list_security_groups' tool in the MCP server's CallToolRequestSchema handler switch statement.
case 'list_security_groups': return await this.securityHandlers.handleListSecurityGroups(args); - src/cloudstack-client.ts:281-283 (helper)Helper method in CloudStackClient that performs the actual API request to CloudStack's listSecurityGroups endpoint.
async listSecurityGroups(params: CloudStackParams = {}): Promise<CloudStackResponse> { return this.request('listSecurityGroups', params); }