vpc_create_volume
Create a block storage volume in IBM Cloud VPC by specifying name, zone, capacity in GB, and optionally profile and region.
Instructions
Create a block storage volume
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| zone | Yes | ||
| capacity | Yes | GB | |
| profile | No | e.g. general-purpose | |
| region | No |
Implementation Reference
- src/tools/vpc/index.ts:96-101 (registration)Registration of the 'vpc_create_volume' tool on the MCP server using server.tool(). Defines the tool name, description, input schema (name, zone, capacity, profile, region), and the handler callback.
server.tool("vpc_create_volume", "Create a block storage volume", { name: z.string(), zone: z.string(), capacity: z.number().describe("GB"), profile: z.string().optional().describe("e.g. general-purpose"), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); return client.post(vpcUrl(p.region||r, "/volumes"), {name:p.name,zone:{name:p.zone},capacity:p.capacity,profile:{name:p.profile||"general-purpose"}}); })); - src/tools/vpc/index.ts:99-101 (handler)The handler function for vpc_create_volume. It calls assertWriteAllowed (via w()), then posts to the IBM Cloud VPC API /volumes endpoint with the provided name, zone, capacity, and profile parameters.
}, async (p) => safeTool(async () => { w(); return client.post(vpcUrl(p.region||r, "/volumes"), {name:p.name,zone:{name:p.zone},capacity:p.capacity,profile:{name:p.profile||"general-purpose"}}); })); - src/tools/vpc/index.ts:97-98 (schema)Input schema definition using Zod for vpc_create_volume. Defines required fields: name (string), zone (string), capacity (number, GB); and optional fields: profile (string, e.g. general-purpose), region (string).
name: z.string(), zone: z.string(), capacity: z.number().describe("GB"), profile: z.string().optional().describe("e.g. general-purpose"), region: z.string().optional(), - src/lib/utils.ts:14-18 (helper)assertWriteAllowed helper - called by the handler to verify write operations are allowed before making the API call.
export function assertWriteAllowed(allowWrite: boolean): void { if (!allowWrite) { throw new WriteNotAllowedError(); } } - src/lib/utils.ts:23-27 (helper)vpcUrl helper - constructs the full VPC API URL for the given region and path (e.g., /volumes) with version and generation query parameters.
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`; }