create_firewall_rule
Add a firewall rule to secure CloudStack MCP Server by specifying IP address, protocol, ports, and CIDR list to control incoming and outgoing traffic.
Instructions
Create a firewall rule
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cidrlist | No | CIDR list (comma-separated) | |
| endport | No | End port | |
| ipaddressid | Yes | Public IP address ID | |
| protocol | Yes | Protocol (tcp, udp, icmp) | |
| startport | No | Start port |
Implementation Reference
- src/handlers/network-handlers.ts:108-119 (handler)The main handler function that executes the create_firewall_rule tool. It calls the CloudStack client to create the rule and returns a formatted MCP response.async handleCreateFirewallRule(args: any) { const result = await this.cloudStackClient.createFirewallRule(args); return { content: [ { type: 'text', text: `Created firewall rule. Job ID: ${result.createfirewallruleresponse?.jobid}\nRule ID: ${result.createfirewallruleresponse?.id}` } ] }; }
- Tool definition including name, description, and input schema for validation.{ name: 'create_firewall_rule', description: 'Create a firewall rule', inputSchema: { type: 'object', properties: { ipaddressid: { type: 'string', description: 'Public IP address ID', }, protocol: { type: 'string', description: 'Protocol (tcp, udp, icmp)', }, startport: { type: 'number', description: 'Start port', }, endport: { type: 'number', description: 'End port', }, cidrlist: { type: 'string', description: 'CIDR list (comma-separated)', }, }, required: ['ipaddressid', 'protocol'], additionalProperties: false, }, },
- src/server.ts:160-161 (registration)Dispatch registration in the MCP server that routes calls to the network handler.case 'create_firewall_rule': return await this.networkHandlers.handleCreateFirewallRule(args);
- src/cloudstack-client.ts:205-207 (helper)Helper method in CloudStack client that wraps the API request for creating a firewall rule.async createFirewallRule(params: CloudStackParams): Promise<CloudStackResponse> { return this.request('createFirewallRule', params); }