@railway/mcp-server
Version:
Official Railway MCP server
38 lines (35 loc) • 1.85 kB
JavaScript
import { listRailwayProjects } from "./projects-ENU6yIz7.js";
import { createToolResponse } from "./utils-Cvxm88Gr.js";
//#region src/tools/list-projects.ts
const listProjectsTool = {
name: "list-projects",
title: "List Railway Projects",
description: "List all Railway projects for the currently logged in account",
inputSchema: {},
handler: async () => {
try {
const projects = await listRailwayProjects();
const formattedList = projects.map((project) => ({
id: project.id,
name: project.name,
team: project.team?.name || "Unknown",
environments: project.environments?.edges?.map((env) => env.node.name) || [],
services: project.services?.edges?.map((service) => service.node.name) || [],
createdAt: project.createdAt,
updatedAt: project.updatedAt
})).map((project) => `**${project.name}** (ID: ${project.id})\nTeam: ${project.team}\nEnvironments: ${project.environments.join(", ")}\nServices: ${project.services.join(", ")}\nCreated: ${new Date(project.createdAt).toLocaleDateString()}\nUpdated: ${new Date(project.updatedAt).toLocaleDateString()}\n`).join("\n");
return createToolResponse(`✅ Found ${projects.length} Railway project(s):\n\n${formattedList}\n\n**Note:** To link to one of these projects, run \`railway link\` manually.`);
} catch (error) {
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
return createToolResponse(`❌ Failed to list Railway projects
**Error:** ${errorMessage}\n\n**Next Steps:**
• Ensure you are logged into Railway CLI (\`railway login\`)
• Check that your authentication token is valid
• Verify you have permissions to view projects
• Try running \`railway login\` to refresh your authentication`);
}
}
};
//#endregion
export { listProjectsTool };
//# sourceMappingURL=list-projects-CDe5bINn.js.map