delete-network-volume
Delete a RunPod network volume by providing its ID to free up resources and clean up unused storage.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| networkVolumeId | Yes | ID of the network volume to delete |
Implementation Reference
- src/index.ts:1319-1340 (handler)The handler function for the 'delete-network-volume' tool. It sends a DELETE request to /networkvolumes/{networkVolumeId} using the runpodRequest helper.
// Delete Network Volume server.tool( 'delete-network-volume', { networkVolumeId: z.string().describe('ID of the network volume to delete'), }, async (params) => { const result = await runpodRequest( `/networkvolumes/${params.networkVolumeId}`, 'DELETE' ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } ); - src/index.ts:1322-1324 (schema)Input schema: requires 'networkVolumeId' as a string, validated with Zod.
{ networkVolumeId: z.string().describe('ID of the network volume to delete'), }, - src/index.ts:1320-1340 (registration)Registration of the 'delete-network-volume' tool via server.tool() on the MCP server instance.
server.tool( 'delete-network-volume', { networkVolumeId: z.string().describe('ID of the network volume to delete'), }, async (params) => { const result = await runpodRequest( `/networkvolumes/${params.networkVolumeId}`, 'DELETE' ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } ); - src/index.ts:60-99 (helper)The runpodRequest helper function that makes authenticated HTTP requests to the RunPod API.
async function runpodRequest( endpoint: string, method: string = 'GET', body?: Record<string, unknown> ) { const url = `${API_BASE_URL}${endpoint}`; const headers = { Authorization: `Bearer ${API_KEY}`, 'Content-Type': 'application/json', }; const options: NodeFetchRequestInit = { method, headers, }; if (body && (method === 'POST' || method === 'PATCH')) { options.body = JSON.stringify(body); } try { const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error(`RunPod API Error: ${response.status} - ${errorText}`); } // Some endpoints might not return JSON const contentType = response.headers.get('content-type'); if (contentType && contentType.includes('application/json')) { return await response.json(); } return { success: true, status: response.status }; } catch (error) { console.error('Error calling RunPod API:', error); throw error; } }