vpc_delete_vpc
Delete a VPC by providing its ID. Optionally specify the region to target.
Instructions
Delete a VPC
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vpc_id | Yes | ||
| region | No |
Implementation Reference
- src/tools/vpc/index.ts:27-29 (registration)Tool 'vpc_delete_vpc' is registered on the MCP server with schema (vpc_id: string, region?: string) and a handler that performs an authenticated DELETE request to the VPC API endpoint.
server.tool("vpc_delete_vpc", "Delete a VPC", { vpc_id: z.string(), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); await client.delete(vpcUrl(p.region||r, `/vpcs/${p.vpc_id}`)); return {message:`VPC ${p.vpc_id} deleted`}; })); - src/tools/vpc/index.ts:27-29 (handler)The inline handler function for vpc_delete_vpc: asserts write permissions, calls client.delete to the VPC API endpoint, and returns a success message.
server.tool("vpc_delete_vpc", "Delete a VPC", { vpc_id: z.string(), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); await client.delete(vpcUrl(p.region||r, `/vpcs/${p.vpc_id}`)); return {message:`VPC ${p.vpc_id} deleted`}; })); - src/tools/vpc/index.ts:27-28 (schema)The input schema for vpc_delete_vpc defines two parameters: vpc_id (required string) and region (optional string).
server.tool("vpc_delete_vpc", "Delete a VPC", { vpc_id: z.string(), region: z.string().optional(), - src/lib/utils.ts:14-27 (helper)assertWriteAllowed helper checks the allowWrite config flag; w() call in the handler ensures write operations are permitted.
export function assertWriteAllowed(allowWrite: boolean): void { if (!allowWrite) { throw new WriteNotAllowedError(); } } /** * Build a VPC API URL with the required version 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:23-27 (helper)vpcUrl helper builds the VPC API URL with region, path, version parameter, and generation=2.
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`; }