Skip to main content
Glama

variable_delete

Removes specific environment variables in Railway services to manage configurations, enhance security, or clean up unused settings. Requires project, environment, and variable details for precise deletion.

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

NameRequiredDescriptionDefault
environmentIdYesID of the environment to delete the variable from (usually obtained from service_list)
nameYesName of the variable to delete
projectIdYesID of the project
serviceIdNoID of the service (optional, if omitted deletes a shared variable)

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "environmentId": { "description": "ID of the environment to delete the variable from (usually obtained from service_list)", "type": "string" }, "name": { "description": "Name of the variable to delete", "type": "string" }, "projectId": { "description": "ID of the project", "type": "string" }, "serviceId": { "description": "ID of the service (optional, if omitted deletes a shared variable)", "type": "string" } }, "required": [ "projectId", "environmentId", "name" ], "type": "object" }

Implementation Reference

  • Registration of the 'variable_delete' tool using createTool, including formatted description, Zod input schema, and handler function that delegates to variableService.deleteVariable
    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); } ),
  • The core handler function for the variable_delete tool, which invokes the variable service to perform the deletion
    async ({ projectId, environmentId, name, serviceId }) => { return variableService.deleteVariable(projectId, environmentId, name, serviceId); }
  • Zod schema defining the input parameters for the variable_delete tool
    { 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)")
  • VariableService.deleteVariable method: wraps the repository call, handles errors, and formats 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)}`); } }
  • Repository layer executes the GraphQL mutation to delete the variable via Railway API
    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 }); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jason-tan-swe/railway-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server