template_deploy
Deploy new services on Railway-MCP using pre-configured templates. Streamline service initiation by selecting templates, specifying project and environment IDs, and avoiding custom configurations.
Instructions
[WORKFLOW] Deploy a new service from a template
⚡️ Best for: ✓ Starting new services from templates ✓ Quick service deployment ✓ Using pre-configured templates
⚠️ Not for: × Custom service configurations × GitHub repository deployments (use service_create_from_repo)
→ Prerequisites: template_list
→ Alternatives: service_create_from_repo, service_create_from_image, database_deploy
→ Next steps: service_info, variable_list
→ Related: service_update, deployment_trigger
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| environmentId | Yes | ID of the environment to deploy to | |
| projectId | Yes | ID of the project to create the service in | |
| teamId | No | ID of the team to create the service in (if not provided, will use the default team) | |
| templateId | Yes | ID of the template to use |
Implementation Reference
- src/tools/template.tool.ts:34-69 (registration)Registration of the 'template_deploy' tool, including formatted description, Zod input schema, and handler function that delegates to templatesService.deployTemplatecreateTool( "template_deploy", formatToolDescription({ type: 'WORKFLOW', description: "Deploy a new service from a template", bestFor: [ "Starting new services from templates", "Quick service deployment", "Using pre-configured templates" ], notFor: [ "Custom service configurations", "GitHub repository deployments (use service_create_from_repo)" ], relations: { prerequisites: ["template_list"], alternatives: ["service_create_from_repo", "service_create_from_image", "database_deploy"], nextSteps: ["service_info", "variable_list"], related: ["service_update", "deployment_trigger"] } }), { projectId: z.string().describe("ID of the project to create the service in"), templateId: z.string().describe("ID of the template to use"), environmentId: z.string().describe("ID of the environment to deploy to"), teamId: z.string().optional().describe("ID of the team to create the service in (if not provided, will use the default team)") }, async ({ projectId, templateId, environmentId, teamId }: { projectId: string; templateId: string; environmentId: string; teamId?: string; }) => { return templatesService.deployTemplate(projectId, templateId, environmentId, teamId); } ),
- TemplatesService.deployTemplate: Fetches the template by ID, then calls the repository to perform the deployment, returns success/error response with workflow IDasync deployTemplate( projectId: string, templateId: string, environmentId: string, teamId?: string, ) { try { // Get the template const templates = await this.client.templates.listTemplates(); const template = templates.find(t => t.id === templateId); if (!template) { return createErrorResponse(`Template not found: ${templateId}`); } // Deploy the template const response = await this.client.templates.deployTemplate(environmentId, projectId, template.serializedConfig, templateId, teamId); return createSuccessResponse({ text: `Created new service "${template.name}" from template ${template.name} in project ${projectId}. Monitoring workflow status with ID: ${response.workflowId}`, data: response }); } catch (error) { return createErrorResponse(`Error creating service from template: ${formatError(error)}`); } }
- TemplateRepository.deployTemplate: Executes GraphQL mutation 'templateDeployV2' to deploy the template and returns projectId and workflowIdasync deployTemplate(environmentId: string, projectId: string, serializedConfig: { services: Record<string, ServiceConfig> }, templateId: string, teamId?: string) { const query = ` mutation deployTemplate($environmentId: String, $projectId: String, $templateId: String!, $teamId: String, $serializedConfig: SerializedTemplateConfig!) { templateDeployV2(input: { environmentId: $environmentId, projectId: $projectId, templateId: $templateId, teamId: $teamId, serializedConfig: $serializedConfig }) { projectId workflowId } } `; const response = await this.client.request<{ templateDeployV2: { projectId: string, workflowId: string } }>(query, { environmentId, projectId, templateId, teamId, serializedConfig, }); return response.templateDeployV2; }
- src/tools/index.ts:16-37 (registration)MCP server registration of all tools, including templateTools which contains template_deploy via spread operator at line 28export function registerAllTools(server: McpServer) { // Collect all tools const allTools = [ ...databaseTools, ...deploymentTools, ...domainTools, ...projectTools, ...serviceTools, ...tcpProxyTools, ...variableTools, ...configTools, ...volumeTools, ...templateTools, ] as Tool[]; // Register each tool with the server allTools.forEach((tool) => { server.tool( ...tool ); }); }