Infracost MCP Server
The Infracost MCP Server enables Claude to estimate and manage Terraform infrastructure costs using Infracost CLI and Cloud API.
Cost Analysis & Estimation: Generate detailed resource-level cost breakdowns for Terraform configurations, compare costs between different versions or branches, and format reports in multiple formats (JSON, HTML, table, diff). Upload estimates to Infracost Cloud for centralized tracking.
Pull Request Integration: Post and update cost estimate comments automatically to GitHub, GitLab, Azure Repos, or Bitbucket pull requests.
Tagging Policies: List, get, create, update, and delete tagging policies that enforce mandatory tags with validation rules (ANY value, LIST of allowed values, or REGEX patterns). Configure policy scope with filters for repositories, projects, resources, and branches. Block or comment on non-compliant PRs.
Cost Guardrails: List, get, create, update, and delete cost guardrails to control infrastructure spending. Set thresholds for total costs, cost increases (dollar amounts), or percentage increases. Block expensive PRs exceeding thresholds and send webhook notifications. Scope guardrails to all projects, specific repositories, or specific projects.
Custom Properties: Upload custom property values via CSV for resource classification.
Usage Templates: Access predefined usage YAML files (small, medium, large, example) as MCP resources for realistic cost estimation with different usage patterns.
Enables posting cost comments and estimates to Bitbucket pull requests for Terraform infrastructure changes.
Enables posting cost comments and estimates to GitHub pull requests for Terraform infrastructure changes.
Enables posting cost comments and estimates to GitLab pull requests for Terraform infrastructure changes.
Provides tools for Terraform cost estimation and cloud governance, including generating cost breakdowns, comparing configurations, creating tagging policies, setting up cost guardrails, and managing custom properties for resource classification.
Provides cost analysis capabilities for Terraform configurations, including breakdown generation, configuration comparison, and cost estimation for infrastructure as code.
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 generate a cost breakdown for my Terraform config in ./infrastructure"
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
MCP server that lets Claude interact with Infracost for Terraform cost estimation and cloud governance. Works with Claude Desktop and Claude Code.
What it does
Generate cost breakdowns for Terraform configurations
Compare costs between different configs or branches
Create and manage tagging policies in Infracost Cloud
Set up cost guardrails that block expensive PRs
Post cost comments to GitHub/GitLab/Azure/Bitbucket PRs
Upload custom properties for resource classification
Access predefined usage YAML files for cost estimation
Related MCP server: kubopt
Prerequisites
Node.js >= 18
Infracost CLI (for cost estimation tools)
Infracost service token from Infracost Cloud > Org Settings > API tokens
Installation
git clone <repo-url> infracost_mcp
cd infracost_mcp
npm install
npm run buildConfiguration
Create a .env file in the project root:
INFRACOST_SERVICE_TOKEN=ics_v1_your_token_here
INFRACOST_ORG=your_org_slugGet your service token from the Infracost Cloud dashboard under Org Settings > API tokens.
Usage
With Claude Code
The repo includes .mcp.json and .claude/agents/ so it works out of the box - just open the project in Claude Code and the Infracost tools will be available.
With Claude Desktop
Add to your Claude Desktop config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.jsonWindows:
%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"infracost": {
"command": "node",
"args": ["/absolute/path/to/infracost_mcp/dist/index.js"],
"env": {
"INFRACOST_SERVICE_TOKEN": "ics_v1_your_token"
}
}
}
}Restart Claude Desktop after updating the config.
Examples
Natural Language Queries
Ask Claude things like:
Cost Estimation:
"What's the monthly cost of my Terraform in ./infrastructure?"
"Show me a cost breakdown for ./terraform/prod in table format"
"Generate an HTML cost report and save it to report.html"
"Upload the cost estimate from infracost.json to Infracost Cloud"
Cost Comparison:
"Compare costs between ./staging and ./prod configs"
"What's the cost difference if I switch from t3.medium to t3.large?"
"Show me cost changes between the current branch and main"
Tagging Policies:
"Create a tagging policy that requires Environment and Owner tags"
"List all tagging policies for my organization"
"Add a tagging policy that allows only 'dev', 'staging', 'prod' for Environment tags"
"Update the tagging policy to also require a CostCenter tag"
Cost Guardrails:
"Set up a guardrail that blocks PRs adding more than $200/month"
"Create a guardrail that warns when total infrastructure cost exceeds $10k/month"
"Block PRs with cost increases over 25% for my production repo"
"List all active guardrails"
Pull Request Integration:
"Post the cost estimate from infracost.json to GitHub PR #123 in owner/repo"
"Add a cost comment to the current GitLab merge request"
JSON Examples
Generate cost breakdown:
{
"path": "./terraform/prod",
"format": "json",
"outFile": "cost-estimate.json"
}Compare configurations:
{
"path": "./terraform/current",
"compareTo": "./terraform/baseline",
"format": "diff"
}Create tagging policy:
{
"name": "Required tags policy",
"prComment": true,
"blockPr": true,
"tags": [
{
"key": "Environment",
"mandatory": true,
"valueType": "LIST",
"allowedValues": ["dev", "staging", "prod"]
},
{
"key": "Owner",
"mandatory": true,
"valueType": "REGEX",
"allowedRegex": "^[a-z]+\\.[a-z]+@company\\.com$"
}
]
}Create cost guardrail:
{
"name": "Production cost limit",
"scope": {
"type": "REPO",
"repositories": ["myorg/prod-infrastructure"]
},
"increasePercentThreshold": 10,
"totalThreshold": 50000,
"blockPullRequest": true,
"commentOnPullRequest": true
}See docs/EXAMPLES.md for more detailed examples.
Available Tools
CLI Tools (require Infracost CLI)
infracost_breakdown- Generate cost breakdown for Terraform infrastructureinfracost_diff- Show cost differences between two configurationsinfracost_output- Combine and format Infracost JSON filesinfracost_upload- Upload cost estimates to Infracost Cloudinfracost_comment- Post cost comments to pull requests
Cloud API Tools (require service token)
Tagging Policies:
infracost_cloud_list_tagging_policies- List all tagging policiesinfracost_cloud_get_tagging_policy- Get a specific tagging policyinfracost_cloud_create_tagging_policy- Create a new tagging policyinfracost_cloud_update_tagging_policy- Update an existing tagging policyinfracost_cloud_delete_tagging_policy- Delete a tagging policy
Guardrails:
infracost_cloud_list_guardrails- List all guardrailsinfracost_cloud_get_guardrail- Get a specific guardrailinfracost_cloud_create_guardrail- Create a cost guardrailinfracost_cloud_update_guardrail- Update an existing guardrailinfracost_cloud_delete_guardrail- Delete a guardrail
Custom Properties:
infracost_cloud_upload_custom_properties- Upload custom property values via CSV
MCP Resources
The server provides predefined Infracost usage YAML files as MCP resources:
infracost://usage/small- Small usage defaults ($5/month) for development environmentsinfracost://usage/medium- Medium usage defaults ($10/month) for staging environmentsinfracost://usage/large- Large usage defaults ($20/month) for production environmentsinfracost://usage/example- Example template showing how to customize usage values
These resources can be used to understand Infracost usage files or as templates for creating custom usage configurations. Claude can access these resources directly to help you set up cost estimation with realistic usage patterns.
Project Structure
src/- TypeScript source codedist/- Compiled JavaScript output (created bynpm run build)resources/- Predefined Infracost usage YAML filesdocs/- Additional documentation and examples.claude/- Claude Code agent configuration
Development
npm run build # Compile TypeScript
npm run watch # Watch mode for development
npm start # Run the MCP serverTroubleshooting
CLI tools not working:
Verify Infracost CLI is installed:
infracost --versionEnsure
INFRACOST_SERVICE_TOKENis set correctly
Cloud API errors:
Check that your service token has the necessary permissions
Verify the organization slug is correct
Server not connecting:
Ensure the path to
dist/index.jsis absolute in your MCP configRestart Claude Desktop after making config changes
Check that
npm run buildcompleted successfully
No resources found:
Run
terraform initin your Terraform directory firstVerify the path to your Terraform files is correct
Resources
License
MIT
Available Tools
16 toolsinfracost_breakdownB
Generate a cost breakdown for Terraform infrastructure. Analyzes Terraform configuration and provides detailed cost estimates for resources. Requires infracost CLI to be installed.
Inputs: path (required), format, outFile, terraformVarFile, +1 more.
infracost_cloud_create_guardrailB
Create cost guardrails in Infracost Cloud that notify stakeholders or block PRs when cost thresholds are exceeded. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: name (required), scope (required), orgSlug, increaseThreshold, +6 more.
infracost_cloud_create_tagging_policyB
Create a new tagging policy in Infracost Cloud for tag validation in pull requests. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: name (required), tags (required), orgSlug, message, +3 more.
infracost_cloud_delete_guardrailA
Delete a guardrail from Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: guardrailId (required), orgSlug.
infracost_cloud_delete_tagging_policyC
Delete a tagging policy from Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: policyId (required), orgSlug.
infracost_cloud_get_guardrailB
Get a specific guardrail from Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: guardrailId (required), orgSlug.
infracost_cloud_get_tagging_policyB
Get a specific tagging policy from Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: policyId (required), orgSlug.
infracost_cloud_list_guardrailsB
List all guardrails in Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: orgSlug.
infracost_cloud_list_tagging_policiesA
List all tagging policies in Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: orgSlug.
infracost_cloud_update_guardrailC
Update an existing guardrail in Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: guardrailId (required), orgSlug, name, filters, +7 more.
infracost_cloud_update_tagging_policyC
Update tagging policies in Infracost Cloud with allowed tag values for validation in pull requests. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: policyId (required), orgSlug, name, message, +4 more.
infracost_cloud_upload_custom_propertiesA
Upload custom property values to Infracost Cloud via CSV for resource classification. Requires INFRACOST_SERVICE_TOKEN environment variable.
Inputs: csvData (required), orgSlug.
infracost_commentA
Post cost estimate comments to pull requests on GitHub, GitLab, Azure Repos, or Bitbucket. Automatically updates existing comments. Requires infracost CLI to be installed and appropriate platform credentials.
Inputs: path (required), platform (required), repo, pullRequest, +3 more.
infracost_diffA
Show cost differences between two Terraform configurations. Compares baseline and current infrastructure to identify cost changes. Requires infracost CLI to be installed.
Inputs: path (required), compareTo (required), format, outFile.
infracost_outputB
Combine and format Infracost JSON files. Useful for merging multiple cost estimates or converting formats. Requires infracost CLI to be installed.
Inputs: path (required), format, outFile, fields, +1 more.
infracost_uploadB
Upload Infracost JSON output to Infracost Cloud for centralized cost tracking and reporting. Requires infracost CLI to be installed.
Inputs: path (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 16 tools
Each tool has a clearly distinct purpose with no ambiguity. The breakdown, diff, output, upload, and comment tools handle different stages of cost analysis workflows, while the cloud tools are neatly organized into guardrail and tagging policy categories with full CRUD operations. The naming and descriptions make it easy to distinguish between local CLI operations and cloud management functions.
All tools follow a consistent snake_case naming pattern with a clear prefix structure: 'infracost_' for core tools and 'infracost_cloud_' for cloud-specific operations. Within each category, verbs like create, get, list, update, delete are used predictably, making the toolset highly readable and organized.
With 16 tools, the count is slightly high but reasonable for the server's dual purpose of local cost analysis and cloud management. It covers both domains thoroughly without feeling excessive, though it might be borderline for some users. The tools are well-scoped, with each serving a distinct function in the Infracost ecosystem.
The toolset provides complete coverage for the Infracost domain, including local cost breakdowns, comparisons, formatting, uploading, and commenting, plus full CRUD operations for cloud guardrails and tagging policies. There are no obvious gaps; agents can perform all expected workflows from analysis to cloud integration and policy management.
Maintenance
Related MCP Connectors
Costory is the FinOps agent your team builds on. Claude plus a single provider's MCP works for one person and one cloud. It breaks when you add more providers, more people, and more tools to maintain. - Multiple providers: AWS, GCP, Azure, LLM APIs and data clouds normalized and allocated to teams and features in one model, including allocation from telemetry (Kubernetes, Datadog, dbt). - Multiple users: one hosted setup with OAuth, per-user access and enterprise SSO, instead of local credentials and prompts per person. - Maintained for you: tools, skills and connectors kept up to date by Costory, so reorgs and new services don't break your agent. Your agent finds savings, explains every change in spend and issues recommendations that your coding agent can implement. It works in Claude, Cursor and any MCP client, plus Slack. Customers include Alan, Deezer, Delivery Hero, Voodoo and Pennylane. Pricing: Starter from $300/month, flat: unlimited users and data sources, and a fair use that 80% of customers never outgrow. Nothing is ever cut off, and agents connected through the MCP use no AI credits. 30-day free trial.
FinOps assistant: query AWS, GCP and Azure cost, commitments, budgets and reports.
Cloud cost, inventory and governance on AWS/Azure/GCP. Read-only by default, optional scoped writes
Ask about AWS, Azure, GCP, OpenAI, Anthropic and Snowflake costs, budgets, and anomalies.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables users to analyze AWS costs, track spending trends, and detect anomalies directly within Claude Desktop using the AWS Cost Explorer API. It provides tools to identify major cost drivers and compare usage across different time periods through natural language queries.MIT
- AlicenseAqualityCmaintenanceKubernetes cluster cost analysis and optimization. Query costs, find savings opportunities, get rightsizing recommendations, and analyze pod spend across AKS, EKS, and GKE — directly from Claude612Apache 2.0
- AlicenseAqualityCmaintenanceEnables Claude to discover and understand infrastructure-as-code drift by listing projects with drift, analyzing Terraform plan outputs, and providing remediation information.4MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to parse multi-cloud infrastructure-as-code files, query real-time pricing from AWS, Azure, and GCP, and generate cost estimates and comparison reports.62 npmMIT