variable_delete
Remove unused or sensitive environment variables from Railway.app services to manage configurations and maintain security.
Instructions
[API] Delete a variable for a service in a specific environment
⚡️ Best for: ✓ Removing unused configuration ✓ Security cleanup ✓ Configuration management
⚠️ Not for: × Temporary variable disabling × Bulk variable removal
→ Prerequisites: service_list
→ Next steps: deployment_trigger, service_restart
→ Related: variable_list, variable_set
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | ID of the project | |
| environmentId | Yes | ID of the environment to delete the variable from (usually obtained from service_list) | |
| name | Yes | Name of the variable to delete | |
| serviceId | No | ID of the service (optional, if omitted deletes a shared variable) |
Implementation Reference
- src/tools/variable.tool.ts:65-94 (registration)Defines and registers the 'variable_delete' tool within the variableTools array using createTool, including description, schema, and handler.createTool( "variable_delete", formatToolDescription({ type: 'API', description: "Delete a variable for a service in a specific environment", bestFor: [ "Removing unused configuration", "Security cleanup", "Configuration management" ], notFor: [ "Temporary variable disabling", "Bulk variable removal" ], relations: { prerequisites: ["service_list"], nextSteps: ["deployment_trigger", "service_restart"], related: ["variable_list", "variable_set"] } }), { projectId: z.string().describe("ID of the project"), environmentId: z.string().describe("ID of the environment to delete the variable from (usually obtained from service_list)"), name: z.string().describe("Name of the variable to delete"), serviceId: z.string().optional().describe("ID of the service (optional, if omitted deletes a shared variable)") }, async ({ projectId, environmentId, name, serviceId }) => { return variableService.deleteVariable(projectId, environmentId, name, serviceId); } ),
- src/tools/variable.tool.ts:91-93 (handler)The executor function of the 'variable_delete' tool, which delegates to the variableService.deleteVariable method.async ({ projectId, environmentId, name, serviceId }) => { return variableService.deleteVariable(projectId, environmentId, name, serviceId); }
- VariableService.deleteVariable method providing the core deletion logic, API call, success/error responses.async deleteVariable(projectId: string, environmentId: string, name: string, serviceId?: string) { try { await this.client.variables.deleteVariable({ projectId, environmentId, name, serviceId }); const variableType = serviceId ? "service variable" : "shared environment variable"; return createSuccessResponse({ text: `Successfully deleted ${variableType} "${name}"` }); } catch (error) { return createErrorResponse(`Error deleting variable: ${formatError(error)}`); } }
- VariableRepository.deleteVariable executes the GraphQL mutation for deleting a variable.async deleteVariable(input: VariableDeleteInput): Promise<void> { const { projectId, environmentId, serviceId, name } = input; await this.client.request<{ variableDelete: boolean }>(` mutation variableDelete( $projectId: String!, $environmentId: String!, $serviceId: String, $name: String! ) { variableDelete( input: { projectId: $projectId, environmentId: $environmentId, serviceId: $serviceId, name: $name } ) } `, { projectId, environmentId, serviceId, name }); }
- src/tools/index.ts:16-37 (registration)Final MCP server registration of all tools, including variableTools containing 'variable_delete' via server.tool(...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 ); }); }