Run Terraform plan and apply through an MCP agent
Table of Contents #. Task: The author configured the tfmcp client in Cursor to execute Terraform commands (init, plan, apply) for provisioning a Postgres database, schema, and user access. When the MCP failed to surface errors during apply, the author reverted to running terraform apply directly in the terminal to diagnose permission issues. The workflow relied on Cursor's Agent mode to interpret CLI errors and suggest configuration fixes, such as setting superuser = false, rather than the MCP alone.; tools: Cursor. Human role: The original post does not say how a person stayed involved.; limitations: MCPs rely on developer expertise for debugging and do not replace core understanding of Infrastructure as Code. The tfmcp implementation had usability concerns, specifically failing to surface logs or interpret errors effectively. Security risks exist as MCPs run third-party code, requiring careful vetting similar to open-source packages..
Tools
Published on Agent Work Atlas:
Overview
Table of Contents #
Workflow
The author configured the tfmcp client in Cursor to execute Terraform commands (init, plan, apply) for provisioning a Postgres database, schema, and user access. When the MCP failed to surface errors during apply, the author reverted to running terraform apply directly in the terminal to diagnose permission issues. The workflow relied on Cursor's Agent mode to interpret CLI errors and suggest configuration fixes, such as setting superuser = false, rather than the MCP alone.
Reported result
The experiment revealed that tfmcp did not make the workflow easier compared to command-line muscle memory. Initial failures occurred because the MCP did not report back if the apply was successful, hiding critical permission errors. The author concluded that the real value came from Cursor's Agent mode interpreting errors, while the MCP layer itself offered limited convenience.
Human role
The original post does not say how a person stayed involved.
Limitations
MCPs rely on developer expertise for debugging and do not replace core understanding of Infrastructure as Code. The tfmcp implementation had usability concerns, specifically failing to surface logs or interpret errors effectively. Security risks exist as MCPs run third-party code, requiring careful vetting similar to open-source packages.
Try it
I want to test an MCP-based Terraform workflow in Cursor. First, configure tfmcp in my mcp.json pointing to [replaceable: terraform directory path]. Create a main.tf file that provisions a [replaceable: resource type, e.g., Postgres DB] with [replaceable: specific permissions]. Ask the agent to run 'terraform init' and 'terraform plan'. Review the plan output carefully. If the agent reports success, verify manually in the terminal. If it fails, ask the agent to run 'terraform apply' via Cursor's Run capability to capture CLI errors. Do not trust the MCP's silent success; always confirm state changes. If errors occur, ask the agent to interpret the CLI output and suggest fixes. Only proceed to 'apply' after human review of the plan. Report back the specific error messages encountered and the final configuration changes made.
Source reports are not independently verified. Publication date is the catalog publication date, not the original article date.