Skip to main content
Glama
run-as-root

Warden Magento MCP Server

by run-as-root

warden_composer

Execute Composer commands within the php-fpm container of a Warden-managed Magento 2 environment to manage dependencies and packages.

Instructions

Run Composer commands inside the php-fpm container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYesPath to the project directory
commandYesComposer command to execute (e.g., 'install', 'update', 'require symfony/console', 'require-commerce')

Implementation Reference

  • Main handler function for 'warden_composer' tool. Executes Composer commands inside the Warden php-fpm container. Checks for composer2 or composer availability and version (requires v2), parses command arguments, runs via 'warden env exec', and returns structured output with success status.
    async runComposer(args) {
      const { project_path, command } = args;
    
      if (!project_path) {
        throw new Error("project_path is required");
      }
    
      if (!command) {
        throw new Error("command is required");
      }
    
      const normalizedProjectPath = project_path.replace(/\/+$/, "");
      const absoluteProjectPath = resolve(normalizedProjectPath);
    
      if (!existsSync(absoluteProjectPath)) {
        throw new Error(
          `Project directory does not exist: ${absoluteProjectPath}`,
        );
      }
    
      try {
        // First, check if composer2 is available
        const composer2CheckResult = await this.executeCommand(
          "warden",
          ["env", "exec", "-T", "php-fpm", "which", "composer2"],
          absoluteProjectPath,
        );
    
        let composerCommand = "composer2";
    
        if (composer2CheckResult.code !== 0) {
          // composer2 not available, check for composer
          const composerCheckResult = await this.executeCommand(
            "warden",
            ["env", "exec", "-T", "php-fpm", "which", "composer"],
            absoluteProjectPath,
          );
    
          if (composerCheckResult.code !== 0) {
            return {
              content: [
                {
                  type: "text",
                  text: `Composer not found!\n\nNeither 'composer2' nor 'composer' commands are available in the php-fpm container.\n\nPlease install Composer version 2 in your container.`,
                },
              ],
              isError: true,
            };
          }
    
          // Check composer version
          const versionCheckResult = await this.executeCommand(
            "warden",
            ["env", "exec", "-T", "php-fpm", "composer", "--version"],
            absoluteProjectPath,
          );
    
          if (versionCheckResult.code !== 0) {
            return {
              content: [
                {
                  type: "text",
                  text: `Failed to check Composer version!\n\nCommand: composer --version\nError: ${versionCheckResult.stderr}`,
                },
              ],
              isError: true,
            };
          }
    
          // Check if it's version 2
          const versionOutput = versionCheckResult.stdout.toLowerCase();
          if (!versionOutput.includes("composer version 2")) {
            return {
              content: [
                {
                  type: "text",
                  text: `Composer version 2 is required!\n\nFound: ${versionCheckResult.stdout.trim()}\n\nPlease install or upgrade to Composer version 2.`,
                },
              ],
              isError: true,
            };
          }
    
          composerCommand = "composer";
        }
    
        // Parse the command string to handle arguments properly
        const commandParts = command.trim().split(/\s+/);
        const wardenCommand = [
          "env",
          "exec",
          "-T",
          "php-fpm",
          composerCommand,
          ...commandParts,
        ];
    
        const result = await this.executeCommand(
          "warden",
          wardenCommand,
          absoluteProjectPath,
        );
    
        const commandStr = `${composerCommand} ${command}`;
        const isSuccess = result.code === 0;
    
        return {
          content: [
            {
              type: "text",
              text: `Composer command ${isSuccess ? "completed successfully" : "failed"}!\n\nCommand: ${commandStr}\nWorking directory: ${absoluteProjectPath}\nExit Code: ${result.code}\n\nOutput:\n${result.stdout || "(no output)"}\n\nErrors:\n${result.stderr || "(no errors)"}`,
            },
          ],
          isError: !isSuccess,
        };
      } catch (error) {
        const commandStr = `composer ${command}`;
        return {
          content: [
            {
              type: "text",
              text: `Failed to execute Composer command:\n\nCommand: ${commandStr}\nWorking directory: ${absoluteProjectPath}\nError: ${error.message}\n\nOutput:\n${error.stdout || "(no output)"}\n\nErrors:\n${error.stderr || "(no errors)"}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema definition for the 'warden_composer' tool, specifying required parameters: project_path and command.
    {
      name: "warden_composer",
      description: "Run Composer commands inside the php-fpm container",
      inputSchema: {
        type: "object",
        properties: {
          project_path: {
            type: "string",
            description: "Path to the project directory",
          },
          command: {
            type: "string",
            description:
              "Composer command to execute (e.g., 'install', 'update', 'require symfony/console', 'require-commerce')",
          },
        },
        required: ["project_path", "command"],
      },
    },
  • server.js:339-340 (registration)
    Registration of the 'warden_composer' tool handler in the CallToolRequestSchema switch statement, dispatching to runComposer method.
    case "warden_composer":
      return await this.runComposer(request.params.arguments);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool runs commands in a container but lacks critical details: whether it requires the container to be active, if it's read-only or mutative (e.g., 'composer install' vs. 'composer update'), potential side effects, error handling, or output format. This leaves significant gaps for safe and effective use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence with zero wasted words. It front-loads the core action ('Run Composer commands') and context ('inside the php-fpm container'), making it immediately understandable. Every word earns its place, achieving optimal conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of executing commands in a container with no annotations and no output schema, the description is incomplete. It doesn't address behavioral aspects like mutability, prerequisites, or error handling, which are crucial for a tool that could modify project dependencies or fail due to container state. More context is needed for reliable agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters ('project_path' and 'command'), including examples for the command. The description adds no additional parameter semantics beyond what the schema provides, such as path format constraints or command limitations. Given the high schema coverage, a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Run Composer commands') and the context ('inside the php-fpm container'), which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'warden_magento_cli' or 'warden_php_script', which might also involve container execution, leaving some ambiguity about when to choose this tool over those alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether the project must be running or initialized), exclusions (e.g., commands that shouldn't be run), or comparisons to siblings like 'warden_magento_cli' for Magento-specific tasks. Usage is implied but not explicitly defined.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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