vpc_start_instance
Start a stopped IBM Cloud VSI by specifying the instance ID and optionally the region.
Instructions
Start a stopped VSI
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instance_id | Yes | ||
| region | No |
Implementation Reference
- src/tools/vpc/index.ts:70-72 (registration)Tool registration for vpc_start_instance using MCP server.tool() with Zod schema for inputs and async handler that posts a start action to the VPC API.
server.tool("vpc_start_instance", "Start a stopped VSI", { instance_id: z.string(), region: z.string().optional(), }, async (p) => safeTool(async () => { w(); return client.post(vpcUrl(p.region||r, `/instances/${p.instance_id}/actions`),{type:"start"}); })); - src/tools/vpc/index.ts:72-72 (handler)The handler function that takes input params, asserts write permission, and makes a POST request to the VPC API to start the instance.
}, async (p) => safeTool(async () => { w(); return client.post(vpcUrl(p.region||r, `/instances/${p.instance_id}/actions`),{type:"start"}); })); - src/tools/vpc/index.ts:70-71 (schema)Zod schema defining the required 'instance_id' (string) and optional 'region' (string) input parameters.
server.tool("vpc_start_instance", "Start a stopped VSI", { instance_id: z.string(), region: z.string().optional(), - src/lib/utils.ts:23-27 (helper)Helper function that builds the 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)Helper wrapper that catches errors from the tool handler and returns proper MCP success/error content 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); } }