service_restart
Restart a Railway service to apply configuration changes, clear service state, or resolve runtime issues in a specific environment.
Instructions
[API] Restart a service in a specific environment
⚡️ Best for: ✓ Applying configuration changes ✓ Clearing service state ✓ Resolving runtime issues
⚠️ Not for: × Deploying new code (use deployment_trigger) × Updating service config (use service_update) × Long-term service stoppage (use service_delete)
→ Prerequisites: service_list
→ Alternatives: deployment_trigger
→ Related: service_info, deployment_logs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serviceId | Yes | ID of the service to restart | |
| environmentId | Yes | ID of the environment where the service should be restarted (usually obtained from service_info) |
Implementation Reference
- src/tools/service.tool.ts:215-217 (handler)The core handler function for the 'service_restart' MCP tool. It takes serviceId and environmentId parameters and delegates to the serviceService to perform the restart.async ({ serviceId, environmentId }) => { return serviceService.restartService(serviceId, environmentId); }
- src/tools/service.tool.ts:211-214 (schema)Zod input schema defining the parameters for the service_restart tool: serviceId and environmentId.{ serviceId: z.string().describe("ID of the service to restart"), environmentId: z.string().describe("ID of the environment where the service should be restarted (usually obtained from service_info)") },
- src/tools/service.tool.ts:191-218 (registration)The createTool call that defines the service_restart tool, including name, description (with relations), input schema, and handler. This is added to serviceTools array which is later registered in src/tools/index.ts."service_restart", formatToolDescription({ type: 'API', description: "Restart a service in a specific environment", bestFor: [ "Applying configuration changes", "Clearing service state", "Resolving runtime issues" ], notFor: [ "Deploying new code (use deployment_trigger)", "Updating service config (use service_update)", "Long-term service stoppage (use service_delete)" ], relations: { prerequisites: ["service_list"], alternatives: ["deployment_trigger"], related: ["service_info", "deployment_logs"] } }), { serviceId: z.string().describe("ID of the service to restart"), environmentId: z.string().describe("ID of the environment where the service should be restarted (usually obtained from service_info)") }, async ({ serviceId, environmentId }) => { return serviceService.restartService(serviceId, environmentId); } )
- Supporting service method called by the tool handler. Performs the actual API call to restart the service instance and handles response/error formatting.async restartService(serviceId: string, environmentId: string) { try { await this.client.services.restartService(serviceId, environmentId); await new Promise(resolve => setTimeout(resolve, 5000)); // TEMPORARY UNTIL WEBHOOKS ARE IMPLEMENTED: Wait for 5 seconds to ensure the service is restarted return createSuccessResponse({ text: `Service restarted successfully` }); } catch (error) { return createErrorResponse(`Error restarting service: ${formatError(error)}`); } }
- src/tools/index.ts:16-37 (registration)Global MCP tool registration function that includes serviceTools (containing service_restart) and registers all tools with the MCP server via server.tool(name, description, inputSchema, handler).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 ); }); }