create-pod
Create a new GPU or CPU pod on RunPod by specifying image, GPU type, cloud type, ports, environment variables, and more. Defaults to the latest RunPod Pytorch image if none provided.
Instructions
Create a new GPU/CPU pod on RunPod. If the user does not specify an image, recommend the "Runpod Pytorch 2.8.0" image (runpod/pytorch:1.0.2-cu1281-torch280-ubuntu2404) as the default — it has the most up-to-date CUDA and PyTorch versions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Name for the pod | |
| imageName | Yes | Docker image to use | |
| cloudType | No | SECURE or COMMUNITY cloud | |
| gpuTypeIds | No | List of acceptable GPU types | |
| gpuCount | No | Number of GPUs | |
| containerDiskInGb | No | Container disk size in GB | |
| volumeInGb | No | Volume size in GB | |
| volumeMountPath | No | Path to mount the volume | |
| ports | No | Ports to expose (e.g., '8888/http', '22/tcp') | |
| env | No | Environment variables | |
| dataCenterIds | No | List of data centers |
Implementation Reference
- src/index.ts:430-474 (registration)Registration of the 'create-pod' tool on the MCP server using server.tool(), with name, description, and schema defined inline.
// Create Pod server.tool( 'create-pod', 'Create a new GPU/CPU pod on RunPod. If the user does not specify an image, recommend the "Runpod Pytorch 2.8.0" image (runpod/pytorch:1.0.2-cu1281-torch280-ubuntu2404) as the default — it has the most up-to-date CUDA and PyTorch versions.', { name: z.string().optional().describe('Name for the pod'), imageName: z.string().describe('Docker image to use'), cloudType: z .enum(['SECURE', 'COMMUNITY']) .optional() .describe('SECURE or COMMUNITY cloud'), gpuTypeIds: z .array(z.string()) .optional() .describe('List of acceptable GPU types'), gpuCount: z.number().optional().describe('Number of GPUs'), containerDiskInGb: z .number() .optional() .describe('Container disk size in GB'), volumeInGb: z.number().optional().describe('Volume size in GB'), volumeMountPath: z.string().optional().describe('Path to mount the volume'), ports: z .array(z.string()) .optional() .describe("Ports to expose (e.g., '8888/http', '22/tcp')"), env: z.record(z.string()).optional().describe('Environment variables'), dataCenterIds: z .array(z.string()) .optional() .describe('List of data centers'), }, async (params) => { const result = await runpodRequest('/pods', 'POST', params); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } ); - src/index.ts:462-473 (handler)Handler function for 'create-pod' — calls runpodRequest('/pods', 'POST', params) to create a new pod via the RunPod API, then returns the result as JSON text.
async (params) => { const result = await runpodRequest('/pods', 'POST', params); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } - src/index.ts:434-460 (schema)Input schema for 'create-pod' using Zod: defines optional fields (name, cloudType, gpuTypeIds, gpuCount, containerDiskInGb, volumeInGb, volumeMountPath, ports, env, dataCenterIds) and required field imageName.
{ name: z.string().optional().describe('Name for the pod'), imageName: z.string().describe('Docker image to use'), cloudType: z .enum(['SECURE', 'COMMUNITY']) .optional() .describe('SECURE or COMMUNITY cloud'), gpuTypeIds: z .array(z.string()) .optional() .describe('List of acceptable GPU types'), gpuCount: z.number().optional().describe('Number of GPUs'), containerDiskInGb: z .number() .optional() .describe('Container disk size in GB'), volumeInGb: z.number().optional().describe('Volume size in GB'), volumeMountPath: z.string().optional().describe('Path to mount the volume'), ports: z .array(z.string()) .optional() .describe("Ports to expose (e.g., '8888/http', '22/tcp')"), env: z.record(z.string()).optional().describe('Environment variables'), dataCenterIds: z .array(z.string()) .optional() .describe('List of data centers'), - src/index.ts:60-99 (helper)runpodRequest helper function — makes authenticated HTTP requests to the RunPod REST API at https://rest.runpod.io/v1 with Bearer token auth.
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; } }