Skip to main content
Glama

template_deploy

Deploy new services from pre-configured templates to quickly set up infrastructure on Railway.app, ideal for starting standardized projects without 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

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesID of the project to create the service in
templateIdYesID of the template to use
environmentIdYesID of the environment to deploy to
teamIdNoID of the team to create the service in (if not provided, will use the default team)

Implementation Reference

  • The core handler function for the 'template_deploy' tool, which invokes the templatesService to perform the deployment.
    async ({ projectId, templateId, environmentId, teamId }: { projectId: string; templateId: string; environmentId: string; teamId?: string; }) => { return templatesService.deployTemplate(projectId, templateId, environmentId, teamId); }
  • Zod input schema defining parameters for the template_deploy tool.
    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)") },
  • Registration of all tools, including template_deploy (via ...templateTools), to the MCP server.
    export 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 ); }); }
  • Helper service method deployTemplate that fetches the template and calls the repository to deploy it.
    async 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)}`); } }
  • Repository method that executes the GraphQL mutation for deploying the template.
    async 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/epitaphe360/railway-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server