Skip to main content
Glama

terraform_state_list

List all resources in Terraform state to manage infrastructure configurations and track deployed components.

Instructions

List all resources in the Terraform state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYesDirectory containing Terraform files

Implementation Reference

  • The handler function that executes 'terraform state list' in the specified directory.
    export async function terraformStateList(args: Record<string, unknown>): Promise<string> {
      const directory = args.directory as string;
      if (!directory) throw new Error("Terraform directory is required");
    
      try {
        const { stdout } = await execFileAsync("terraform", ["state", "list"], {
          cwd: directory,
          timeout: 30000,
        });
        const resources = stdout.trim().split("\n").filter(Boolean);
        if (resources.length === 0) return "No resources in Terraform state.";
        return `Terraform state resources (${resources.length}):\n\n${resources.join("\n")}`;
      } catch (error: any) {
        throw new Error(`Terraform state list failed: ${error.stderr || error.message}`);
      }
    }
  • The input schema definition for the terraform_state_list tool.
    {
      name: "terraform_state_list",
      description: "List all resources in the Terraform state",
      inputSchema: {
        type: "object" as const,
        properties: {
          directory: { type: "string", description: "Directory containing Terraform files" },
        },
        required: ["directory"],
      },
    },
  • Registration logic mapping the tool name to its handler function within the tool router.
    case "terraform_state_list": return terraformStateList(a);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it's a listing operation, implying read-only behavior, but doesn't mention whether this requires specific permissions, whether it reads from local or remote state, what happens if the state is locked, or what format the output takes. For a state inspection tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 directly states the tool's purpose with zero wasted words. It's appropriately sized for a simple listing tool and front-loads the essential information.

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

Completeness3/5

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

For a single-parameter listing tool with no output schema, the description provides the basic purpose but lacks important context. It doesn't explain what the output looks like (list format, resource identifiers, state versions), doesn't mention error conditions (missing state file, invalid directory), and doesn't provide usage guidance relative to sibling tools. Given the complexity of Terraform state management, this leaves gaps in understanding how to effectively use the tool.

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 the single 'directory' parameter. The description doesn't add any parameter-specific information beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in description.

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 ('List') and resource ('all resources in the Terraform state'), making the purpose immediately understandable. It distinguishes from sibling tools like terraform_state_show (which shows specific resources) by emphasizing 'all resources'. However, it doesn't specify the verbosity level or format of the listing.

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?

No guidance is provided about when to use this tool versus alternatives. While it's clear this lists resources, there's no mention of prerequisites (like requiring a Terraform state file), comparison to terraform_state_show (which shows details of specific resources), or when this listing would be preferred over other state inspection methods.

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