get_disk_image
Retrieve detailed information about a specific disk image from the Civo cloud platform using its ID and optional region identifier.
Instructions
Get details of a specific disk image
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Disk image ID | |
| region | No | Region identifier |
Implementation Reference
- src/api/disk-images.ts:32-54 (handler)Core handler function that executes the get_disk_image tool logic by making an API request to Civo to retrieve disk image details.export async function getDiskImage(params: { id: string; region: string; }): Promise<CivoDiskImage> { checkRateLimit(); const url = new URL(`${CIVO_API_URL}/disk_images/${params.id}`); url.searchParams.set('region', params.region); const response = await fetch(url.toString(), { headers: { Authorization: `Bearer ${CIVO_API_KEY}`, }, }); if (!response.ok) { throw new Error( `Civo API error: ${response.status} ${response.statusText}` ); } return response.json(); }
- src/tools/disk-images.ts:17-34 (schema)Schema definition for the get_disk_image tool, including input validation schema, description, and name.export const GET_DISK_IMAGE_TOOL: Tool = { name: 'get_disk_image', description: 'Get details of a specific disk image', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Disk image ID', }, region: { type: 'string', description: 'Region identifier', }, }, required: ['id'], }, };
- src/index.ts:79-79 (registration)Registers the get_disk_image tool schema in the MCP server's capabilities.tools dictionary.[GET_DISK_IMAGE_TOOL.name]: GET_DISK_IMAGE_TOOL,
- src/index.ts:198-229 (handler)MCP server dispatch handler for get_disk_image tool calls: validates input, calls the core getDiskImage function, and formats the response text.case 'get_disk_image': { if ( typeof args !== 'object' || args === null || typeof args.id !== 'string' ) { throw new Error('Invalid arguments for get_disk_image'); } const image = await getDiskImage({ id: args.id as string, region: args.region as string, }); return { content: [ { type: 'text', text: 'Disk Image Details:\n' + `ID: ${image.id}\n` + `Name: ${image.name}\n` + `Version: ${image.version}\n` + `State: ${image.state}\n` + `Distribution: ${image.distribution}\n` + `Description: ${image.description || 'None'}\n` + `Label: ${image.label || 'None'}`, }, ], isError: false, }; }