shutdown_instance
Shut down a Civo cloud instance by providing its instance ID and region.
Instructions
Shutdown a cloud instance on Civo
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Instance ID | |
| region | Yes | Region identifier |
Implementation Reference
- src/api/instances.ts:97-121 (handler)The core handler function that executes the shutdown_instance tool logic. It makes a PUT request to the Civo API endpoint /instances/{id}/stop to shut down the instance.
export async function shutdownInstance(params: { id: string; region: string; }): Promise<any> { checkRateLimit(); const url = `${CIVO_API_URL}/instances/${params.id}/stop`; const response = await fetch(url, { method: 'PUT', headers: { Authorization: `Bearer ${CIVO_API_KEY}`, }, body: new URLSearchParams({ region: params.region, }), }); if (!response.ok) { throw new Error( `Civo API error: ${response.status} ${response.statusText}` ); } return response.json(); } - src/tools/instances.ts:79-96 (schema)The tool definition/schema for shutdown_instance, defining its name, description, and input schema (id and region as required strings).
export const SHUTDOWN_INSTANCE_TOOL: Tool = { name: 'shutdown_instance', description: 'Shutdown a cloud instance on Civo', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Instance ID', }, region: { type: 'string', description: 'Region identifier', }, }, required: ['id', 'region'], }, }; - src/index.ts:255-277 (registration)The call handler registration for shutdown_instance in the MCP server. It validates arguments (id and region as strings) and calls the shutdownInstance API function, returning a text result.
case 'shutdown_instance': { if ( typeof args !== 'object' || args === null || typeof args.id !== 'string' || typeof args.region !== 'string' ) { throw new Error('Invalid arguments for shutdown_instance'); } const result = await shutdownInstance( args as { id: string; region: string } ); return { content: [ { type: 'text', text: `Instance ${args.id} shutdown: ${result.result}`, }, ], isError: false, }; } - src/index.ts:74-74 (registration)Tool registration within the server's capabilities - maps SHUTDOWN_INSTANCE_TOOL.name to its schema definition.
[SHUTDOWN_INSTANCE_TOOL.name]: SHUTDOWN_INSTANCE_TOOL, - src/index.ts:101-101 (registration)Tool listed in the ListToolsResponse handler so the client knows shutdown_instance is available.
SHUTDOWN_INSTANCE_TOOL,