Skip to main content
Glama
railwayapp

Railway MCP Server

Official
by railwayapp

List Railway Variables

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");
    	}
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states it 'shows' variables, implying a read operation without details on permissions, rate limits, or output format. It doesn't disclose whether this is a safe read, if it requires authentication, or how results are structured, leaving significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. It's appropriately sized for a listing tool, with zero wasted text, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a tool with 5 parameters. It lacks details on behavioral traits, output format, or error handling, which are crucial for an agent to use it correctly. The minimal description doesn't compensate for the missing structured data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% description coverage, so parameters are well-documented in the schema itself. The description adds no additional parameter semantics beyond implying 'active environment' context, which aligns with the optional 'environment' parameter but doesn't provide extra meaning. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Show') and resource ('variables for the active environment'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'set-variables' or 'list-services', which would require mentioning it's a read-only listing operation versus mutation or other resource types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance by implying usage in the 'active environment', but lacks explicit when-to-use instructions, prerequisites, or alternatives. It doesn't clarify when to use this versus other listing tools like 'list-services' or 'list-deployments', or how it relates to 'set-variables' for mutation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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