Skip to main content
Glama

project_environments

Retrieve and list all environments within a specified project on the Railway MCP server. Use the project ID to query and organize deployment environments efficiently.

Instructions

List all environments in a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesID of the project

Implementation Reference

  • Core handler logic that lists environments for a project using the client API, formats the response with details, and handles errors.
      async listEnvironments(projectId: string) {
        try {
          const environments = await this.client.projects.listEnvironments(projectId);
    
          if (environments.length === 0) {
            return createSuccessResponse({
              text: "No environments found in this project.",
              data: []
            });
          }
    
          const environmentDetails = environments.map(env => 
            `🌍 ${env.name} (ID: ${env.id})
    Created: ${new Date(env.createdAt).toLocaleString()}
    ${env.isEphemeral ? '(Ephemeral)' : '(Permanent)'}
    ${env.unmergedChangesCount ? `Unmerged Changes: ${env.unmergedChangesCount}` : ''}`
          );
    
          return createSuccessResponse({
            text: `Environments in project:\n\n${environmentDetails.join('\n\n')}`,
            data: environments
          });
        } catch (error) {
          return createErrorResponse(`Error listing environments: ${formatError(error)}`);
        }
      }
  • Defines the project_environments tool: registers name, description, input schema (projectId), and thin handler delegating to projectService.
    createTool(
      "project_environments",
      "List all environments in a project",
      {
        projectId: z.string().describe("ID of the project")
      },
      async ({projectId}) => {
        return projectService.listEnvironments(projectId);
      }
    )
  • Zod input schema requiring projectId string.
    {
      projectId: z.string().describe("ID of the project")
    },
  • Final registration of all tools including project_environments (via projectTools) with the MCP server using server.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/jason-tan-swe/railway-mcp'

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