vpc_create_security_group
Create a security group for an IBM Cloud VPC to define network access rules and control traffic.
Instructions
Create a security group
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| vpc_id | Yes | ||
| region | No |
Implementation Reference
- src/tools/vpc/index.ts:112-114 (registration)Registration of the 'vpc_create_security_group' tool on the MCP server via server.tool() with zod schema for inputs (name, vpc_id, region) and handler that calls client.post to the IBM Cloud VPC API.
server.tool("vpc_create_security_group", "Create a security group", { name: z.string(), vpc_id: z.string(), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); return client.post(vpcUrl(p.region||r, "/security_groups"), {name:p.name,vpc:{id:p.vpc_id}}); })); - src/tools/vpc/index.ts:112-114 (handler)The handler function that executes the tool logic: validates write access via assertWriteAllowed(), then POSTs to /security_groups with name and vpc.id as the request body.
server.tool("vpc_create_security_group", "Create a security group", { name: z.string(), vpc_id: z.string(), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); return client.post(vpcUrl(p.region||r, "/security_groups"), {name:p.name,vpc:{id:p.vpc_id}}); })); - src/tools/vpc/index.ts:112-114 (schema)Input schema defined using zod: name (z.string()), vpc_id (z.string()), and optional region (z.string().optional()). No explicit output schema - returns raw API response wrapped via safeTool.
server.tool("vpc_create_security_group", "Create a security group", { name: z.string(), vpc_id: z.string(), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); return client.post(vpcUrl(p.region||r, "/security_groups"), {name:p.name,vpc:{id:p.vpc_id}}); })); - src/tools/vpc/index.ts:7-9 (helper)The registerVPCTools function that sets up all VPC tools. Contains imports for safeTool, assertWriteAllowed, and vpcUrl utilities used by the handler.
export function registerVPCTools(server: McpServer, client: IBMCloudAPIClient, config: ServerConfig) { const r = config.region; const w = () => assertWriteAllowed(config.allowWrite);