Skip to main content
Glama

domain_create

Create custom domains for Railway services to configure HTTPS endpoints and establish public-facing URLs for applications.

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

  • The main handler function for the "domain_create" MCP tool. It extracts parameters from the tool call and delegates to the domainService.createServiceDomain method.
    async ({ environmentId, serviceId, domain, suffix, targetPort }) => {
      return domainService.createServiceDomain({
        environmentId,
        serviceId,
        domain,
        suffix,
        targetPort
      });
    }
  • Zod schema defining the input parameters 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.)"),
    },
  • The domain_create tool is defined and registered to the domainTools array using createTool, which includes name, description, schema, and handler.
    createTool(
      "domain_create",
      formatToolDescription({
        type: 'API',
        description: "Create a new domain for a service",
        bestFor: [
          "Setting up custom domains",
          "Configuring service endpoints",
          "Adding HTTPS endpoints"
        ],
        notFor: [
          "TCP proxy setup (use tcp_proxy_create)",
          "Internal service communication"
        ],
        relations: {
          prerequisites: ["service_list", "domain_check"],
          nextSteps: ["domain_update"],
          alternatives: ["tcp_proxy_create"],
          related: ["service_info", "domain_list"]
        }
      }),
      {
        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.)"),
      },
      async ({ environmentId, serviceId, domain, suffix, targetPort }) => {
        return domainService.createServiceDomain({
          environmentId,
          serviceId,
          domain,
          suffix,
          targetPort
        });
      }
    ),
  • Final registration of all tools, including domainTools containing domain_create, to the MCP server via server.tool().
    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
        );
      });
    } 
  • Helper service method that handles domain creation logic, including availability check and API call via repository.
    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)}`);
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.8/5.0
Behavior2/5

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

No annotations are provided, so the description must stand alone. It only states 'Create a new domain' without disclosing side effects, authorization requirements, idempotency, or limits. For a creation tool, this is insufficient behavioral detail.

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?

Description is well-structured with bullet points and clear sections (Best for, Not for, Prerequisites, etc.). It is concise but informative. Minor noise from '[API]' prefix and emojis, but overall efficient.

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

Completeness3/5

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

While the description includes prerequisites and next steps, it lacks context about the return value or success behavior (no output schema). For a tool with 5 parameters and no annotations, more detail about expected results or side effects would improve completeness.

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 coverage is 100%, so the description does not need to repeat parameter details. The description adds no extra meaning beyond what schema already provides; thus, baseline of 3 is appropriate.

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

Purpose5/5

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

Clearly states 'Create a new domain for a service' with specific use cases (custom domains, service endpoints, HTTPS). Distinguishes from siblings like tcp_proxy_create by explicitly listing 'Not for' items.

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

Usage Guidelines5/5

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

Provides explicit best-for/not-for sections, prerequisites (service_list, domain_check), alternatives (tcp_proxy_create), and next steps (domain_update). Guides when to use and when not.

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