Skip to main content
Glama

template_list

Browse and search available deployment templates to plan and initiate service creation on Railway infrastructure.

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

  • Core logic for listing templates: fetches from API, optional fuzzy search with Fuse.js, categorizes by category, sorts by popularity (projects), formats rich text output with service details.
    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)}`); } }
  • MCP tool definition for 'template_list': includes description, input schema (optional searchQuery), and thin handler delegating to templatesService.listTemplates.
    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); } ),
  • Zod input schema for the template_list tool: optional string searchQuery.
    searchQuery: z.string().optional().describe("Optional search query to filter templates by name and description"), },
  • Registers all MCP tools on the server, including templateTools which contains the 'template_list' 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 ); }); }

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