Skip to main content
Glama

list-services

Display all services associated with a linked Railway project by specifying the workspace path. Use this tool to manage and review project services directly from the CLI.

Instructions

List all services for the currently linked Railway project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspacePathYesThe path to the workspace to list services from

Implementation Reference

  • Core implementation of the 'list-services' tool: defines name, title, description, input schema, and the handler function that executes the logic to list services.
    export const listServicesTool = { name: "list-services", title: "List Railway Services", description: "List all services for the currently linked Railway project", inputSchema: { workspacePath: z .string() .describe("The path to the workspace to list services from"), }, handler: async ({ workspacePath }: GetServicesOptions) => { try { const result = await getRailwayServices({ workspacePath }); if (!result.success) { throw new Error(result.error); } const services = result.services || []; if (services.length === 0) { return createToolResponse( "ℹ️ No services found for the currently linked Railway project.\n\n" + "**Next Steps:**\n" + "• Ensure you have a project linked (`railway link`)\n" + "• Check that your project has services created\n" + "• Create a new service through the Railway dashboard or CLI", ); } const formattedList = services .map((service, index) => `${index + 1}. **${service}**`) .join("\n"); return createToolResponse( `✅ Found ${services.length} service(s) in the linked Railway project:\n\n${formattedList}\n\n**Note:** To link to a specific service, use the \`link-service\` tool.`, ); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return createToolResponse( "❌ Failed to list Railway services\n\n" + `**Error:** ${errorMessage}\n\n` + "**Next Steps:**\n" + "• Ensure you are logged into Railway CLI (`railway login`)\n" + "• Check that you have a project linked (`railway link`)\n" + "• Verify you have permissions to view services\n" + "• Try running `railway login` to refresh your authentication", ); } }, };
  • src/index.ts:21-31 (registration)
    Registers all tools (including 'list-services') from the './tools' module into the MCP server using a loop over Object.values(tools).
    Object.values(tools).forEach((tool) => { server.registerTool( tool.name, { title: tool.title, description: tool.description, inputSchema: tool.inputSchema, }, tool.handler, ); });
  • Barrel export of the listServicesTool from its implementation file for easy import in src/index.ts.
    export { listServicesTool } from "./list-services";
  • Helper function getRailwayServices used by the tool handler; runs 'railway status --json' in the workspace and parses services list.
    export const getRailwayServices = async ({ workspacePath, }: GetServicesOptions): Promise<{ success: boolean; services?: string[]; error?: string; }> => { try { await checkRailwayCliStatus(); const result = await getLinkedProjectInfo({ workspacePath }); if (!result.success) { throw new Error(result.error); } const { output } = await runRailwayCommand( "railway status --json", workspacePath, ); // Parse the JSON output to extract services const statusData = JSON.parse(output); // Extract services from the JSON structure const services = statusData.services?.edges?.map( (edge: { node: { name: string } }) => edge.node.name, ) || []; return { success: true, services }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { success: false, error: errorMessage }; } };

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

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