vpc_list_vpcs
List all Virtual Private Clouds (VPCs) in a specified region, with optional pagination using limit and start parameters.
Instructions
List all VPCs in the region
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| start | No | ||
| region | No |
Implementation Reference
- src/tools/vpc/index.ts:12-14 (registration)Tool registration via server.tool() call. Registers 'vpc_list_vpcs' with the MCP server, defining the schema and handler inline.
server.tool("vpc_list_vpcs", "List all VPCs in the region", { limit: z.number().optional(), start: z.string().optional(), region: z.string().optional(), }, async (p) => safeTool(() => client.get(vpcUrl(p.region||r, "/vpcs"), {limit:p.limit,start:p.start}))); - src/tools/vpc/index.ts:13-13 (schema)Input schema using zod: optional 'limit' (number), 'start' (string), and 'region' (string) parameters.
limit: z.number().optional(), start: z.string().optional(), region: z.string().optional(), - src/tools/vpc/index.ts:14-14 (handler)Handler function: wrapped in safeTool(), makes a GET request to VPC API endpoint '/vpcs' with optional limit/start query params, using the provided or default region.
}, async (p) => safeTool(() => client.get(vpcUrl(p.region||r, "/vpcs"), {limit:p.limit,start:p.start}))); - src/lib/utils.ts:23-27 (helper)vpcUrl helper builds the full VPC API URL with region, path, version, and generation 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`; } - src/lib/utils.ts:70-77 (helper)safeTool helper wraps async handlers to catch errors and return proper MCP success/error response format.
export async function safeTool<T>(fn: () => Promise<T>): Promise<ReturnType<typeof successContent> | ReturnType<typeof errorContent>> { try { const result = await fn(); return successContent(result); } catch (error) { return errorContent(error); } }