Skip to main content
Glama
railwayapp

Railway MCP Server

Official
by railwayapp

Deploy to Railway

deploy

Deploy applications from your current directory to Railway's cloud platform. Configure environment, service, and CI mode options for controlled deployments.

Instructions

Upload and deploy from the current directory. Supports CI mode, environment, and service options.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspacePathYesThe path to the workspace to deploy
ciNoStream build logs only, then exit (equivalent to setting $CI=true)
environmentNoEnvironment to deploy to (defaults to linked environment)
serviceNoService to deploy to (defaults to linked service)

Implementation Reference

  • The handler function for the 'deploy' MCP tool. It invokes deployRailwayProject from the CLI module, handles success/error responses, and formats the output using createToolResponse.
    handler: async ({
    	workspacePath,
    	ci,
    	environment,
    	service,
    }: DeployOptions) => {
    	const {
    		workspacePath: wsPath,
    		ci: ciMode = false,
    		environment: env,
    		service: svc,
    	} = { workspacePath, ci, environment, service };
    	try {
    		const result = await deployRailwayProject({
    			workspacePath: wsPath,
    			ci: ciMode,
    			environment: env,
    			service: svc,
    		});
    		return createToolResponse(
    			`✅ Successfully triggered a deployment for Railway project. This process will take some time to complete:\n\n${result}`,
    		);
    	} catch (error: unknown) {
    		const errorMessage =
    			error instanceof Error ? error.message : "Unknown error occurred";
    		return createToolResponse(
    			"❌ Failed to deploy Railway project\n\n" +
    				`**Error:** ${errorMessage}\n\n` +
    				"**Next Steps:**\n" +
    				"• Ensure you have a Railway project linked\n" +
    				"• Check that the environment and service exist\n" +
    				"• Verify your project has the necessary files for deployment\n" +
    				"• Check that you have permissions to deploy to this project",
    		);
    	}
    },
  • Zod schema defining the input parameters for the 'deploy' tool: workspacePath (required), ci, environment, service (optional).
    inputSchema: {
    	workspacePath: z.string().describe("The path to the workspace to deploy"),
    	ci: z
    		.boolean()
    		.optional()
    		.describe(
    			"Stream build logs only, then exit (equivalent to setting $CI=true)",
    		),
    	environment: z
    		.string()
    		.optional()
    		.describe("Environment to deploy to (defaults to linked environment)"),
    	service: z
    		.string()
    		.optional()
    		.describe("Service to deploy to (defaults to linked service)"),
    },
  • src/index.ts:21-31 (registration)
    Main MCP server registration loop that dynamically registers all tools (including 'deploy') from the tools module by name, schema, and handler.
    Object.values(tools).forEach((tool) => {
    	server.registerTool(
    		tool.name,
    		{
    			title: tool.title,
    			description: tool.description,
    			inputSchema: tool.inputSchema,
    		},
    		tool.handler,
    	);
    });
  • src/tools/index.ts:4-4 (registration)
    Re-export of the deployTool from its implementation file, making it available for import in the main server.
    export { deployTool } from "./deploy";
  • Core helper function deployRailwayProject that executes the 'railway up' CLI command with options, handles service linking, and error analysis. Called by the deploy tool handler.
    export const deployRailwayProject = async ({
      workspacePath,
      environment,
      service,
      ci,
    }: DeployOptions): Promise<string> => {
      try {
        await checkRailwayCliStatus();
        const result = await getLinkedProjectInfo({ workspacePath });
        if (!result.success) {
          throw new Error(result.error);
        }
    
        // Build the railway up command with options
        let command = "railway up";
    
        if (ci) {
          command += " --ci";
        }
    
        if (environment) {
          command += ` --environment ${environment}`;
        }
    
        if (service) {
          command += ` --service ${service}`;
        }
    
        const { output: deployOutput } = await runRailwayCommand(
          command,
          workspacePath
        );
    
        // After deployment, try to link a service if none is linked
        try {
          // Check if there are any services available
          const servicesResult = await getRailwayServices({ workspacePath });
          if (
            servicesResult.success &&
            servicesResult.services &&
            servicesResult.services.length > 0
          ) {
            // Link the first available service
            const firstService = servicesResult.services[0];
            const { output: linkOutput } = await runRailwayCommand(
              `railway service ${firstService}`,
              workspacePath
            );
            return `${deployOutput}\n\nService linked: ${firstService}\n${linkOutput}`;
          }
        } catch (linkError) {
          // If linking fails, just return the deployment output
          console.warn(
            "Warning: Could not automatically link service after deployment:",
            linkError
          );
        }
    
        return deployOutput;
      } catch (error: unknown) {
        return analyzeRailwayError(error, "railway up");
      }
    };
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 lacks critical behavioral details. It mentions 'Upload and deploy' implying a write operation, but doesn't disclose permissions needed, whether it's destructive, rate limits, or what happens on failure. The CI mode hint is useful but insufficient for a mutation tool.

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

Conciseness4/5

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

The description is brief and front-loaded with the core action, using two efficient sentences. However, the second sentence could be more structured to clearly separate features, and it slightly under-specifies given the tool's complexity.

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?

For a deployment tool with 4 parameters, no annotations, and no output schema, the description is inadequate. It misses behavioral context, output expectations, error handling, and differentiation from siblings, leaving significant gaps for an AI agent to understand and invoke it correctly.

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?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds minimal value by listing 'CI mode, environment, and service options' but doesn't explain semantics beyond what the schema provides, such as how defaults work or interaction effects.

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 ('Upload and deploy') and resource ('from the current directory'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'deploy-template' or 'list-deployments' beyond the basic action, missing specific distinctions about scope or method.

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 no guidance on when to use this tool versus alternatives like 'deploy-template' or 'check-railway-status'. It mentions supported options but doesn't specify prerequisites, exclusions, or contextual triggers, leaving usage ambiguous.

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