service_restart
Restart a service to apply configuration changes, clear 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
| 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/services/service.service.ts:152-162 (handler)The restartService method in ServiceService class - core handler that calls the API to restart a service and waits 5 seconds before returning success.
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/service.tool.ts:190-218 (schema)The 'service_restart' tool definition with Zod schema for serviceId and environmentId parameters, and formatToolDescription for metadata.
createTool( "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); } ) - src/tools/index.ts:16-37 (registration)The registerAllTools function that registers all tools (including service_restart via serviceTools) with 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 ); }); } - The restartService method in ServiceRepository that makes the actual GraphQL mutation 'serviceInstanceRedeploy' to the Railway API.
async restartService(serviceId: string, environmentId: string): Promise<void> { await this.client.request<{ serviceInstanceRedeploy: boolean }>(` mutation serviceInstanceRedeploy($serviceId: String!, $environmentId: String!) { serviceInstanceRedeploy(serviceId: $serviceId, environmentId: $environmentId) } `, { serviceId, environmentId }); }