Skip to content
Back to search

tfmcp

๐ŸŒ Terraform Model Context Protocol (MCP) Tool - An experimental CLI tool that enables AI assistants to manage and operate Terraform environments. Supports reading Terraform configurations, analyzing plans, applying configurations, and managing state with Claude Desktop integration. โšก๏ธ

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/nwiizo/tfmcp with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/nwiizo/tfmcp'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/nwiizo--tfmcp/badge.svg)](/listings/nwiizo--tfmcp)

HTML

<a href="/listings/nwiizo--tfmcp"><img src="/api/listings/nwiizo--tfmcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

From Source

# Clone the repository
git clone https://github.com/nwiizo/tfmcp
cd tfmcp

# Build and install
cargo install --path .

From Crates.io

cargo install tfmcp

Using Docker

# Clone the repository
git clone https://github.com/nwiizo/tfmcp
cd tfmcp

# Build the Docker image
docker build -t tfmcp .

# Run the container
docker run -it tfmcp

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md ยท README ยท 607 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # tfmcp: Terraform Model Context Protocol Tool
  2. [![Trust Score](https://archestra.ai/mcp-catalog/api/badge/quality/nwiizo/tfmcp)](https://archestra.ai/mcp-catalog/nwiizo__tfmcp)
  3. *โš ๏ธ This project includes production-ready security features but is still under active development. While the security system provides robust protection, please review all operations carefully in production environments. โš ๏ธ*
  4. tfmcp runs local Terraform workflows through the Model Context Protocol (MCP).
  5. It helps AI assistants inspect a project, prepare execution, review a saved plan,
  6. apply that same plan, and check the result. Registry and HCP/TFE tools support
  7. these local workflows.
  8. ## ๐ŸŽฎ Demo
  9. See tfmcp in action with Claude Desktop:
  10. ![tfmcp Demo with Claude Desktop](https://raw.githubusercontent.com/nwiizo/tfmcp/main/.github/images/tfmcp-demo.gif)
  11. - Reading Terraform configuration files
  12. - Analyzing Terraform plan outputs
  13. - Applying Terraform configurations
  14. - Managing Terraform state
  15. - Creating and modifying Terraform configurations
  16. ## ๐ŸŽ‰ Current Release
  17. tfmcp v0.2.4 is the current release:
  18. ```bash
  19. cargo install tfmcp --version 0.2.4
  20. ```
  21. ### What's new in v0.2.4
  22. - Reviewed destroy plans with the same saved-plan and permission checks as apply
  23. - Saved-plan listing and disposal to reclaim the 64-plan capacity
  24. - Retained apply results, failed/unknown outcomes, and recovery guidance
  25. - Sensitive output redaction for both full and named output queries
  26. - RMCP 3.5.0, updated dependencies and images, with the Rust 1.88 MSRV retained
  27. ## Features
  28. | Area | Capabilities |
  29. | --- | --- |
  30. | Local Terraform | Validate, format, plan/apply workflows, import guidance, outputs, providers, dependency graphs, refresh-only flows, and guarded state operations |
  31. | Repository intelligence | Entrypoint/project detection, configuration analysis, quality checks, security checks, module health, plan review, and drift/state-safety inspection |
  32. | Registry | Public/private provider, module, and policy lookup with HashiCorp-compatible aliases |
  33. | HCP Terraform / TFE | Organizations, projects, workspaces, runs, plans, applies, variables, policy sets, variable sets, tags, stacks, and gated operations |
  34. | MCP deployment | stdio and Streamable HTTP, MCP 2026-07-28 discovery, structured tool results, cache hints, toolsets, resources, health/metrics, sessions, Host/Origin validation, rate limits, TLS wiring, and audit logging |
  35. | Packaging | Cargo, Docker/OCI metadata, MCP Registry metadata, Rust Edition 2024 |
  36. ## Installation
  37. ### From Source
  38. ```bash
  39. # Clone the repository
  40. git clone https://github.com/nwiizo/tfmcp
  41. cd tfmcp
  42. # Build and install
  43. cargo install --path .
  44. ```
  45. ### From Crates.io
  46. ```bash
  47. cargo install tfmcp
  48. ```
  49. ### Using Docker
  50. ```bash
  51. # Clone the repository
  52. git clone https://github.com/nwiizo/tfmcp
  53. cd tfmcp
  54. # Build the Docker image
  55. docker build -t tfmcp .
  56. # Run the container
  57. docker run -it tfmcp
  58. ```
  59. ## Requirements
  60. - Rust 1.88.0+ (Rust Edition 2024)
  61. - Terraform CLI 1.15.8 installed and available in `PATH`
  62. - An MCP-compatible AI client (for example, Claude Desktop or Codex)
  63. - Docker (optional, for containerized deployment)
  64. ## Usage
  65. ```bash
  66. $ tfmcp --help
  67. โœจ A CLI tool to manage Terraform configurations and operate Terraform through the Model Context Protocol (MCP).
  68. Usage: tfmcp [OPTIONS] [COMMAND]
  69. Commands:
  70. mcp Launch tfmcp as an MCP server
  71. analyze Analyze Terraform configurations
  72. help Print this message or the help of the given subcommand(s)
  73. Options:
  74. -c, --config <PATH> Path to the configuration file
  75. -d, --dir <PATH> Terraform project directory
  76. -V, --version Print version
  77. -h, --help Print help
  78. ```
  79. ### Using Docker
  80. When using Docker, you can run tfmcp commands like this:
  81. ```bash
  82. # Run as MCP server (default)
  83. docker run -it tfmcp
  84. # Run with specific command and options
  85. docker run -it tfmcp analyze --dir /app/example
  86. # Mount your Terraform project directory
  87. docker run -it -v /path/to/your/terraform:/app/terraform tfmcp --dir /app/terraform
  88. # Set environment variables
  89. docker run -it -e TFMCP_LOG_LEVEL=debug tfmcp
  90. ```
  91. ### Integrating with Claude Desktop
  92. To use tfmcp with Claude Desktop:
  93. 1. If you haven't already, install tfmcp:
  94. ```bash
  95. cargo install tfmcp
  96. ```
  97. Alternatively, you can use Docker:
  98. ```bash
  99. docker build -t tfmcp .
  100. ```
  101. 2. Find the path to your installed tfmcp executable:
  102. ```bash
  103. which tfmcp
  104. ```
  105. 3. Add the following configuration to `~/Library/Application\ Support/Claude/claude_desktop_config.json`:
  106. ```json
  107. {
  108. "mcpServers": {
  109. "tfmcp": {
  110. "command": "/path/to/your/tfmcp", // Replace with the actual path from step 2
  111. "args": ["mcp"],
  112. "env": {
  113. "HOME": "/Users/yourusername", // Replace with your username
  114. "PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
  115. "TERRAFORM_DIR": "/path/to/your/terraform/project" // Optional: specify your Terraform project
  116. }
  117. }
  118. }
  119. }
  120. ```
  121. If you're using Docker with Claude Desktop, you can set up the configuration like this:
  122. ```json
  123. {
  124. "mcpServers": {
  125. "tfmcp": {
  126. "command": "docker",
  127. "args": ["run", "--rm", "-v", "/path/to/your/terraform:/app/terraform", "tfmcp", "mcp"],
  128. "env": {
  129. "TERRAFORM_DIR": "/app/terraform"
  130. }
  131. }
  132. }
  133. }
  134. ```
  135. 4. Restart Claude Desktop and enable the tfmcp tool.
  136. 5. tfmcp will automatically create a sample Terraform project in `~/terraform` if one doesn't exist, ensuring Claude can start working with Terraform right away. The sample project is based on the examples included in the `example/demo` directory of this repository.
  137. ## Local plan/apply workflow
  138. Start with `tfmcp --dir /path/to/project mcp --toolsets terraform`.
  139. The default toolset supports preparation and plan review; the `terraform`
  140. toolset also exposes initialization and gated local writes.
  141. 1. Call `prepare_terraform_change` to inspect the selected directory, Terraform
  142. version, workspace, backend, configuration validity, and state readability.
  143. `ready` means the inspected prerequisites passed; input variables and provider
  144. credentials are checked by the actual plan. Initialize with `init_terraform`
  145. when required, then repeat preparation.
  146. 2. Call `get_terraform_plan` with `{}` or, for example,
  147. `{"var_files":["environment.tfvars"]}`. The result includes a `plan_id`,
  148. `target`, `created_at`, `has_changes`, and a redacted Terraform JSON `plan` string.
  149. Use `replace` for resource replacement addresses or `refresh_only:true` to
  150. preview drift without modifying state.
  151. 3. Pass the returned `plan_id` to `analyze_plan`, `review_terraform_plan`, and
  152. `summarize_plan_for_pr`. These calls reuse the saved result. Omitting the ID
  153. creates a new plan. A review decision is advisory and does not authorize apply.
  154. 4. After reviewing and approving the change, call `apply_terraform` with
  155. `{"plan_id":"<returned ID>","auto_approve":true}`. Both
  156. `TFMCP_ALLOW_DANGEROUS_OPS=true` and `TFMCP_ALLOW_AUTO_APPROVE=true` must already
  157. be configured on the server. The saved plan determines the applied changes,
  158. including when configuration files have subsequently been edited.
  159. 5. Check `success`, `status`, `exit_code`, `diagnostics`, `state_verified`, and
  160. `recovery.next_steps` in the apply result. Retrieve the plan's final status and
  161. retained `apply_result` with
  162. `get_terraform_plan({"plan_id":"<returned ID>"})`. After failure or timeout,
  163. inspect state and create a new plan; the attempted ID cannot be applied again.
  164. **Migration from v0.2.2:** `apply_terraform` requires `plan_id`; calls that only
  165. provide `auto_approve` now return an explanatory error. Approval happens in the
  166. client before the call, because Terraform receives no interactive input.
  167. For a reviewed teardown, create a plan with `get_terraform_plan({"destroy":true})`,
  168. review its `plan_id`, then call `destroy_terraform` with that ID and
  169. `auto_approve:true`. The server must also have `TFMCP_DELETE_ENABLED=true`, in
  170. addition to both apply permissions. Passing a destroy plan to `apply_terraform`
  171. enforces the same permissions. `destroy` cannot be combined with `refresh_only`
  172. or `replace`. **Migration from v0.2.3:** `destroy_terraform` now requires a saved
  173. destroy plan; it no longer creates an unreviewed plan or waits for a prompt.
  174. Use `list_terraform_plans` to find retained IDs and their targets and statuses.
  175. Use `discard_terraform_plan({"plan_id":"<ID>"})` to delete an unneeded plan's
  176. temporary files and free capacity. Discard does not change infrastructure,
  177. cancel an operation, or roll back an apply; inspect failed or unknown outcomes
  178. before removing their records. These tools are available in the default and
  179. Terraform toolsets.
  180. Saved plans use private temporary directories and are bound to the project,
  181. workspace, initialized backend metadata, Terraform version, and provider
  182. lockfile. Plan IDs remain valid only for the current server process, with a
  183. maximum of 64 retained plans. Normal server shutdown removes the temporary
  184. files. `failed` means Terraform returned a nonzero exit code and may have applied
  185. some changes. `outcome_unknown` means no definitive exit result was obtained,
  186. including timeout or cancellation. Both prevent reapplying the same plan and
  187. include recovery guidance: confirm operations have stopped, inspect the recorded
  188. target and actual resources, resolve the cause, then generate and review a new
  189. plan. No rollback or automatic retry is performed. `apply_result` is null when a
  190. request was cancelled before a result could be retained. State verification checks
  191. resource addresses, not all attribute values or output values.
  192. Status retrieval waits for an ongoing operation
  193. to finish; live progress and restart recovery are not provided in this release.
  194. ## MCP Tools
  195. tfmcp provides the following MCP tools for AI assistants:
  196. ### Core Terraform Operations
  197. | Tool | Description |
  198. |------|-------------|
  199. | `init_terraform` | Initialize Terraform working directory |
  200. | `get_terraform_plan` | Generate a saved plan, or retrieve its redacted result and status by plan ID |
  201. | `list_terraform_plans` | List saved plan IDs, targets, statuses, and destroy flags |
  202. | `discard_terraform_plan` | Remove an unneeded saved plan and free retention capacity |
  203. | `analyze_plan` | **NEW** Analyze plan with risk scoring and recommendations |
  204. | `apply_terraform` | Apply the reviewed saved plan ID and verify state resource addresses |
  205. | `destroy_terraform` | Apply a reviewed saved destroy plan with explicit deletion permissions |
  206. | `validate_terraform` | Validate configuration syntax |
  207. | `validate_terraform_detailed` | Detailed validation with guidelines |
  208. | `get_terraform_state` | Show current state |
  209. | `analyze_state` | **NEW** Analyze state with drift detection |
  210. | `review_terraform_plan` | Review plan risk, blockers, destructive changes, and recommendations |
  211. | `summarize_plan_for_pr` | Generate markdown plan summary for PR comments |
  212. | `run_terraform_quality_checks` | Run CI-friendly validation, module health, guideline, and lockfile checks |
  213. | `inspect_state_safety` | Inspect state readability, drift risk, lockfile status, and blockers |
  214. | `detect_drift_candidates` | Detect drift candidates from readable state without modifying infrastructure |
  215. | `prepare_terraform_change` | Generate blockers, warnings, and a recommended change sequence |
  216. | `list_terraform_resources` | List all managed resources |
  217. | `set_terraform_directory` | Change active project directory |
  218. ### Workspace & State (v0.1.9)
  219. | Tool | Description |
  220. |------|-------------|
  221. | `terraform_workspace` | **NEW** Manage workspaces (list, show, new, select, delete) |
  222. | `terraform_import` | **NEW** Import existing resources |
  223. | `terraform_taint` | **NEW** Taint/untaint resources |
  224. | `terraform_refresh` | **NEW** Refresh state |
  225. ### Code & Output (v0.1.9)
  226. | Tool | Description |
  227. |------|-------------|
  228. | `terraform_fmt` | **NEW** Format code |
  229. | `terraform_graph` | **NEW** Generate dependency graph |
  230. | `terraform_output` | Get output values with sensitive values redacted, including named queries |
  231. | `terraform_providers` | **NEW** Get provider info with lock file |
  232. | `check_provider_lockfile` | Check `.terraform.lock.hcl` for reproducible provider selections |
  233. ### Analysis & Security
  234. | Tool | Description |
  235. |------|-------------|
  236. | `analyze_terraform` | Analyze configuration |
  237. | `inspect_terraform_project` | Inspect local Terraform directories, modules, and likely entrypoints |
  238. | `detect_terraform_entrypoints` | Detect likely root module entrypoints |
  239. | `analyze_module_health` | Module health with cohesion/coupling metrics |
  240. | `get_resource_dependency_graph` | Resource dependencies visualization |
  241. | `suggest_module_refactoring` | Refactoring suggestions |
  242. | `get_security_status` | Security scan with secret detection |
  243. ### Registry
  244. | Tool | Description |
  245. |------|-------------|
  246. | `search_providers` | Search providers (HashiCorp-compatible alias) |
  247. | `search_terraform_providers` | Search providers |
  248. | `get_provider_details` | Provider details (HashiCorp-compatible alias) |
  249. | `get_provider_info` | Provider details |
  250. | `get_provider_docs` | Provider documentation |
  251. | `get_provider_capabilities` | Provider resources, data sources, functions, and guides |
  252. | `search_modules` | Search modules (HashiCorp-compatible alias) |
  253. | `search_terraform_modules` | Search modules |
  254. | `get_module_details` | Module details |
  255. | `get_latest_module_version` | Latest module version |
  256. | `get_latest_provider_version` | Latest provider version |
  257. | `search_policies` | Search Sentinel/OPA policy libraries |
  258. | `get_policy_details` | Policy library details |
  259. ### HCP Terraform / Terraform Enterprise (Read-only)
  260. | Tool | Description |
  261. |------|-------------|
  262. | `get_token_permissions` | Inspect configured token account details without exposing the token |
  263. | `list_terraform_orgs` | List visible organizations |
  264. | `list_terraform_projects` | List projects in an organization |
  265. | `list_workspaces` | List workspaces in an organization |
  266. | `get_workspace_details` | Get workspace details by ID or organization/name |
  267. | `list_runs` | List workspace runs |
  268. | `get_run_details` | Get run details |
  269. | `get_plan_details` | Get plan details |
  270. | `get_plan_logs` | Get plan logs |
  271. | `get_plan_json_output` | Get Terraform JSON plan output |
  272. | `get_apply_details` | Get apply details |
  273. | `get_apply_logs` | Get apply logs |
  274. | `get_workspace_policy_sets` | Get policy sets attached to a workspace |
  275. | `list_workspace_variables` | List workspace variables |
  276. | `list_variable_sets` | List organization variable sets |
  277. | `read_workspace_tags` | Read workspace tags |
  278. | `list_stacks` | List Terraform stacks |
  279. | `get_stack_details` | Get Terraform stack details |
  280. | `search_private_modules` | Search private registry modules |
  281. | `get_private_module_details` | Get private registry module details |
  282. | `search_private_providers` | Search private registry providers |
  283. | `get_private_provider_details` | Get private registry provider details |
  284. ### HCP Terraform / Terraform Enterprise (Gated Operations)
  285. | Tool | Description |
  286. |------|-------------|
  287. | `create_workspace` | Create a workspace when `ENABLE_TF_OPERATIONS=true` |
  288. | `update_workspace` | Update workspace settings when `ENABLE_TF_OPERATIONS=true` |
  289. | `delete_workspace_safely` | Use the safe-delete workspace action when `ENABLE_TF_OPERATIONS=true` |
  290. | `create_run` | Queue a run when `ENABLE_TF_OPERATIONS=true` |
  291. | `action_run` | Apply, discard, cancel, force-cancel, or force-execute a run when `ENABLE_TF_OPERATIONS=true` |
  292. | `create_workspace_variable` | Create a workspace variable when `ENABLE_TF_OPERATIONS=true` |
  293. | `update_workspace_variable` | Update a workspace variable when `ENABLE_TF_OPERATIONS=true` |
  294. | `attach_policy_set_to_workspace` | Attach a policy set to a workspace when `ENABLE_TF_OPERATIONS=true` |
  295. | `create_variable_set` | Create a variable set when `ENABLE_TF_OPERATIONS=true` |
  296. | `create_variable_in_variable_set` | Create a variable in a variable set when `ENABLE_TF_OPERATIONS=true` |
  297. | `delete_variable_in_variable_set` | Delete a variable from a variable set when `ENABLE_TF_OPERATIONS=true` |
  298. | `attach_variable_set_to_workspaces` | Attach a variable set to workspaces when `ENABLE_TF_OPERATIONS=true` |
  299. | `detach_variable_set_from_workspaces` | Detach a variable set from workspaces when `ENABLE_TF_OPERATIONS=true` |
  300. | `create_workspace_tags` | Create or attach workspace tags when `ENABLE_TF_OPERATIONS=true` |
  301. ### MCP Resources
  302. | URI | Description |
  303. |-----|-------------|
  304. | `terraform://style-guide` / `/terraform/style-guide` | Terraform style guide |
  305. | `terraform://module-development` / `/terraform/module-development` | Terraform module development guide |
  306. | `terraform://best-practices` | tfmcp security and operational best practices |
  307. | `/terraform/providers/{namespace}/name/{name}/version/{version}` | HashiCorp-compatible provider documentation template |
  308. ## Logs and Troubleshooting
  309. The tfmcp server logs are available at:
  310. ```
  311. ~/Library/Logs/Claude/mcp-server-tfmcp.log
  312. ```
  313. Common issues and solutions:
  314. - **Claude can't connect to the server**: Make sure the path to the tfmcp executable is correct in your configuration
  315. - **Terraform project issues**: tfmcp automatically creates a sample Terraform project if none is found
  316. - **Method not found errors**: tfmcp advertises and implements tools/list, resources/list, resources/templates/list, and resources/read
  317. - **Docker issues**: If using Docker, ensure your container has proper volume mounts and permissions
  318. ## Environment Variables
  319. ### Core Configuration
  320. - `TERRAFORM_DIR`: Set this to specify a custom Terraform project directory. If not set, tfmcp will use the directory provided by command line arguments, configuration files, or fall back to `~/terraform`. You can also change the project directory at runtime using the `set_terraform_directory` tool.
  321. - `TFMCP_LOG_LEVEL`: Set to `debug`, `info`, `warn`, or `error` to control logging verbosity.
  322. - `TFMCP_DEMO_MODE`: Set to `true` to enable demo mode with additional safety features.
  323. - `TFMCP_COMMAND_TIMEOUT_SECONDS`: Positive timeout in seconds for init, plan, saved-plan apply, validation, and execution preparation (default: `900`). Timed-out writes may have partially completed; inspect state before retrying.
  324. ### Security Configuration
  325. - `ENABLE_TF_OPERATIONS`: Set to `true` to enable gated HCP Terraform / Terraform Enterprise write tools (default: `false`)
  326. - `TFMCP_ALLOW_DANGEROUS_OPS`: Set to `true` to enable apply/destroy operations (default: `false`)
  327. - `TFMCP_DELETE_ENABLED`: Set to `true` to apply saved destroy plans; both apply permissions are also required (default: `false`)
  328. - `TFMCP_ALLOW_AUTO_APPROVE`: Set to `true` to enable auto-approve for dangerous operations (default: `false`)
  329. - `TFMCP_MAX_RESOURCES`: Set maximum number of resources that can be managed (default: 50)
  330. - `TFMCP_AUDIT_ENABLED`: Set to `false` to disable audit logging (default: `true`)
  331. - `TFMCP_AUDIT_LOG_FILE`: Custom path for audit log file (default: `~/.tfmcp/audit.log`)
  332. - `TFMCP_AUDIT_LOG_SENSITIVE`: Set to `true` to include sensitive information in audit logs (default: `false`)
  333. ### HCP Terraform / Terraform Enterprise
  334. - `TFE_ADDRESS`: HCP Terraform or Terraform Enterprise base URL (default: `https://app.terraform.io`)
  335. - `TFE_TOKEN`: API token for HCP Terraform / Terraform Enterprise tools
  336. - `TFE_SKIP_TLS_VERIFY`: Set to `true` only for trusted private TFE installations with custom TLS
  337. - `TFE_MAX_RESPONSE_BYTES`: Maximum HCP/TFE response bytes returned to MCP clients before truncation (default: `65536`)
  338. HCP/TFE write tools are disabled by default and fail closed unless
  339. `ENABLE_TF_OPERATIONS=true` is set. The `default` toolset keeps write tools
  340. hidden; use `--toolsets operations` or `--toolsets all` to expose them.
  341. ### MCP Transport
  342. - `TRANSPORT_MODE`: MCP transport mode. Use `stdio` (default) for local desktop clients or `streamable-http` for remote/CI clients.
  343. - `TRANSPORT_HOST`: HTTP bind host for streamable HTTP mode (default: `127.0.0.1`).
  344. - `TRANSPORT_PORT`: HTTP bind port for streamable HTTP mode (default: `8080`).
  345. - `MCP_ENDPOINT`: Streamable HTTP MCP endpoint path (default: `/mcp`).
  346. - `MCP_HEALTH_ENDPOINT`: Health endpoint path (default: `/health`).
  347. - `MCP_METRICS_ENDPOINT`: OTel-compatible JSON metrics snapshot endpoint path (default: `/metrics`).
  348. - `MCP_SESSION_MODE`: `stateful` for normal MCP clients or `stateless` for CI-style JSON responses (default: `stateful`). Applies only to clients negotiating a protocol version before `2026-07-28`; that spec removed sessions, so those requests are always served statelessly.
  349. - `MCP_HEARTBEAT_INTERVAL`: Streamable HTTP SSE keep-alive interval in seconds. Set to `0` to disable (default: `15`).
  350. - `MCP_CORS_MODE`: Response CORS policy: `strict`, `development`, or `disabled` (default: `strict`). MCP request Origin validation remains enabled in all modes.
  351. - `MCP_ALLOWED_ORIGINS`: Comma-separated allowed browser origins. Loopback origins are used by default.
  352. - `MCP_ALLOWED_HOSTS`: Comma-separated HTTP `Host` / authority values accepted by Streamable HTTP. When unset, rmcp's loopback-only defaults apply.
  353. - `MCP_ORGANIZATION_ALLOWLIST`: Comma-separated HCP/TFE organization names that remote requests may access.
  354. - `MCP_RATE_LIMIT_GLOBAL`: Maximum HTTP requests per minute across the server (`0` or unset disables).
  355. - `MCP_RATE_LIMIT_SESSION`: Maximum HTTP requests per minute per `Mcp-Session-Id` (`0` or unset disables). Clients negotiating `2026-07-28` send no session header, so only `MCP_RATE_LIMIT_GLOBAL` bounds them.
  356. - `MCP_TLS_CERT_FILE`: PEM certificate file for HTTPS Streamable HTTP.
  357. - `MCP_TLS_KEY_FILE`: PEM private key file for HTTPS Streamable HTTP.
  358. HCP/TFE credentials and addresses are server configuration. tfmcp intentionally
  359. does not accept request-scoped `TFE_TOKEN`, `Authorization`, or `TFE_ADDRESS`
  360. overrides for downstream passthrough. When an organization allowlist is active,
  361. account-wide and ID-only HCP/TFE requests fail closed because their owning
  362. organization cannot be verified locally.
  363. Example streamable HTTP launch:
  364. ```bash
  365. TRANSPORT_MODE=streamable-http \
  366. TRANSPORT_HOST=127.0.0.1 \
  367. TRANSPORT_PORT=8080 \
  368. tfmcp mcp --toolsets default
  369. ```
  370. The MCP endpoint is `http://127.0.0.1:8080/mcp`, the health endpoint is
  371. `http://127.0.0.1:8080/health`, and the metrics endpoint is
  372. `http://127.0.0.1:8080/metrics`.
  373. ## Security Considerations
  374. tfmcp includes comprehensive security features designed for production use:
  375. ### ๐Ÿ”’ Built-in Security Features
  376. - **Access Controls**: Automatic blocking of production/sensitive file patterns
  377. - **Operation Restrictions**: Dangerous operations (apply/destroy) disabled by default
  378. - **Resource Limits**: Configurable maximum resource count protection
  379. - **Audit Logging**: Complete operation tracking with timestamps and user identification
  380. - **Directory Validation**: Security policy enforcement for project directories
  381. ### ๐Ÿ›ก๏ธ Security Best Practices
  382. - **Default Safety**: Apply/destroy operations are disabled by default - explicitly enable only when needed
  383. - **Review Plans**: Always review Terraform plans before applying, especially AI-generated ones
  384. - **IAM Boundaries**: Use appropriate IAM permissions and role boundaries in cloud environments
  385. - **Audit Monitoring**: Regularly review audit logs at `~/.tfmcp/audit.log`
  386. - **File Patterns**: Built-in protection against accessing `prod*`, `production*`, and `secret*` patterns
  387. - **Docker Security**: When using containers, carefully consider volume mounts and exposed data
  388. ### โš™๏ธ Production Configuration
  389. ```bash
  390. # Recommended production settings
  391. export TFMCP_ALLOW_DANGEROUS_OPS=false # Keep disabled for safety
  392. export TFMCP_ALLOW_AUTO_APPROVE=false # Require manual approval
  393. export TFMCP_MAX_RESOURCES=10 # Limit resource scope
  394. export TFMCP_AUDIT_ENABLED=true # Enable audit logging
  395. export TFMCP_AUDIT_LOG_SENSITIVE=false # Don't log sensitive data
  396. ```
  397. ## Contributing
  398. Contributions are welcome! Please feel free to submit a Pull Request.
  399. 1. Fork the repository
  400. 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
  401. 3. Enable the repository-managed fast pre-commit checks once per clone:
  402. ```bash
  403. git config core.hooksPath .githooks
  404. ```
  405. 4. Run the full correctness checks before pushing:
  406. ```bash
  407. cargo fmt --all -- --check
  408. cargo clippy --all-targets --all-features -- -D warnings
  409. cargo test --locked --all-targets --all-features
  410. ```
  411. 5. Commit your changes (`git commit -m 'Add some amazing feature'`)
  412. 6. Push to the branch (`git push origin feature/amazing-feature`)
  413. 7. Open a Pull Request
  414. The pre-commit hook always checks staged whitespace and conditionally runs
  415. `cargo fmt`, `actionlint`, Registry metadata validation, module coupling, and
  416. duplicate-code checks for affected files. The optional architecture tools are
  417. still mandatory in `Release.sh`; install `cargo-coupling` and `similarity-rs`
  418. to run the same fast feedback while developing.
  419. ### Release Process
  420. Releases are done manually after the local release gate passes:
  421. 1. Confirm `Cargo.toml`, `Cargo.lock`, `server.json`, `Dockerfile`, README, and `CHANGELOG.md` use the target version.
  422. 2. Run the local release gate: `./Release.sh v0.2.4`.
  423. 3. Review `CHANGELOG.md` and the generated package.
  424. 4. Commit and push `main`, then confirm CI passed for that exact commit.
  425. 5. From the clean commit, publish with `./Release.sh v0.2.4 --publish`.
  426. ## Roadmap
  427. Here are some planned improvements and future features for tfmcp:
  428. For the consolidated v0.2.1 scope and future work, see
  429. [docs/releases/v0.2-roadmap.md](docs/releases/v0.2-roadmap.md). Release changes
  430. are recorded in [CHANGELOG.md](CHANGELOG.md).
  431. The [local development requirements](.claude/docs/local-development-requirements.md)
  432. compare the current implementation with Terraform documentation and the local
  433. Terraform in Depth / Terraform at Scale source material, with prioritized jobs
  434. and acceptance criteria for future work.
  435. For a hands-on check with a real local Web app, see the
  436. [local application example](example/local-app/README.md). It verifies saved-plan
  437. deployment, HTTP responses, actual Terraform arguments, audit records, and
  438. teardown, and retains the report and logs.
  439. ### Completed
  440. - [x] **Basic Terraform Integration**
  441. Core integration with Terraform CLI for analyzing and executing operations.
  442. - [x] **MCP Server Implementation**
  443. Initial implementation of the Model Context Protocol server for AI assistants.
  444. - [x] **Automatic Project Creation**
  445. Added functionality to automatically create sample Terraform projects when needed.
  446. - [x] **Claude Desktop Integration**
  447. Support for seamless integration with Claude Desktop.
  448. - [x] **Core MCP Methods**
  449. Implementation of essential MCP methods including tools/list, resources/list, resources/templates/list, and resources/read.
  450. - [x] **Error Handling Improvements**
  451. Better error handling and recovery mechanisms for robust operation.
  452. - [x] **Dynamic Project Directory Switching**
  453. Added ability to change the active Terraform project directory without restarting the service.
  454. - [x] **Crates.io Publication**
  455. Published the package to Crates.io for easy installation via Cargo.
  456. - [x] **Docker Support**
  457. Added containerization support for easier deployment and cross-platform compatibility.
  458. - [x] **Security Enhancements**
  459. Comprehensive security system with configurable policies, audit logging, access controls, and production-ready safety features.
  460. - [x] **Module Health Analysis (v0.1.6)**
  461. Whitebox approach to IaC with cohesion/coupling metrics, health scoring, and refactoring suggestions.
  462. - [x] **Resource Dependency Graph (v0.1.6)**
  463. Visualization of resource relationships including explicit and implicit dependencies.
  464. - [x] **Module Registry Integration (v0.1.6)**
  465. Search and explore Terraform modules from the registry.
  466. - [x] **Comprehensive Testing Framework**
  467. 85+ tests including integration tests with real Terraform configurations.
  468. - [x] **RMCP SDK Migration (v0.1.8)**
  469. Migrated to official RMCP SDK with proper tool annotations for better MCP compliance.
  470. - [x] **Future Architect Guidelines (v0.1.8)**
  471. Terraform coding standards compliance checks with secret detection and variable quality validation.
  472. ### In Progress
  473. - [ ] **Multi-Environment Support**
  474. Add support for managing multiple Terraform environments, workspaces, and modules.
  475. ### Planned
  476. - [ ] **Expanded MCP Protocol Support**
  477. Implement additional MCP methods and capabilities for richer integration with AI assistants.
  478. - [ ] **Performance Optimization**
  479. Optimize resource usage and response times for large Terraform projects.
  480. - [ ] **Cost Estimation**
  481. Integrate with cloud provider pricing APIs to provide cost estimates for Terraform plans.
  482. - [ ] **Interactive TUI**
  483. Develop a terminal-based user interface for easier local usage and debugging.
  484. - [ ] **Integration with Other AI Platforms**
  485. Extend beyond Claude to support other AI assistants and platforms.
  486. - [ ] **Plugin System**
  487. Develop a plugin architecture to allow extensions of core functionality.
  488. ## License
  489. This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If itโ€™s helped, pass it on.