service_create_from_image
Create a Railway service from a Docker image to deploy custom databases, pre-built containers, or specific image versions.
Instructions
[API] Create a new service from a Docker image
⚡️ Best for: ✓ Custom database deployments ✓ Pre-built container deployments ✓ Specific version requirements
⚠️ Not for: × Standard database deployments (use database_deploy) × GitHub repository deployments (use service_create_from_repo) × Services needing build process
→ Prerequisites: project_list
→ Alternatives: database_deploy, service_create_from_repo
→ Next steps: variable_set, service_update, tcp_proxy_create
→ Related: volume_create, deployment_trigger
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | ID of the project to create the service in | |
| image | Yes | Docker image to use (e.g., 'postgres:13-alpine') | |
| name | No | Optional custom name for the service |
Implementation Reference
- src/tools/service.tool.ts:116-118 (handler)MCP tool handler function that executes the tool logic by calling serviceService.createServiceFromImage(projectId, image, name).async ({ projectId, image, name }) => { return serviceService.createServiceFromImage(projectId, image, name); }
- src/tools/service.tool.ts:111-115 (schema)Zod input schema defining parameters for the service_create_from_image tool: projectId, image, and optional name.{ projectId: z.string().describe("ID of the project to create the service in"), image: z.string().describe("Docker image to use (e.g., 'postgres:13-alpine')"), name: z.string().optional().describe("Optional custom name for the service") },
- src/tools/index.ts:16-37 (registration)Registration function that collects and registers all tools to the MCP server, including serviceTools which defines service_create_from_image.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 method in ServiceService class that implements the core logic for creating a service from a Docker image using the Railway client API.async createServiceFromImage(projectId: string, image: string, name?: string) { try { const service = await this.client.services.createService({ projectId, name, source: { image, } }); return createSuccessResponse({ text: `Created new service "${service.name}" (ID: ${service.id}) from Docker image "${image}"`, data: service }); } catch (error) { return createErrorResponse(`Error creating service: ${formatError(error)}`); } }