update-template
Modify existing pod templates by updating Docker images, ports, environment variables, and documentation to adapt configurations for different workloads.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| templateId | Yes | ID of the template to update | |
| name | No | New name for the template | |
| imageName | No | New Docker image | |
| ports | No | New ports to expose | |
| env | No | New environment variables | |
| readme | No | New README content in markdown format |
Implementation Reference
- src/index.ts:583-599 (handler)Handler function that updates a RunPod template by sending a PATCH request to the /templates/{templateId} endpoint with the provided update parameters, then returns the API response as formatted text.async (params) => { const { templateId, ...updateParams } = params; const result = await runpodRequest( `/templates/${templateId}`, 'PATCH', updateParams ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/index.ts:572-582 (schema)Zod schema defining the input parameters for the update-template tool: required templateId, optional name, imageName, ports, env, and readme.{ templateId: z.string().describe('ID of the template to update'), name: z.string().optional().describe('New name for the template'), imageName: z.string().optional().describe('New Docker image'), ports: z.array(z.string()).optional().describe('New ports to expose'), env: z.record(z.string()).optional().describe('New environment variables'), readme: z .string() .optional() .describe('New README content in markdown format'), },
- src/index.ts:570-600 (registration)Registration of the 'update-template' tool on the MCP server using server.tool(), providing the input schema and handler function.server.tool( 'update-template', { templateId: z.string().describe('ID of the template to update'), name: z.string().optional().describe('New name for the template'), imageName: z.string().optional().describe('New Docker image'), ports: z.array(z.string()).optional().describe('New ports to expose'), env: z.record(z.string()).optional().describe('New environment variables'), readme: z .string() .optional() .describe('New README content in markdown format'), }, async (params) => { const { templateId, ...updateParams } = params; const result = await runpodRequest( `/templates/${templateId}`, 'PATCH', updateParams ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } );
- src/index.ts:27-66 (helper)Shared helper function runpodRequest used by the update-template handler (and other tools) to make 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; } }