vpc_get_vpc
Retrieve details of a Virtual Private Cloud (VPC) by providing its ID. Optionally specify the region to scope the query.
Instructions
Get VPC details
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vpc_id | Yes | VPC ID | |
| region | No |
Implementation Reference
- src/tools/vpc/index.ts:16-18 (handler)The handler for vpc_get_vpc tool. It registers an MCP tool that takes vpc_id (required) and region (optional, defaults to configured region) parameters, and makes a GET request to the VPC API endpoint /vpcs/{vpc_id} using the IBMCloudAPIClient, wrapped in safeTool for error handling.
server.tool("vpc_get_vpc", "Get VPC details", { vpc_id: z.string().describe("VPC ID"), region: z.string().optional(), }, async (p) => safeTool(() => client.get(vpcUrl(p.region||r, `/vpcs/${p.vpc_id}`)))); - src/tools/vpc/index.ts:17-18 (schema)The input schema for vpc_get_vpc. Uses Zod validation: vpc_id is a required string, region is optional string (falls back to configured region).
vpc_id: z.string().describe("VPC ID"), region: z.string().optional(), }, async (p) => safeTool(() => client.get(vpcUrl(p.region||r, `/vpcs/${p.vpc_id}`)))); - src/tools/vpc/index.ts:16-18 (registration)Registration of the vpc_get_vpc tool via server.tool() - the standard MCP server registration pattern. This is within the registerVPCTools function which is called from src/server.ts line 53.
server.tool("vpc_get_vpc", "Get VPC details", { vpc_id: z.string().describe("VPC ID"), region: z.string().optional(), }, async (p) => safeTool(() => client.get(vpcUrl(p.region||r, `/vpcs/${p.vpc_id}`)))); - src/server.ts:53-54 (registration)The top-level registration call from createServer() that invokes registerVPCTools, which in turn registers all VPC tools including vpc_get_vpc.
registerVPCTools(server, client, config); console.error(` ✓ VPC Infrastructure (35 tools)`); - src/lib/utils.ts:23-27 (helper)The vpcUrl helper function that builds the full VPC API URL including region, path, API version, and generation parameter. Used by vpc_get_vpc to construct https://{region}.iaas.cloud.ibm.com/v1/vpcs/{vpc_id}?version=2024-11-19&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`; }