Skip to main content
Glama
railwayapp

Railway MCP Server

Official
by railwayapp

Generate Railway Domain

generate-domain

Generate a domain for your Railway project. Returns the existing domain URL if one is already configured, or creates a new domain for the project or specific service.

Instructions

Generate a domain for the currently linked Railway project. If a domain already exists, it will return the existing domain URL. Optionally specify a service to generate the domain for.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspacePathYesThe path to the workspace to generate domain for
serviceNoThe name of the service to generate the domain for (optional)

Implementation Reference

  • The main execution logic for the 'generate-domain' tool. Calls the helper generateRailwayDomain, handles errors, and returns formatted responses using createToolResponse.
    handler: async ({ workspacePath, service }: GenerateDomainOptions) => {
      try {
        const domain = await generateRailwayDomain({
          workspacePath,
          service,
        });
        return createToolResponse(
          `āœ… Successfully generated Railway domain${
            service ? ` for service '${service}'` : ""
          }:\n\nšŸš€ ${domain}\n\n**Note:** This domain is now available for your Railway project.`
        );
      } catch (error: unknown) {
        const errorMessage =
          error instanceof Error ? error.message : "Unknown error occurred";
        return createToolResponse(
          "āŒ Failed to generate Railway domain\n\n" +
            `**Error:** ${errorMessage}\n\n` +
            "**Next Steps:**\n" +
            "• Ensure you have a Railway project linked\n" +
            "• Check that you have permissions to generate domains\n" +
            "• Verify the project has been deployed at least once\n" +
            "• Run `railway link` to ensure proper project connection"
        );
      }
    },
  • Zod-based input schema defining parameters for the tool: workspacePath (required string) and service (optional string).
    inputSchema: {
      workspacePath: z
        .string()
        .describe("The path to the workspace to generate domain for"),
      service: z
        .string()
        .optional()
        .describe(
          "The name of the service to generate the domain for (optional)"
        ),
    },
  • src/index.ts:21-31 (registration)
    Dynamic registration of all tools (including 'generate-domain') to the MCP server using registerTool with name, schema details, 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:6-6 (registration)
    Export of the generateDomainTool object from its definition file, making it available for bulk import and registration.
    export { generateDomainTool } from "./generate-domain";
  • Core helper function that executes the 'railway domain --json' CLI command (optionally for a service), parses JSON output, and returns the domain URL or error.
    export const generateRailwayDomain = async ({
      workspacePath,
      service,
    }: GenerateDomainOptions): Promise<string> => {
      try {
        await checkRailwayCliStatus();
        const projectResult = await getLinkedProjectInfo({ workspacePath });
        if (!projectResult.success) {
          throw new Error(projectResult.error);
        }
    
        // Build the railway domain command with options
        let command = "railway domain --json";
    
        if (service) {
          command += ` --service ${service}`;
        }
    
        const domainResult = await runRailwayJsonCommand(command, workspacePath);
    
        if (domainResult.domain) {
          return domainResult.domain;
        }
    
        throw new Error("No domain found in Railway CLI JSON response");
      } catch (error: unknown) {
        return analyzeRailwayError(error, "railway domain --json");
      }
    };
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool returns an existing domain URL if one already exists, which is useful behavioral context. However, it doesn't mention potential side effects (e.g., whether this modifies infrastructure, requires permissions, or has rate limits), and the output format is unspecified. For a tool that likely involves infrastructure changes, this is a significant gap.

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 two sentences with zero waste: the first states the core purpose and behavior, and the second adds optional parameter context. It's front-loaded with the main action and efficiently structured, 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 the complexity (likely involving infrastructure changes), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what a 'domain' entails in this context, potential errors, or the return value format. For a tool with no structured safety or output information, more descriptive detail is needed to guide effective use.

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 already documents both parameters fully. The description adds minimal value by mentioning the optional 'service' parameter, but doesn't provide additional semantics beyond what's in the schema (e.g., format examples or constraints). With high schema coverage, the baseline is 3, and the description doesn't significantly enhance understanding.

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 ('generate a domain') and resource ('for the currently linked Railway project'), with additional context about returning existing domains. It distinguishes from siblings like 'create-project-and-link' or 'deploy' by focusing specifically on domain generation. However, it doesn't explicitly differentiate from all potential domain-related tools that might exist.

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

Usage Guidelines3/5

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

The description implies usage when a domain is needed for a Railway project, mentioning optional service specification. However, it doesn't provide explicit guidance on when to use this versus alternatives like 'deploy' (which might handle domains differently) or 'link-service', nor does it mention prerequisites like having a linked project. The context is clear but lacks specific when/when-not instructions.

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