Infracost MCP Server
This server lets you estimate, compare, report, and collaborate on cloud infrastructure costs using the Infracost CLI via MCP tools.
infracost_breakdown: Generate baseline monthly cost estimates for Terraform/IaC projects.infracost_diff: Compare current vs planned infrastructure to show cost deltas.infracost_output: Render existing Infracost JSON into tables, HTML, comments, or other formats.infracost_comment: Post cost estimate comments to PRs on GitHub, GitLab, Azure Repos, or Bitbucket.infracost_upload: Upload cost reports to Infracost Cloud for centralized visibility.infracost_configure: Get or set Infracost CLI configuration (e.g., currency, API key).infracost_auth: Authenticate with Infracost Cloud via API key or browser login.infracost_generate_usage: Generate pre-filled usage files with sensible defaults for supported resource types.
Allows posting Infracost cost estimates as comments on Bitbucket pull requests.
Allows posting Infracost cost estimates as comments on GitHub pull requests.
Allows posting Infracost cost estimates as comments on GitLab merge requests.
Provides tools for interacting with Infracost to estimate, compare, and publish infrastructure cost changes from Terraform and other IaC projects.
Enables cost estimation and diffing of Terraform configurations and plan files using the Infracost CLI.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Infracost MCP Server estimate the cost of my Terraform project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 |
| Estimation | Monthly cost baseline for current IaC |
| Comparison | Cost delta from a planned change |
| Reporting | Rendered table/JSON/HTML/comment output |
| Collaboration | PR comment with estimated impact |
| Cloud Sync | Cost report visible in Infracost Cloud |
| Configuration | Persisted CLI config update/read |
| Authentication | Login flow for Infracost Cloud |
| Utilities | Pre-filled usage file template with defaults |
Related MCP server: AWS Pricing Calculator MCP Server
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_uploadRun breakdown (infracost_breakdown)
@infracost run infracost_breakdownExpected output: Baseline cost estimate with command output, exit code, stdout, and stderr.
Run diff (infracost_diff)
@infracost run infracost_diffExpected output: Cost delta from the planned change compared to current baseline.
Render output (infracost_output)
@infracost run infracost_output with format htmlExpected 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 trueExpected output: Generated comment payload, or posted comment when not in dry-run mode. Platform defaults to github.
Upload report (infracost_upload)
@infracost run infracost_uploadExpected output: Upload confirmation for Infracost Cloud ingestion.
Configure CLI (infracost_configure)
@infracost run infracost_configure with:
- set: currency=USDExpected output: Configuration update confirmation from the CLI.
Authenticate (infracost_auth)
@infracost run infracost_authExpected 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: trueExpected 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.0npm (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 buildConfiguration
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_diffUsage 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 startDevelopment mode:
npm run devBuilt mode:
npm run startDebugging
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_breakdownInteractive VS Code Workflows
1. PR Cost Impact Review
Generate a baseline:
@infracost run infracost_breakdown with:
- path: .
- format: jsonGenerate a diff:
@infracost run infracost_diff with:
- path: .
- format: diffDraft a PR comment:
@infracost run infracost_comment with:
- platform: github
- path: infracost-diff.json
- repo: owner/repo
- pullRequest: 123
- dryRun: true2. Reporting Pipeline Setup
Render a report for humans:
@infracost run infracost_output with:
- path: infracost-diff.json
- format: htmlUpload for centralized tracking:
@infracost run infracost_upload with:
- path: infracost-diff.json3. Environment Bootstrap
Configure defaults:
@infracost run infracost_configure with:
- set: currency=USDAuthenticate:
@infracost run infracost_authBest 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 buildLicense
Licensed under the MIT License.
Available Tools
8 toolsinfracost_authA
Authenticate with Infracost Cloud. Opens browser for login flow.
Inputs: apiKey, extraArgs, timeoutSeconds, workingDirectory.
infracost_breakdownB
Generate cost breakdown for Infrastructure as Code (Terraform, CloudFormation, etc.). Shows cost estimates for cloud resources.
Inputs: path, apiKey, fields, format, +10 more.
infracost_commentA
Post cost estimate comments to pull requests on GitHub, GitLab, Azure Repos, or Bitbucket.
Inputs: tag, path, repo, token, +9 more.
infracost_configureB
Get or set Infracost configuration options (API key, currency, etc.).
Inputs: get, set, apiKey, extraArgs, +2 more.
infracost_diffA
Show cost diff between current IaC and planned changes. Useful for pull request reviews to understand cost impact.
Inputs: path, apiKey, format, showSkus, +9 more.
infracost_generate_usageB
Generate Infracost usage file with sensible defaults for specified resource types. Complements infracost_configure by providing pre-filled templates.
Inputs: resourceTypes (required), onlyJson, outputFilePath, includeGuidance.
infracost_outputB
Format Infracost JSON output to different formats (table, html, github-comment, etc.).
Inputs: path, apiKey, fields, format, +4 more.
infracost_uploadA
Upload Infracost JSON output to Infracost Cloud for centralized cost visibility and reporting.
Inputs: path, apiKey, extraArgs, timeoutSeconds, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct action: breakdown (cost estimate), diff (comparison), output (formatting), comment (posting), upload (cloud sync), configure (settings), auth (login), and generate_usage (usage templates). There is no ambiguity between them.
All tools follow the consistent `infracost_<verb>` pattern, using snake_case throughout. Even though some verbs are nouns (output, breakdown), the prefix and lowercase snake_case make the set uniform and predictable.
Eight tools is a well-scoped count for a cost-estimation server, covering core operations without bloat. Each tool serves a clear purpose in the workflow.
The domain (Infracost cost analysis) is fully covered: generating estimates, diffs, formatted output, PR comments, cloud upload, authentication, configuration, and usage file generation. No obvious gaps exist for the intended purpose.
Maintenance
Related MCP Connectors
Hosted MCP server for AWS cloud spend: service breakdowns, anomalies, savings and forecasts.
The MCP server for Azure DevOps, bringing the power of Azure DevOps directly to your agents.
MCP server for Appcircle mobile CI/CD platform.
Related MCP Servers
- AlicenseAqualityCmaintenanceCloud cost management MCP server for Azure. Ask your AI about your cloud bill.15104 npm1MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that provides tools for automating AWS Pricing Calculator estimate generation.MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for managing Terraform infrastructure as code, enabling initialization, planning, applying, destroying, validating, and showing state of Terraform configurations.1MIT
- FlicenseBqualityDmaintenanceAn MCP server that gives Claude live access to Azure pricing and cost data — retail prices, VM comparisons, reservation analysis, architecture estimates, and actual subscription spend.9-