vpc_list_images
List available OS images for provisioning VPC instances. Filter by visibility (public/private) or region.
Instructions
List available OS images
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| visibility | No | ||
| region | No |
Implementation Reference
- src/tools/vpc/index.ts:87-89 (registration)Registration of the vpc_list_images tool with schema params (limit, visibility, region) and handler calling GET /images via the API client.
server.tool("vpc_list_images", "List available OS images", { limit: z.number().optional(), visibility: z.enum(["public","private"]).optional(), region: z.string().optional(), }, async (p) => safeTool(() => client.get(vpcUrl(p.region||r, "/images"), {limit:p.limit,visibility:p.visibility}))); - src/tools/vpc/index.ts:89-89 (handler)The handler function for vpc_list_images. It calls client.get with the VPC API URL for /images, passing optional limit and visibility query params, wrapped in safeTool for error handling.
}, async (p) => safeTool(() => client.get(vpcUrl(p.region||r, "/images"), {limit:p.limit,visibility:p.visibility}))); - src/tools/vpc/index.ts:88-88 (schema)Input schema for vpc_list_images: optional limit (number), visibility (enum: public/private), and region (string).
limit: z.number().optional(), visibility: z.enum(["public","private"]).optional(), region: z.string().optional(), - src/lib/utils.ts:23-27 (helper)Helper function that builds the full VPC API URL with region, path, version, and generation=2 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)Wrapper that executes the handler function and catches errors, returning either success or error formatted MCP responses.
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); } }