io.github.DownAtTheBottomOfTheMoleHole/infracost
编码与调试by downatthebottomofthemolehole
用于集成 Infracost CLI 的 MCP server,为 Infrastructure as Code 提供云成本估算与预算可见性。
什么是 io.github.DownAtTheBottomOfTheMoleHole/infracost?
用于集成 Infracost CLI 的 MCP server,为 Infrastructure as Code 提供云成本估算与预算可见性。
README
Infracost MCP Server

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
| Tool | Category | Typical outcome |
|---|---|---|
infracost_breakdown | Estimation | Monthly cost baseline for current IaC |
infracost_diff | Comparison | Cost delta from a planned change |
infracost_output | Reporting | Rendered table/JSON/HTML/comment output |
infracost_comment | Collaboration | PR comment with estimated impact |
infracost_upload | Cloud Sync | Cost report visible in Infracost Cloud |
infracost_configure | Configuration | Persisted CLI config update/read |
infracost_auth | Authentication | Login flow for Infracost Cloud |
infracost_generate_usage | Utilities | Pre-filled usage file template with defaults |
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
@infracost run infracost_breakdown
@infracost run infracost_diff
@infracost run infracost_output
@infracost run infracost_comment with dryRun true
@infracost run infracost_upload
Run breakdown (infracost_breakdown)
@infracost run infracost_breakdown
Expected output: Baseline cost estimate with command output, exit code, stdout, and stderr.
Run diff (infracost_diff)
@infracost run infracost_diff
Expected output: Cost delta from the planned change compared to current baseline.
Render output (infracost_output)
@infracost run infracost_output with format html
Expected output: Formatted output from existing Infracost JSON (auto-detected when possible).
Post PR comment (infracost_comment)
@infracost run infracost_comment with repo owner/repo and pullRequest 123 and dryRun true
Expected output: Generated comment payload, or posted comment when not in dry-run mode. Platform defaults to github.
Upload report (infracost_upload)
@infracost run infracost_upload
Expected output: Upload confirmation for Infracost Cloud ingestion.
Configure CLI (infracost_configure)
@infracost run infracost_configure with:
- set: currency=USD
Expected output: Configuration update confirmation from the CLI.
Authenticate (infracost_auth)
@infracost run infracost_auth
Expected output: Authentication flow prompt or login success details.
Generate usage file (infracost_generate_usage)
@infracost run infracost_generate_usage with:
- resourceTypes: ["aws_lambda_function", "aws_s3_bucket", "aws_dynamodb_table"]
- outputFilePath: ./infracost-usage.json
- includeGuidance: true
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
npm install
npm run build
Configuration
Usage with VS Code Copilot Chat
This workspace is preconfigured in .vscode/mcp.json:
{
"servers": {
"infracost": {
"type": "stdio",
"command": "node",
"args": ["./dist/index.js"]
}
}
}
Reload VS Code (Cmd+Shift+P -> Developer: Reload Window) after changing MCP configuration.
Then query the server from Copilot Chat with @infracost, for example:
@infracost run infracost_breakdown
@infracost run infracost_diff
Usage with Other MCP Clients
Use stdio transport with the built entrypoint:
{
"name": "infracost-mcp-server",
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/infracost-mcp/dist/index.js"]
}
Build first with npm run build, then start your MCP client.
Running
npm start
Development mode:
npm run dev
Built mode:
npm run start
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:
@infracost run infracost_breakdown
Interactive VS Code Workflows
1. PR Cost Impact Review
- Generate a baseline:
@infracost run infracost_breakdown with:
- path: .
- format: json
- Generate a diff:
@infracost run infracost_diff with:
- path: .
- format: diff
- Draft a PR comment:
@infracost run infracost_comment with:
- platform: github
- path: infracost-diff.json
- repo: owner/repo
- pullRequest: 123
- dryRun: true
2. Reporting Pipeline Setup
- Render a report for humans:
@infracost run infracost_output with:
- path: infracost-diff.json
- format: html
- Upload for centralized tracking:
@infracost run infracost_upload with:
- path: infracost-diff.json
3. Environment Bootstrap
- Configure defaults:
@infracost run infracost_configure with:
- set: currency=USD
- Authenticate:
@infracost run infracost_auth
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
npm run lint
npm test
npm run build
License
Licensed under the MIT License.
常见问题
io.github.DownAtTheBottomOfTheMoleHole/infracost 是什么?
用于集成 Infracost CLI 的 MCP server,为 Infrastructure as Code 提供云成本估算与预算可见性。
相关 Skills
网页构建器
by anthropics
面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。
✎ 在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。
网页应用测试
by anthropics
用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。
✎ 借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。
前端设计
by anthropics
面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。
✎ 想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。
相关 MCP Server
GitHub
编辑精选by GitHub
GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。
✎ 这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。
Context7 文档查询
编辑精选by Context7
Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。
✎ 它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。
by tldraw
tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。
✎ 这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。