Skip to main content
Glama

warden_list_environments

Lists all active Warden-managed Magento 2 development environments with their directory paths in structured JSON format.

Instructions

List all running Warden environments with their directories (returns structured JSON)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function for 'warden_list_environments' tool. Executes 'warden status' command, parses the output using parseEnvironmentList, and returns structured JSON response with list of environments or error details.
    async listEnvironments() { try { const result = await this.executeCommand( "warden", ["status"], process.cwd(), ); if (result.code === 0) { const environments = this.parseEnvironmentList(result.stdout); return { content: [ { type: "text", text: JSON.stringify( { success: true, command: "warden status", exit_code: result.code, environments: environments.map((env) => ({ name: env.name, path: env.path, })), raw_output: result.stdout, }, null, 2, ), }, ], isError: false, }; } else { return { content: [ { type: "text", text: JSON.stringify( { success: false, command: "warden status", exit_code: result.code, environments: [], error: result.stderr || "Unknown error", raw_output: result.stdout, }, null, 2, ), }, ], isError: true, }; } } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { success: false, command: "warden status", exit_code: -1, environments: [], error: error.message, raw_output: error.stdout || "", raw_errors: error.stderr || "", }, null, 2, ), }, ], isError: true, }; } }
  • server.js:34-43 (registration)
    Tool registration in ListToolsRequestSchema handler, including name, description, and empty input schema.
    { name: "warden_list_environments", description: "List all running Warden environments with their directories (returns structured JSON)", inputSchema: { type: "object", properties: {}, required: [], }, },
  • server.js:321-322 (registration)
    Dispatch case in CallToolRequestSchema switch statement that routes calls to the listEnvironments handler.
    case "warden_list_environments": return await this.listEnvironments();
  • Input schema definition for the tool (empty object, no parameters required).
    inputSchema: { type: "object", properties: {}, required: [], },
  • Helper function to parse 'warden status' output and extract environment names and project directories.
    parseEnvironmentList(output) { const environments = []; const lines = output.split("\n"); let currentProject = null; let currentPath = null; for (const line of lines) { const trimmed = line.trim(); // Skip empty lines and headers if ( !trimmed || trimmed.includes("No running environments found") || trimmed.includes("Found the following") ) { continue; } // Remove ANSI color codes for parsing const cleanLine = trimmed.replace(/\x1b\[[0-9;]*m/g, ""); // Look for project name pattern: " projectname a magento2 project" const projectMatch = cleanLine.match(/^\s*(\w+)\s+a\s+\w+\s+project$/); if (projectMatch) { currentProject = projectMatch[1]; continue; } // Look for project directory pattern: " Project Directory: /path/to/project" const directoryMatch = cleanLine.match(/^\s*Project Directory:\s*(.+)$/); if (directoryMatch && currentProject) { currentPath = directoryMatch[1]; // Add the environment when we have both name and path environments.push({ name: currentProject, path: currentPath, raw: line, }); // Reset for next project currentProject = null; currentPath = null; continue; } // Skip URL lines if (cleanLine.includes("Project URL:")) { continue; } } return environments; }

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/run-as-root/warden-mcp-server'

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