List Railway Projects
list-projectsRetrieve all Railway cloud platform projects for your account to manage deployments, services, and environments.
Instructions
List all Railway projects for the currently logged in account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/list-projects.ts:9-53 (handler)The async handler function that fetches Railway projects using listRailwayProjects, maps and formats them into a markdown list grouped by project details, handles errors, and returns a formatted tool response.
handler: async () => { try { const projects = await listRailwayProjects(); const projectList = 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, })); const formattedList = projectList .map( (project) => `**${project.name}** (ID: ${project.id})\n` + `Team: ${project.team}\n` + `Environments: ${project.environments.join(", ")}\n` + `Services: ${project.services.join(", ")}\n` + `Created: ${new Date(project.createdAt).toLocaleDateString()}\n` + `Updated: ${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: unknown) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return createToolResponse( "❌ Failed to list Railway projects\n\n" + `**Error:** ${errorMessage}\n\n` + "**Next Steps:**\n" + "• Ensure you are logged into Railway CLI (`railway login`)\n" + "• Check that your authentication token is valid\n" + "• Verify you have permissions to view projects\n" + "• Try running `railway login` to refresh your authentication", ); } }, - src/tools/list-projects.ts:8-8 (schema)Empty input schema as the tool requires no input parameters.
inputSchema: {}, - src/index.ts:21-31 (registration)Registers all imported tools (including 'list-projects') with the MCP server by looping through Object.values(tools) and calling server.registerTool with name, schema details, and handler.
Object.values(tools).forEach((tool) => { server.registerTool( tool.name, { title: tool.title, description: tool.description, inputSchema: tool.inputSchema, }, tool.handler, ); }); - src/cli/projects.ts:71-84 (helper)Core helper function that executes the 'railway list --json' CLI command to retrieve the list of Railway projects, with status check and error analysis.
export const listRailwayProjects = async (): Promise<RailwayProject[]> => { try { await checkRailwayCliStatus(); const projects = await runRailwayJsonCommand("railway list --json"); if (!Array.isArray(projects)) { throw new Error("Unexpected response format from Railway CLI"); } return projects; } catch (error: unknown) { return analyzeRailwayError(error, "railway list --json"); } };