create_network
Create a new network on the Civo cloud platform by specifying a label and optional region for organizing cloud resources.
Instructions
Create a new network on Civo
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | Yes | Network label | |
| region | No | Region identifier |
Implementation Reference
- src/index.ts:379-400 (handler)Handler for the 'create_network' tool: validates input arguments, calls the createNetwork API function, and returns a success message with the created network details.case 'create_network': { if ( typeof args !== 'object' || args === null || typeof args.label !== 'string' ) { throw new Error('Invalid arguments for create_network'); } const network = await createNetwork( args as { label: string; region?: string } ); return { content: [ { type: 'text', text: `Created network ${network.label} (ID: ${network.id})`, }, ], isError: false, }; }
- src/tools/networks.ts:12-29 (schema)Schema definition for the 'create_network' tool, including input schema with required 'label' and optional 'region'.export const CREATE_NETWORK_TOOL: Tool = { name: 'create_network', description: 'Create a new network on Civo', inputSchema: { type: 'object', properties: { label: { type: 'string', description: 'Network label', }, region: { type: 'string', description: 'Region identifier', }, }, required: ['label'], }, };
- src/api/networks.ts:27-46 (helper)Helper function that performs the actual API call to Civo to create a network using POST request.export async function createNetwork(params: { label: string; region?: string; }): Promise<any> { const url = `${CIVO_API_URL}/networks`; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${CIVO_API_KEY}`, }, body: JSON.stringify(params), }); if (!response.ok) { throw new Error(`Failed to create network: ${response.statusText}`); } return await response.json(); }
- src/index.ts:83-83 (registration)Registration of the 'create_network' tool in the server capabilities.tools dictionary.[CREATE_NETWORK_TOOL.name]: CREATE_NETWORK_TOOL,