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)}`);
      }
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates that this is a creation/mutation tool (implied by 'Create'), mentions prerequisites that suggest authorization needs, and provides context about what gets created (custom domains, HTTPS endpoints). However, it doesn't explicitly mention rate limits or detailed error conditions.

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 well-structured with clear sections (API purpose, Best for, Not for, Prerequisites, Alternatives, Next steps, Related). Every sentence earns its place by providing distinct value, and the information is front-loaded with the core purpose stated first.

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

Completeness4/5

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

For a creation tool with no annotations and no output schema, the description provides substantial context about usage, alternatives, and relationships. It covers the tool's purpose, when to use it, and what to expect next. The main gap is the lack of information about return values or error conditions, which would be helpful given the absence of an output schema.

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 all 5 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema, which is acceptable given the comprehensive schema coverage. The baseline score of 3 reflects adequate parameter documentation through the schema alone.

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?

The description clearly states the specific action ('Create a new domain for a service') and distinguishes it from sibling tools by explicitly mentioning what it's not for (TCP proxy setup, internal service communication). It provides a verb+resource combination that is unambiguous.

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?

The description provides explicit guidance with 'Best for' and 'Not for' sections, names specific alternatives (tcp_proxy_create), lists prerequisites (service_list, domain_check), and suggests next steps (domain_update). This gives comprehensive context for when to use this tool versus alternatives.

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

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