Skip to main content
Glama

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

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