Skip to main content
Glama

exec_in_environment

Execute commands within a QIT test environment's PHP container to run tests, manage environments, or debug WordPress/WooCommerce plugins.

Instructions

Execute a command inside a running QIT test environment's PHP container.

⚠️ QIT CLI not detected. QIT CLI not found. Please install it using one of these methods:

  1. Via Composer (recommended): composer require woocommerce/qit-cli --dev

  2. Set QIT_CLI_PATH environment variable: export QIT_CLI_PATH=/path/to/qit

  3. Ensure 'qit' is available in your system PATH

For more information, visit: https://github.com/woocommerce/qit-cli

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesCommand to execute inside the container
env_idNoEnvironment ID. If not provided, uses the most recent environment.

Implementation Reference

  • The core handler function for the 'exec_in_environment' tool. It builds the QIT CLI command 'env:exec' with optional --env flag and the provided command, then executes it using executeAndFormat with a 5-minute timeout.
    handler: async (args: { command: string; env_id?: string }) => {
      const cmdArgs = ["env:exec"];
    
      if (args.env_id) {
        cmdArgs.push("--env", args.env_id);
      }
    
      cmdArgs.push("--", args.command);
    
      return executeAndFormat(cmdArgs, { timeout: 300000 });
    },
  • Zod input schema for the tool, requiring a 'command' string and optionally an 'env_id' string.
    inputSchema: z.object({
      command: z.string().describe("Command to execute inside the container"),
      env_id: z
        .string()
        .optional()
        .describe(
          "Environment ID. If not provided, uses the most recent environment."
        ),
    }),
  • Registration of environmentTools (containing exec_in_environment) into the aggregated allTools object exported for use by the MCP server.
    export const allTools = {
      ...authTools,
      ...testExecutionTools,
      ...testResultsTools,
      ...groupsTools,
      ...environmentTools,
      ...packagesTools,
      ...configTools,
      ...utilitiesTools,
    };
  • src/server.ts:29-38 (registration)
    MCP ListTools handler converts allTools (including exec_in_environment) into the protocol's tool list format with name, description, and JSON schema.
      const tools = Object.entries(allTools).map(([_, tool]) => ({
        name: tool.name,
        description: cliInfo
          ? tool.description
          : `${tool.description}\n\n⚠️ QIT CLI not detected. ${getQitCliNotFoundError()}`,
        inputSchema: zodToJsonSchema(tool.inputSchema),
      }));
    
      return { tools };
    });
  • src/server.ts:44-64 (registration)
    In MCP CallTool handler, retrieves the tool handler from allTools by name and invokes it with validated arguments. This is the entry point for executing exec_in_environment.
    const tool = allTools[name as ToolName];
    
    if (!tool) {
      return {
        content: [
          {
            type: "text",
            text: `Unknown tool: ${name}`,
          },
        ],
        isError: true,
      };
    }
    
    try {
      // Validate input
      const validatedArgs = tool.inputSchema.parse(args);
    
      // Execute tool
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      const result = await (tool.handler as (args: any) => Promise<{ content: string; isError: boolean }>)(validatedArgs);
Behavior2/5

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

No annotations are provided, so the description carries full burden. It discloses that QIT CLI must be installed (a prerequisite) and mentions the 'env_id' parameter's default behavior ('uses the most recent environment'). However, it lacks critical behavioral details: what happens if the environment isn't running, whether commands are persistent, error handling, or output format. For a command execution tool with no annotations, this is insufficient.

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

Conciseness2/5

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

The description is poorly structured and not front-loaded. The first sentence states the purpose, but the majority is a lengthy error/warning message about QIT CLI installation (7 lines), which belongs in error handling or prerequisites, not the core description. This wastes space and obscures the tool's functionality.

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 no annotations and no output schema, the description is incomplete. It covers the basic purpose and prerequisites but misses behavioral context (e.g., execution safety, output format, error conditions) and doesn't leverage sibling tool context. For a command execution tool in a test environment suite, this leaves significant gaps for an AI agent.

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%, so the schema already documents both parameters ('command' and 'env_id') fully. The description adds minimal value: it implies 'env_id' is optional (matching schema) and notes the default behavior for 'env_id'. No additional syntax, format, or constraints are provided beyond the schema. Baseline 3 is appropriate when schema does the heavy lifting.

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 tool's purpose: 'Execute a command inside a running QIT test environment's PHP container.' This specifies the verb ('execute'), resource ('command'), and context ('running QIT test environment's PHP container'). However, it doesn't explicitly differentiate from sibling tools like 'run_test' or 'reset_environment', which also involve execution in test environments.

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 mentions prerequisites (QIT CLI installation) but doesn't compare to sibling tools like 'run_test' (for running tests) or 'start_environment' (for environment management). There's no explicit 'when-to-use' or 'when-not-to-use' context.

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/woocommerce/qit-mcp'

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