volume_create
Create persistent storage volumes for Railway services to manage database files, application data, and other storage needs that require data retention across deployments.
Instructions
[API] Create a new persistent volume for a service
⚡️ Best for: ✓ Setting up database storage ✓ Configuring persistent data ✓ Adding file storage
⚠️ Not for: × Temporary storage needs × Static file hosting × Memory caching
→ Prerequisites: service_list
→ Next steps: volume_list
→ Related: service_update, database_deploy
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | ID of the project containing the service | |
| environmentId | Yes | ID of the environment for the volume (usually obtained from service_info) | |
| serviceId | Yes | ID of the service to attach volume to | |
| mountPath | Yes | Path where the volume should be mounted in the container |
Implementation Reference
- src/tools/volume.tool.ts:57-59 (handler)The handler function for the 'volume_create' tool, which delegates to volumeService.createVolume.async ({ projectId, environmentId, serviceId, mountPath }) => { return volumeService.createVolume(projectId, serviceId, environmentId, mountPath); }
- src/tools/volume.tool.ts:51-56 (schema)Zod input schema defining parameters for the volume_create tool.{ projectId: z.string().describe("ID of the project containing the service"), environmentId: z.string().describe("ID of the environment for the volume (usually obtained from service_info)"), serviceId: z.string().describe("ID of the service to attach volume to"), mountPath: z.string().describe("Path where the volume should be mounted in the container") },
- src/tools/volume.tool.ts:30-60 (registration)Local registration of the volume_create tool within the volumeTools array using createTool.createTool( "volume_create", formatToolDescription({ type: 'API', description: "Create a new persistent volume for a service", bestFor: [ "Setting up database storage", "Configuring persistent data", "Adding file storage" ], notFor: [ "Temporary storage needs", "Static file hosting", "Memory caching" ], relations: { prerequisites: ["service_list"], nextSteps: ["volume_list"], related: ["service_update", "database_deploy"] } }), { projectId: z.string().describe("ID of the project containing the service"), environmentId: z.string().describe("ID of the environment for the volume (usually obtained from service_info)"), serviceId: z.string().describe("ID of the service to attach volume to"), mountPath: z.string().describe("Path where the volume should be mounted in the container") }, async ({ projectId, environmentId, serviceId, mountPath }) => { return volumeService.createVolume(projectId, serviceId, environmentId, mountPath); } ),
- src/tools/index.ts:16-37 (registration)Global registration of all tools, including volumeTools which contains volume_create, 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 ); }); }
- src/services/volume.service.ts:50-66 (helper)Service layer implementation that handles volume creation logic, error handling, and response formatting by calling the client.async createVolume(projectId: string, serviceId: string, environmentId: string, mountPath: string): Promise<CallToolResult> { try { const input = { projectId, serviceId, environmentId, mountPath }; const volume = await this.client.volumes.createVolume(input); if (!volume) { return createErrorResponse(`Error creating volume: Failed to create volume for ${serviceId} in environment ${environmentId}`); } return createSuccessResponse({ text: `✅ Volume "${volume.name}" created successfully (ID: ${volume.id})`, data: volume }); } catch (error) { return createErrorResponse(`Error creating volume: ${formatError(error)}`); } }