volume_create
Create persistent storage volumes for services on Railway platform, ideal for database storage and persistent data configuration. Requires project, environment, and service IDs for setup.
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 |
|---|---|---|---|
| environmentId | Yes | ID of the environment for the volume (usually obtained from service_info) | |
| mountPath | Yes | Path where the volume should be mounted in the container | |
| projectId | Yes | ID of the project containing the service | |
| serviceId | Yes | ID of the service to attach volume to |
Implementation Reference
- src/tools/volume.tool.ts:57-59 (handler)Executes the core logic of the volume_create tool by invoking volumeService.createVolume with the input parameters.async ({ projectId, environmentId, serviceId, mountPath }) => { return volumeService.createVolume(projectId, serviceId, environmentId, mountPath); }
- src/tools/volume.tool.ts:52-56 (schema)Zod schema defining the input parameters and descriptions 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/index.ts:16-37 (registration)Registers all tools with the MCP server, including volumeTools which contains the volume_create tool.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)Helper service method that orchestrates volume creation: prepares input, calls repository, formats success/error responses.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)}`); } }
- Repository helper that executes the GraphQL mutation for creating a volume.async createVolume(input: VolumeCreateInput): Promise<Volume> { const data = await this.client.request<{ volumeCreate: Volume }>(` mutation volumeCreate($input: VolumeCreateInput!) { volumeCreate(input: $input) { createdAt id name projectId } } `, { input }); return data.volumeCreate; }