delete-pod
Remove a RunPod pod by providing its ID to terminate and free resources.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| podId | Yes | ID of the pod to delete |
Implementation Reference
- src/index.ts:550-568 (registration)The tool 'delete-pod' is registered on the MCP server using server.tool(), with a Zod schema for podId parameter and a handler that calls the RunPod API.
// Delete Pod server.tool( 'delete-pod', { podId: z.string().describe('ID of the pod to delete'), }, async (params) => { const result = await runpodRequest(`/pods/${params.podId}`, 'DELETE'); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } ); - src/index.ts:553-555 (schema)Input schema for delete-pod: requires a 'podId' string field described as 'ID of the pod to delete'.
{ podId: z.string().describe('ID of the pod to delete'), }, - src/index.ts:556-567 (handler)The handler function that executes the delete-pod logic: calls runpodRequest with DELETE method on /pods/{podId} endpoint and returns the JSON result.
async (params) => { const result = await runpodRequest(`/pods/${params.podId}`, '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 REST API. Used by the delete-pod handler.
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; } }