vpc_create_vpc
Create a new Virtual Private Cloud (VPC) in IBM Cloud with specified name, region, resource group, and address prefix management mode.
Instructions
Create a new VPC
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| address_prefix_management | No | ||
| resource_group_id | No | ||
| region | No |
Implementation Reference
- src/tools/vpc/index.ts:20-25 (handler)The handler function for vpc_create_vpc: calls client.post() to create a VPC via the IBM Cloud API, using the constructed VPC URL. Also calls assertWriteAllowed (w()) to enforce read-only mode.
server.tool("vpc_create_vpc", "Create a new VPC", { name: z.string(), address_prefix_management: z.enum(["auto","manual"]).optional(), resource_group_id: z.string().optional(), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); return client.post(vpcUrl(p.region||r, "/vpcs"), {name:p.name,address_prefix_management:p.address_prefix_management||"auto",resource_group:p.resource_group_id?{id:p.resource_group_id}:undefined}); })); - src/tools/vpc/index.ts:20-22 (schema)Input schema for vpc_create_vpc defined with Zod: name (string), address_prefix_management (optional 'auto'|'manual'), resource_group_id (optional string), region (optional string).
server.tool("vpc_create_vpc", "Create a new VPC", { name: z.string(), address_prefix_management: z.enum(["auto","manual"]).optional(), resource_group_id: z.string().optional(), region: z.string().optional(), - src/server.ts:53-54 (registration)Registration call: registerVPCTools(server, client, config) invoked during server setup to register all VPC tools including vpc_create_vpc.
registerVPCTools(server, client, config); console.error(` ✓ VPC Infrastructure (35 tools)`); - src/lib/utils.ts:23-27 (helper)vpcUrl helper function: builds the full IBM Cloud VPC API URL with region, path, version, and generation=2 query parameter.
export function vpcUrl(region: string, path: string, version: string = "2024-11-19"): string { const base = `https://${region}.iaas.cloud.ibm.com/v1${path}`; const sep = base.includes("?") ? "&" : "?"; return `${base}${sep}version=${version}&generation=2`; } - src/lib/utils.ts:14-17 (helper)assertWriteAllowed helper: throws WriteNotAllowedError if write operations are not permitted (read-only mode).
export function assertWriteAllowed(allowWrite: boolean): void { if (!allowWrite) { throw new WriteNotAllowedError(); }