Skip to main content
Glama

terraform_plan

Preview infrastructure changes safely before applying them with Terraform. This read-only tool analyzes your configuration to show what modifications would occur.

Instructions

Run terraform plan to preview infrastructure changes (read-only, safe)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYesDirectory containing Terraform files

Implementation Reference

  • The implementation of the `terraform_plan` tool logic, which executes `terraform plan` using `child_process`.
    export async function terraformPlan(args: Record<string, unknown>): Promise<string> {
      const directory = args.directory as string;
      if (!directory) throw new Error("Terraform directory is required");
    
      try {
        const { stdout, stderr } = await execFileAsync("terraform", ["plan", "-no-color", "-input=false"], {
          cwd: directory,
          timeout: 120000,
        });
        return `Terraform plan for '${directory}':\n\n${stdout}${stderr ? `\nWarnings:\n${stderr}` : ""}`;
      } catch (error: any) {
        throw new Error(`Terraform plan failed: ${error.stderr || error.message}`);
      }
    }
  • Registration of the `terraform_plan` tool, including its name, description, and input schema.
    {
      name: "terraform_plan",
      description: "Run terraform plan to preview infrastructure changes (read-only, safe)",
      inputSchema: {
        type: "object" as const,
        properties: {
          directory: { type: "string", description: "Directory containing Terraform files" },
        },
        required: ["directory"],
      },
    },
  • The handler function that routes calls to `terraform_plan` to the appropriate implementation.
    export async function handleTerraformTool(
      name: string,
      args: Record<string, unknown> | undefined
    ): Promise<string> {
      const a = args || {};
      switch (name) {
        case "terraform_plan": return terraformPlan(a);
        case "terraform_state_list": return terraformStateList(a);
        case "terraform_state_show": return terraformStateShow(a);
        case "terraform_output": return terraformOutput(a);
        case "terraform_validate": return terraformValidate(a);
        default: throw new Error(`Unknown Terraform tool: ${name}`);
      }
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates that the operation is read-only and safe, which is crucial for a Terraform plan tool that previews changes without applying them. However, it lacks details on execution time, output format, or potential side effects like state locking.

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, efficient sentence that front-loads the core action ('Run terraform plan') and includes essential qualifiers in parentheses. Every word earns its place, with no redundancy or unnecessary elaboration.

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

Completeness4/5

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

For a tool with one parameter (fully documented in schema), no annotations, and no output schema, the description provides adequate context by clarifying the tool's purpose and safety. It could be more complete by mentioning typical output or linking to Terraform documentation, but it covers the essentials given the low complexity.

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?

The input schema has 100% description coverage, with the single parameter 'directory' clearly documented in the schema. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline of 3 for high schema coverage without compensating value.

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

Purpose5/5

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

The description clearly states the specific action ('Run terraform plan') and resource ('preview infrastructure changes'), with the parenthetical adding important context about safety. It distinguishes from siblings like terraform_output, terraform_state_list, and terraform_validate by focusing on change previewing rather than output retrieval, state inspection, or validation.

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

Usage Guidelines3/5

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

The description implies usage context through 'preview infrastructure changes' and '(read-only, safe)', suggesting it's for checking changes before applying them. However, it doesn't explicitly state when to use this versus alternatives like terraform_validate for syntax checking or terraform_state_show for current state inspection, nor does it mention prerequisites or exclusions.

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/batu-sonmez/infraclaude'

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