Skip to main content
Glama

domain_create

Create custom domains for Railway services to configure HTTPS endpoints and establish accessible service URLs.

Instructions

[API] Create a new domain for a service

⚡️ Best for: ✓ Setting up custom domains ✓ Configuring service endpoints ✓ Adding HTTPS endpoints

⚠️ Not for: × TCP proxy setup (use tcp_proxy_create) × Internal service communication

→ Prerequisites: service_list, domain_check

→ Alternatives: tcp_proxy_create

→ Next steps: domain_update

→ Related: service_info, domain_list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentIdYesID of the environment
serviceIdYesID of the service
domainNoCustom domain name (optional, as railway will generate one for you and is generally better to leave it up to railway to generate one. There's usually no need to specify this and there are no use cases for overriding it.)
suffixNoSuffix for the domain (optional, railway will generate one for you and is generally better to leave it up to railway to generate one.)
targetPortNoTarget port for the domain (optional, as railway will use the default port for the service and detect it automatically.)

Implementation Reference

  • Handler function for the domain_create MCP tool, which delegates to the domain service.
    async ({ environmentId, serviceId, domain, suffix, targetPort }) => { return domainService.createServiceDomain({ environmentId, serviceId, domain, suffix, targetPort }); }
  • Input schema using Zod for the domain_create tool.
    { environmentId: z.string().describe("ID of the environment"), serviceId: z.string().describe("ID of the service"), domain: z.string().optional().describe("Custom domain name (optional, as railway will generate one for you and is generally better to leave it up to railway to generate one. There's usually no need to specify this and there are no use cases for overriding it.)"), suffix: z.string().optional().describe("Suffix for the domain (optional, railway will generate one for you and is generally better to leave it up to railway to generate one.)"), targetPort: z.number().optional().describe("Target port for the domain (optional, as railway will use the default port for the service and detect it automatically.)"), },
  • Registers all tools including domainTools (containing domain_create) to the MCP server.
    export function registerAllTools(server: McpServer) { // Collect all tools const allTools = [ ...databaseTools, ...deploymentTools, ...domainTools, ...projectTools, ...serviceTools, ...tcpProxyTools, ...variableTools, ...configTools, ...volumeTools, ...templateTools, ] as Tool[]; // Register each tool with the server allTools.forEach((tool) => { server.tool( ...tool ); }); }
  • Service layer function that checks domain availability and creates the service domain via the client.
    async createServiceDomain(input: ServiceDomainCreateInput): Promise<CallToolResult> { try { // Check domain availability if a domain is specified if (input.domain) { const availability = await this.client.domains.serviceDomainAvailable(input.domain); if (!availability.available) { return createErrorResponse(`Domain unavailable: ${availability.message}`); } } const domain = await this.client.domains.serviceDomainCreate(input); return createSuccessResponse({ text: `Domain created successfully: ${domain.domain} (ID: ${domain.id}, Port: ${domain.targetPort || 'default'})`, data: domain }); } catch (error) { return createErrorResponse(`Error creating domain: ${formatError(error)}`); } }
  • TypeScript interface for ServiceDomainCreateInput used throughout the domain creation flow.
    export interface ServiceDomainCreateInput { /** ID of the environment */ environmentId: string; /** ID of the service */ serviceId: string; /** Custom domain name (optional) */ domain?: string; /** Suffix for the domain (optional) */ suffix?: string; /** Target port for the domain (optional) */ targetPort?: number; }

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/epitaphe360/railway-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server