variable_delete
Delete environment variables from Railway.app services to remove unused configurations and enhance security through cleanup.
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)Registers the 'variable_delete' MCP tool using createTool, including Zod input schema, tool description, and thin handler delegating to variableService.deleteVariablecreateTool( "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/services/variable.service.ts:56-72 (handler)Service layer handler that calls the repository to delete the variable and formats the responseasync 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)}`); } }
- Repository helper that executes the GraphQL mutation to delete the variable using the Railway API clientasync 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/types.ts:202-207 (schema)TypeScript interface defining the input shape for variable deletion, used by the repositoryexport interface VariableDeleteInput { projectId: string; environmentId: string; serviceId?: string; name: string; }