list-templates
List templates: view your own by default, or include official RunPod, public community, or endpoint-bound templates.
Instructions
List available templates. By default returns only the user's own templates. Use includeRunpodTemplates to also include official RunPod templates. The recommended default template for new pods is "Runpod Pytorch 2.8.0" (ID: runpod-torch-v280) — it has the latest CUDA and PyTorch versions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeRunpodTemplates | No | Include official RunPod templates in the response | |
| includePublicTemplates | No | Include community-made public templates in the response | |
| includeEndpointBoundTemplates | No | Include templates bound to Serverless endpoints in the response |
Implementation Reference
- src/index.ts:1068-1107 (registration)Registration of the 'list-templates' tool via server.tool() — includes both schema and handler inline.
server.tool( 'list-templates', 'List available templates. By default returns only the user\'s own templates. Use includeRunpodTemplates to also include official RunPod templates. The recommended default template for new pods is "Runpod Pytorch 2.8.0" (ID: runpod-torch-v280) — it has the latest CUDA and PyTorch versions.', { includeRunpodTemplates: z .boolean() .optional() .describe('Include official RunPod templates in the response'), includePublicTemplates: z .boolean() .optional() .describe('Include community-made public templates in the response'), includeEndpointBoundTemplates: z .boolean() .optional() .describe( 'Include templates bound to Serverless endpoints in the response' ), }, async (params) => { const queryParams = new URLSearchParams(); if (params.includeRunpodTemplates) queryParams.set('includeRunpodTemplates', 'true'); if (params.includePublicTemplates) queryParams.set('includePublicTemplates', 'true'); if (params.includeEndpointBoundTemplates) queryParams.set('includeEndpointBoundTemplates', 'true'); const query = queryParams.toString(); const result = await runpodRequest(`/templates${query ? `?${query}` : ''}`); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } ); - src/index.ts:1071-1086 (schema)Zod schema defining the three optional boolean input parameters for list-templates.
{ includeRunpodTemplates: z .boolean() .optional() .describe('Include official RunPod templates in the response'), includePublicTemplates: z .boolean() .optional() .describe('Include community-made public templates in the response'), includeEndpointBoundTemplates: z .boolean() .optional() .describe( 'Include templates bound to Serverless endpoints in the response' ), }, - src/index.ts:1087-1106 (handler)Handler function: builds query params from schema, calls runpodRequest to GET /templates, and returns JSON result as text content.
async (params) => { const queryParams = new URLSearchParams(); if (params.includeRunpodTemplates) queryParams.set('includeRunpodTemplates', 'true'); if (params.includePublicTemplates) queryParams.set('includePublicTemplates', 'true'); if (params.includeEndpointBoundTemplates) queryParams.set('includeEndpointBoundTemplates', 'true'); const query = queryParams.toString(); const result = await runpodRequest(`/templates${query ? `?${query}` : ''}`); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } - src/index.ts:60-99 (helper)Helper function used by the handler to make authenticated HTTP requests to the RunPod REST 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; } }