Skip to main content
Glama

list-variables

Display environment variables for active Railway projects to manage configuration settings across services and deployments.

Instructions

Show variables for the active environment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspacePathYesThe path to the workspace to list variables from
serviceNoThe service to show variables for (optional)
environmentNoThe environment to show variables for (optional)
kvNoShow variables in KV format (optional)
jsonNoOutput in JSON format (optional)

Implementation Reference

  • The MCP tool handler for 'list-variables' that invokes the CLI wrapper function and formats the response with error handling.
    handler: async ({ workspacePath, service, environment, kv, json, }: ListVariablesOptions) => { try { const variables = await listRailwayVariables({ workspacePath, service, environment, kv, json, }); return createToolResponse(variables); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return createToolResponse( "❌ Failed to list Railway variables\n\n" + `**Error:** ${errorMessage}\n\n` + "**Next Steps:**\n" + "• Ensure you have a Railway project linked\n" + "• Check that the service and environment exist\n" + "• Verify you have permissions to view variables\n" + "• Run `railway link` to ensure proper project connection", ); } },
  • Zod-based input schema defining parameters for the list-variables tool.
    inputSchema: { workspacePath: z .string() .describe("The path to the workspace to list variables from"), service: z .string() .optional() .describe("The service to show variables for (optional)"), environment: z .string() .optional() .describe("The environment to show variables for (optional)"), kv: z .boolean() .optional() .describe("Show variables in KV format (optional)"), json: z.boolean().optional().describe("Output in JSON format (optional)"), },
  • src/index.ts:21-31 (registration)
    Registration of all tools (imported as * from './tools') into the MCP server, including the list-variables tool.
    Object.values(tools).forEach((tool) => { server.registerTool( tool.name, { title: tool.title, description: tool.description, inputSchema: tool.inputSchema, }, tool.handler, ); });
  • Helper function that constructs and executes the 'railway variables' CLI command with provided options.
    export const listRailwayVariables = async ({ workspacePath, service, environment, kv, json, }: ListVariablesOptions): Promise<string> => { try { await checkRailwayCliStatus(); const result = await getLinkedProjectInfo({ workspacePath }); if (!result.success) { throw new Error(result.error); } let command = "railway variables"; if (service) { command += ` --service ${service}`; } if (environment) { command += ` --environment ${environment}`; } if (kv) { command += " --kv"; } if (json) { command += " --json"; } const { output } = await runRailwayCommand(command, workspacePath); return output; } catch (error: unknown) { return analyzeRailwayError(error, "railway variables"); } };

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/railwayapp/railway-mcp-server'

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