
Infracost
io.github.DownAtTheBottomOfTheMoleHole由 GitHub 帳號 DownAtTheBottomOfTheMoleHole 發布v1.0.1更新於 Oct 24, 2026
MCP server for Infracost CLI integration - cloud cost estimates for Infrastructure as Code
概覽
社群維護的 MCP 伺服器,包裝 Infracost CLI,讓助理估算、比較並發布 Terraform 等 IaC 專案的雲端成本變化。
- 可以做什麼
- 為 Terraform/IaC 目錄或 plan JSON 產生每月成本基準並比較計畫變更的成本差額
- 把既有的 Infracost JSON 轉成表格、JSON、HTML 或留言格式
- 在 GitHub、GitLab、Azure Repos 或 Bitbucket 上草擬或張貼 PR 成本留言
- 上傳成本報告到 Infracost Cloud,並讀取或設定 CLI 設定
- 執行 Infracost 登入流程,並為常見的 AWS、Google、Azure 資源類型產生預填用量檔案範本
- 適用情境
- 適合在審查基礎設施即程式碼變更時,直接在助理對話中查看成本影響:合併前成本把關、PR 成本留言、基準快照,或根據已上傳報告的 FinOps 報表。
- 執行需求
- 以 npm 套件形式透過 stdio 在本機執行;需要 Node.js 24.14.0 以上版本,以及已安裝並位於 PATH 中的 Infracost CLI(或以 INFRACOST_BINARY_PATH 指定)。雲端功能需要 INFRACOST_API_KEY 中的 Infracost API 金鑰,張貼 PR 留言需要把平台權杖傳給工具。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Infracost,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Infracost MCP Server
[Down At The Bottom Of The Mole Hole banner]
[CI/Publish] [Coverage] [npm] [License: MIT] [Node Version]
Note: This is a community-maintained MCP server. It is not an official Model Context Protocol server from Infracost.
A Model Context Protocol (MCP) server for running the Infracost CLI to estimate, compare, and publish infrastructure cost changes from Terraform and other Infrastructure as Code projects.
Overview
This server provides eight MCP tools across estimation, reporting, collaboration, and operations workflows:
infracost_breakdownto generate baseline cost estimates.infracost_diffto compare planned cost changes.infracost_outputto render existing Infracost JSON in different formats.infracost_commentto post PR comments on supported SCM platforms.infracost_uploadto upload reports to Infracost Cloud.infracost_configureto get or set CLI configuration.infracost_authto run authentication flow.infracost_generate_usageto generate usage files with sensible defaults.
Platform Compatibility
This MCP server is platform-agnostic and works in local and CI environments:
- Local development
- GitHub Actions
- GitLab CI/CD
- Azure DevOps
- CircleCI, Jenkins, and Bitbucket Pipelines
- AI Agents and Copilot workflows
The primary requirements are Node.js and the Infracost CLI binary.
Tool Matrix
Tools
infracost_breakdown
Runs infracost breakdown.
Inputs:
workingDirectory(string, optional): Command working directory.path(string, optional): Path to Terraform/IaC directory or plan JSON.configFile(string, optional): Path to Infracost config file.usageFile(string, optional): Path to usage file.format(string, optional): Output format. Default:table.fields(string[], optional): Fields to include in output.showSkus(boolean, optional): Include SKU details.syncUsageFile(boolean, optional): Sync usage file with detected resources.compareTo(string, optional): Baseline Infracost JSON path.terraformWorkspace(string, optional): Terraform workspace.terraformPlanFlags(string, optional): Flags forterraform plan.timeoutSeconds(number, optional): Timeout in seconds.extraArgs(string[], optional): Additional CLI arguments.
infracost_diff
Runs infracost diff.
Inputs:
workingDirectory(string, optional): Command working directory.path(string, optional): Path to Terraform/IaC directory or plan JSON.configFile(string, optional): Path to Infracost config file.usageFile(string, optional): Path to usage file.format(string, optional): Output format. Default:table.compareTo(string, optional): Baseline Infracost JSON path.showSkus(boolean, optional): Include SKU details.syncUsageFile(boolean, optional): Sync usage file with detected resources.terraformWorkspace(string, optional): Terraform workspace.terraformPlanFlags(string, optional): Flags forterraform plan.timeoutSeconds(number, optional): Timeout in seconds.extraArgs(string[], optional): Additional CLI arguments.
infracost_output
Runs infracost output.
Inputs:
workingDirectory(string, optional): Command working directory.path(string, optional): Infracost JSON file path. Auto-detected when omitted.format(string, optional): Output format. Default:table.fields(string[], optional): Fields to include in output.showSkus(boolean, optional): Include SKU details.timeoutSeconds(number, optional): Timeout in seconds.extraArgs(string[], optional): Additional CLI arguments.
infracost_comment
Runs infracost comment.
Inputs:
workingDirectory(string, optional): Command working directory.platform(string, optional): Platform (github,gitlab,azure-repos,bitbucket). Default:github.path(string, optional): Infracost JSON file path. Auto-detected when omitted.repo(string, optional): Repository (owner/repo).pullRequest(string, optional): Pull request number.commit(string, optional): Commit SHA.token(string, optional): Platform token.tag(string, optional): Comment tag.behavior(string, optional): Comment update behavior.dryRun(boolean, optional): Generate without posting.timeoutSeconds(number, optional): Timeout in seconds.extraArgs(string[], optional): Additional CLI arguments.
infracost_upload
Runs infracost upload.
Inputs:
workingDirectory(string, optional): Command working directory.path(string, optional): Infracost JSON file path. Auto-detected when omitted.timeoutSeconds(number, optional): Timeout in seconds.extraArgs(string[], optional): Additional CLI arguments.
infracost_configure
Runs infracost configure.
Inputs:
workingDirectory(string, optional): Command working directory.set(string, optional): Set configuration value.get(string, optional): Read configuration value.timeoutSeconds(number, optional): Timeout in seconds.extraArgs(string[], optional): Additional CLI arguments.
infracost_auth
Runs infracost auth login.
Inputs:
workingDirectory(string, optional): Command working directory.timeoutSeconds(number, optional): Timeout in seconds.extraArgs(string[], optional): Additional CLI arguments.
infracost_generate_usage
Generates an Infracost usage file with sensible defaults for specified resource types. This is a utility tool that complements infracost_configure by providing pre-filled templates you can customize for your workloads. Returns both raw JSON and formatted guidance.
Inputs:
resourceTypes(string[], required): Resource types to include (e.g.,["aws_lambda_function", "aws_s3_bucket"]).outputFilePath(string, optional): Path where usage file should be saved (for guidance only).includeGuidance(boolean, optional): Include formatted guidance. Default:true.onlyJson(boolean, optional): Return only raw JSON (no guidance). Default:false.
Supported resource types: aws_lambda_function, aws_instance, aws_db_instance, aws_s3_bucket, aws_dynamodb_table, aws_ebs_volume, aws_cloudfront_distribution, aws_lb, aws_nat_gateway, google_compute_instance, google_storage_bucket, azurerm_windows_virtual_machine, azurerm_linux_virtual_machine, azurerm_storage_account, azurerm_mssql_database.
Prompt Cookbook
Use these minimal prompts in Copilot Chat with @infracost.
CLI tools default to the current workspace root when no path is given.
If you add a file or folder as Copilot context (#file or #folder), reference it in your prompt and the tool will target that path.
The server auto-detects common report files (infracost-diff.json, infracost-base.json, infracost.json), so you usually do not need to pass path for infracost_output, infracost_comment, or infracost_upload.
Quick prompts
Run breakdown (infracost_breakdown)
Expected output: Baseline cost estimate with command output, exit code, stdout, and stderr.
Run diff (infracost_diff)
Expected output: Cost delta from the planned change compared to current baseline.
Render output (infracost_output)
Expected output: Formatted output from existing Infracost JSON (auto-detected when possible).
Post PR comment (infracost_comment)
Expected output: Generated comment payload, or posted comment when not in dry-run mode. Platform defaults to github.
Upload report (infracost_upload)
Expected output: Upload confirmation for Infracost Cloud ingestion.
Configure CLI (infracost_configure)
Expected output: Configuration update confirmation from the CLI.
Authenticate (infracost_auth)
Expected output: Authentication flow prompt or login success details.
Generate usage file (infracost_generate_usage)
Expected output: Pre-filled usage file JSON with sensible defaults, plus guidance on customization and usage. Use onlyJson: true to return only the JSON for programmatic handling.
Dependencies
System Dependencies
- Node.js
>=24.14.0 - npm (bundled with Node.js)
- Infracost CLI installed and available in
PATH(or viaINFRACOST_BINARY_PATH)
npm Dependencies
Runtime:
@modelcontextprotocol/sdk(MCP server SDK)
Development:
typescript(build/compile)tsx(development runner)vitest(unit test runner)@types/node(Node.js typings)
Environment Variables
INFRACOST_API_KEY: Infracost API key for cloud-backed features.INFRACOST_BINARY_PATH: Override path to Infracost binary.
Installation
Configuration
Usage with VS Code Copilot Chat
This workspace is preconfigured in .vscode/mcp.json:
Reload VS Code (Cmd+Shift+P -> Developer: Reload Window) after changing MCP configuration.
Then query the server from Copilot Chat with @infracost, for example:
Usage with Other MCP Clients
Use stdio transport with the built entrypoint:
Build first with npm run build, then start your MCP client.
Running
Development mode:
Built mode:
Debugging
Use .vscode/launch.json:
Debug MCP Server(runsnpm run dev)Debug MCP Server (Built)(runsdist/index.jsafter build)
Set breakpoints in src/index.ts, then press F5.
Testing
See docs/TESTING.md for Copilot Chat scenarios, manual JSON-RPC checks, and troubleshooting guidance.
Quick validation prompt in Copilot Chat:
Interactive VS Code Workflows
1. PR Cost Impact Review
- Generate a baseline:
- Generate a diff:
- Draft a PR comment:
2. Reporting Pipeline Setup
- Render a report for humans:
- Upload for centralized tracking:
3. Environment Bootstrap
- Configure defaults:
- Authenticate:
Best Practices
- Keep
workingDirectoryexplicit when running inside monorepos. - Use
--format jsonfor machine processing and--format tablefor human triage. - Keep
timeoutSecondshigh enough for large Terraform plans. - Prefer
infracost_commentwithdryRun=truebefore posting to production PR threads. - Use
infracost_uploadfor historical visibility in Infracost Cloud.
Additional Use Cases
- Pre-merge cost gates in pull requests.
- Scheduled baseline cost snapshots in CI.
- Cost delta reporting for release trains.
- Team-level FinOps dashboards based on uploaded reports.
Related Projects
Infracost Resources
Model Context Protocol
Community and Contributing
Attribution and License
Maintained by Carl Dawson under the Down At The Bottom Of The Mole Hole organization.
Development
License
Licensed under the MIT License.
來源:README.md,提交 f2615d3
工具
0版本歷史
1- v1.0.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分