Skip to main content
Glama

list-variables

Display environment variables for a specified workspace, service, or environment in plain text, KV, or JSON format using the Railway MCP Server.

Instructions

Show variables for the active environment

Input Schema

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

Implementation Reference

  • The handler function for the 'list-variables' tool. It calls listRailwayVariables with provided options, returns the result wrapped in createToolResponse, or formats an error message on failure.
    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 input schema defining parameters for the list-variables tool: workspacePath (required), service, environment, kv, json (optional).
    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)
    Registers all tools (including list-variables) from the tools module into the MCP server using server.registerTool.
    Object.values(tools).forEach((tool) => { server.registerTool( tool.name, { title: tool.title, description: tool.description, inputSchema: tool.inputSchema, }, tool.handler, ); });
  • Core helper function that constructs and executes the 'railway variables' CLI command with options, handling errors via analyzeRailwayError.
    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"); } };

Other Tools

Related Tools

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