YT

yawlabs/terraform-cwd-mcp

开发工具官方

本页由 AI 翻译,技术细节请以原文为准。 查看原文

1 stars 0 forks 质量 76 趋势 16MIT

Terraform MCP 服务器,展示本工作目录中真实的内容:固定的提供者模式、保存的计划、涂黑状态、本地模块以及提供者升级影响

概览

一键就能把它添加到你本地的Yaw MCP配置里,这样每次Yaw Terminal会话都能使用。或者在下面手动安装。 它补充了 HashiCorp 的 terraform-mcp-server,而不是取代它:该服务器响应来自 Terraform 注册表文档,描述了最新的提供者版本;而这个服务器则来自你根模块中的 Terraform providers schema -json,描述了你实际锁定的版本。两个都运行。 你的锁文件显示的是 hashicorp/aws 5.31.0;注册表文档(以及模型的训练数据)显示的是之后或更早的版本。代理会写出在你引脚后添加、之前删除,或者仅计算且无法设置的参数。Terraform 验证会在代码写入后捕捉到。这个服务器允许代理在写入前检查。 —— 真实的来源是 Terraform providers schema -json 运行在你的根模块中,版本从 .terraform.lock.hcl 读取。

概述(AI 翻译)

一键就能把它添加到你本地的Yaw MCP配置里,这样每次Yaw Terminal会话都能使用。或者在下面手动安装。

在这个 Terraform 工作目录中,真实的事实是什么:固定在你 .terraform.lock.hcl 中的确切提供者模式(这样编码代理就不会写出不存在、已被删除或只读的参数),还有你保存的计划、状态(已编辑)、本地和已安装的模块,以及提供者升级会破坏什么。 它补充了 HashiCorp 的 terraform-mcp-server,而不是取代它:该服务器的回答来自 Terraform 注册表文档,描述了最新的提供者版本;这个版本来自你根模块中的 terraform providers schema -json,描述了你实际锁定的版本。两个都运行。

由Yaw Labs制造和维护。

为什么是这个?

你的锁文件显示为hashicorp/aws 5.31.0;注册表文档(以及模型的训练数据)显示的是之后或更早的。代理随后写入那些在你引脚后添加、之前移除,或者仅computed且无法设置的参数。terraform validate在代码写入后捕捉到。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

@yawlabs/terraform-cwd-mcp

One click adds this to your local Yaw MCP config so it’s available in every Yaw Terminal session. Or install manually below.

What is actually true in THIS Terraform working directory: the exact provider schemas pinned in your .terraform.lock.hcl (so coding agents stop writing arguments that do not exist, were removed, or are read-only), plus your saved plans, your state (redacted), your local and installed modules, and what a provider upgrade would break. It complements HashiCorp’s terraform-mcp-server rather than replacing it: that server answers from the Terraform Registry docs, which describe the latest provider release; this one answers from terraform providers schema -json in your root module, which describes the version you actually locked. Run both.

Built and maintained by Yaw Labs.

Why this one?

Your lock file says hashicorp/aws 5.31.0; the registry docs (and the model’s training data) say whatever came later or earlier. Agents then write arguments that were added after your pin, removed before it, or are computed-only and cannot be set at all. terraform validate catches it – after the code is written. This server lets the agent check before it writes.

  • Pinned, not latest – the source of truth is terraform providers schema -json run in your root module, with versions read from .terraform.lock.hcl.
  • Read-only, never inits – it never runs terraform init (no downloads, no backend contact, no lock-file rewrites). An uninitialized directory gets an actionable error telling you what to run.
  • Cached per lock file – dumps are cached in memory and on disk, keyed on the root path plus the lock file’s bytes, so a provider upgrade invalidates the cache automatically. The AWS provider’s schema is tens of MB; you pay for that dump once per lock-file change, not per question.
  • Small answers – tf_get_schema renders one type as a compact indented outline with required / optional / optional+computed / computed (read-only), [deprecated], [sensitive] and [write_only] flags, instead of handing the model raw JSON.
  • Cross-platform – macOS, Linux and Windows. Terraform is spawned directly (no shell) and its output is streamed, so there is no buffer ceiling.

Tools

Tool What it does
在 GitHub 查看完整 README

安装

npx -y @yawlabs/terraform-cwd-mcp@latest
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "terraform-cwd": { "command": "npx", "args": ["-y", "@yawlabs/terraform-cwd-mcp@latest"] } } }