@railway/mcp-server
Version:
Official Railway MCP server
34 lines (31 loc) • 1.83 kB
JavaScript
import { getRailwayServices } from "./services-BXZqOgoN.js";
import { createToolResponse } from "./utils-Cvxm88Gr.js";
import z from "zod";
//#region src/tools/list-services.ts
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 }) => {
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) {
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
return createToolResponse(`❌ Failed to list Railway services
**Error:** ${errorMessage}\n\n**Next Steps:**
• Ensure you are logged into Railway CLI (\`railway login\`)
• Check that you have a project linked (\`railway link\`)
• Verify you have permissions to view services
• Try running \`railway login\` to refresh your authentication`);
}
}
};
//#endregion
export { listServicesTool };
//# sourceMappingURL=list-services-7QChZxQt.js.map