Skip to main content
Glama

template_list

Discover available templates for deploying services on Railway. Use this API to plan deployments by retrieving template IDs, sources, and filtering results with a search query.

Instructions

[API] List all available templates on Railway

⚡️ Best for: ✓ Discovering available templates ✓ Planning service deployments ✓ Finding template IDs and sources

⚠️ Not for: × Listing existing services × Getting service details

→ Alternatives: service_create_from_repo, service_create_from_image

→ Next steps: service_create_from_template

→ Related: database_list_types

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchQueryNoOptional search query to filter templates by name and description

Implementation Reference

  • Definition of the 'template_list' tool including its description, input schema, and handler function that calls templatesService.listTemplates(searchQuery). This is the core implementation of the MCP tool.
    createTool(
      "template_list",
      formatToolDescription({
        type: 'API',
        description: "List all available templates on Railway",
        bestFor: [
          "Discovering available templates",
          "Planning service deployments",
          "Finding template IDs and sources"
        ],
        notFor: [
          "Listing existing services",
          "Getting service details"
        ],
        relations: {
          nextSteps: ["service_create_from_template"],
          alternatives: ["service_create_from_repo", "service_create_from_image"],
          related: ["database_list_types"]
        }
      }),
      {
        searchQuery: z.string().optional().describe("Optional search query to filter templates by name and description"),
      },
      async ({ searchQuery }) => {
        return templatesService.listTemplates(searchQuery);
      }
    ),
  • Input schema for the 'template_list' tool using Zod.
    {
      searchQuery: z.string().optional().describe("Optional search query to filter templates by name and description"),
    },
  • Registration of all tools including templateTools (which contains 'template_list') with 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
        );
      });
    } 
  • Supporting utility: templatesService.listTemplates() method which fetches templates from the client API, optionally filters with Fuse.js, categorizes, formats output, and handles errors.
    async listTemplates(searchQuery?: string) {
      try {
        let templates = await this.client.templates.listTemplates();
    
        // If search query is provided, filter templates by name and description
        if (searchQuery) {
          const fuse = new Fuse(templates, {
            keys: [{
              name: 'name',
              weight: 3,
            }, {
              name: 'description',
              weight: 2,
            }],
            threshold: 0.3
          });
          templates = fuse.search(searchQuery).map(result => result.item);
        }
        
        // Group templates by category
        const categorizedTemplates = templates.reduce((acc, template) => {
          if (!acc[template.category]) {
            acc[template.category] = [];
          }
          acc[template.category].push(template);
          return acc;
        }, {} as Record<string, typeof templates>);
    
        const formattedTemplates = Object.entries(categorizedTemplates)
          .map(([category, templates]) => {
            // Sort templates by projects in descending order
            const sortedTemplates = [...templates].sort((a, b) => b.projects - a.projects);
            
            return `
              📁 ${category}
              ${sortedTemplates.map(template => {
                const services = Object.entries(template.serializedConfig.services)
                  .map(([id, service]) => `
                      Service: ${service.name}
                      ${service.icon ? `Icon: ${service.icon}` : ''}
                      Source: ${service.source?.image || service.source?.repo || 'N/A'}
                      Variables: ${Object.keys(service.variables || {}).length} configured
                      Networking: ${service.networking?.tcpProxies ? 'TCP Proxy enabled' : 'No TCP Proxy'}, ${Object.keys(service.networking?.serviceDomains || {}).length} domains
                      Volumes: ${Object.keys(service.volumeMounts || {}).length} mounts`
                  ).join('\n');
    
                return `  📦 ${template.name}
                  ID: ${template.id}
                  Description: ${template.description}
                  Projects: ${template.projects}
                  Services:
                  ${services}`;
              }).join('\n')}
          `;
          })
          .join('\n');
    
        return createSuccessResponse({
          text: `Available templates:\n${formattedTemplates}`,
          data: categorizedTemplates
        });
      } catch (error) {
        return createErrorResponse(`Error listing templates: ${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 describes the tool's behavior as a read-only listing operation (implied by 'List all available templates'), includes context about its use cases, and clarifies exclusions. However, it doesn't mention potential limitations like pagination, rate limits, or authentication requirements, which would be valuable for a tool with no annotation coverage.

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 and front-loaded with the core purpose, followed by bullet points for best uses, exclusions, and related tools. Every sentence earns its place by providing clear, actionable information without redundancy or fluff, making it highly efficient and easy to parse.

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?

Given the tool's low complexity (1 optional parameter, no output schema, no annotations), the description is largely complete. It covers purpose, usage guidelines, and exclusions thoroughly. The main gap is the lack of output details (e.g., what data is returned, format), which would be helpful since there's no output schema, but this is partially mitigated by the clear use cases listed.

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?

The input schema has 100% description coverage, with the single parameter 'searchQuery' documented as 'Optional search query to filter templates by name and description'. The description text does not add any parameter-specific information beyond what the schema provides, so it meets the baseline of 3 for high schema coverage without compensating value.

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 tool's purpose with a specific verb ('List') and resource ('all available templates on Railway'), distinguishing it from sibling tools like service_list, deployment_list, or volume_list. It explicitly identifies what it does (discovering templates, planning deployments, finding IDs/sources), making the purpose unambiguous and distinct.

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 on when to use this tool ('Best for: Discovering available templates, Planning service deployments, Finding template IDs and sources') and when not to use it ('Not for: Listing existing services, Getting service details'). It also names specific alternatives (service_create_from_repo, service_create_from_image) and related tools (service_create_from_template, database_list_types), offering comprehensive usage context.

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

Related 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/jason-tan-swe/railway-mcp'

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