Skip to main content
Glama

terraform_output

Read Terraform output values from infrastructure configurations to retrieve deployment details and resource information for infrastructure management.

Instructions

Read Terraform output values

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYesDirectory containing Terraform files
nameNoSpecific output name (optional, shows all if omitted)

Implementation Reference

  • The implementation of the terraform_output tool handler.
    export async function terraformOutput(args: Record<string, unknown>): Promise<string> {
      const directory = args.directory as string;
      if (!directory) throw new Error("Terraform directory is required");
      const name = args.name as string | undefined;
    
      const tfArgs = ["output", "-json"];
      if (name) tfArgs.push(name);
    
      try {
        const { stdout } = await execFileAsync("terraform", tfArgs, {
          cwd: directory,
          timeout: 30000,
        });
        const parsed = JSON.parse(stdout);
        return `Terraform outputs${name ? ` (${name})` : ""}:\n\n${JSON.stringify(parsed, null, 2)}`;
      } catch (error: any) {
        throw new Error(`Terraform output failed: ${error.stderr || error.message}`);
      }
    }
  • The input schema definition for the terraform_output tool.
    {
      name: "terraform_output",
      description: "Read Terraform output values",
      inputSchema: {
        type: "object" as const,
        properties: {
          directory: { type: "string", description: "Directory containing Terraform files" },
          name: { type: "string", description: "Specific output name (optional, shows all if omitted)" },
        },
        required: ["directory"],
      },
    },
  • The registration/dispatch logic for the terraform_output tool within the terraform tools handler.
    case "terraform_output": return terraformOutput(a);

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